?? getlasterror.htm
字號:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>GetLastError</title>
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
<style><!--
body,table {font-family:"宋體"; font-size: 9pt; line-height:11pt;}
a {text-decoration:none} a:hover {color:red;text-decoration:underline}
--></style>
</head>
<body link="#FF0000" vlink="#FF0000" alink="#FF0000" bgcolor="#FFC8C8">
<div align="center"><center>
<table border="0" width="100%" height="22" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" height="16"><a name="GetLastError">GetLastError</a></td>
</tr>
</table>
</center></div><div align="center"><center>
<table border="1" width="100%" bordercolorlight="#808080" cellspacing="0"
bordercolordark="#FFFFFF">
<tr>
<td width="100%" colspan="2">VB聲明</td>
</tr>
<tr>
<td width="100%" colspan="2">Declare Function GetLastError Lib "kernel32" Alias
"GetLastError" () As Long</td>
</tr>
<tr>
<td width="100%" colspan="2">說明</td>
</tr>
<tr>
<td width="100%" colspan="2">針對之前調用的api函數(shù),用這個函數(shù)取得擴展錯誤信息(在vb里使用:在vb中,用Err對象的GetLastError屬性獲取<a
name="GetLastError">GetLastError</a>的值。這樣做是必要的,因為在api調用返回以及vb調用繼續(xù)執(zhí)行期間,vb有時會重設<a
name="GetLastError">GetLastError</a>的值)</td>
</tr>
<tr>
<td width="100%" colspan="2">返回值</td>
</tr>
<tr>
<td width="100%" colspan="2">Long,由api函數(shù)決定。請參考api32.txt文件,其中列出了一系列錯誤常數(shù);都以ERROR_前綴起頭。常用的錯誤代碼見下表</td>
</tr>
<tr>
<td width="50%">ERROR_INVALID_HANDLE</td>
<td width="50%">無效的句柄作為一個參數(shù)傳遞</td>
</tr>
<tr>
<td width="50%">ERROR_CALL_NOT_IMPLEMENTED</td>
<td width="50%">在win 95下調用專為win nt設計的win32 api函數(shù)</td>
</tr>
<tr>
<td width="50%">ERROR_INVALID_PARAMETER</td>
<td width="50%">函數(shù)中有個參數(shù)不正確</td>
</tr>
<tr>
<td width="100%" colspan="2">注解</td>
</tr>
<tr>
<td width="100%" colspan="2"><p align="left"><a name="GetLastError">GetLastError</a>返回的值通過在api函數(shù)中調用SetLastError或SetLastErrorEx設置。函數(shù)并無必要設置上一次錯誤信息,所以即使一次<a
name="GetLastError">GetLastError</a>調用返回的是零值,也不能擔保函數(shù)已成功執(zhí)行。只有在函數(shù)調用返回一個錯誤結果時,這個函數(shù)指出的錯誤結果才是有效的。通常,只有在函數(shù)返回一個錯誤結果,而且已知函數(shù)會設置<a
name="GetLastError">GetLastError</a>變量的前提下,才應訪問<a
name="GetLastError">GetLastError</a>;這時能保證獲得有效的結果。SetLastError函數(shù)主要在對api函數(shù)進行模擬的dll函數(shù)中使用,所以對vb應用程序來說是沒有意義的</td>
</tr>
</table>
</center></div><div align="center"><center>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="100%"><p align="right"><a href="#GetLastError">Top</a></td>
</tr>
</table>
</center></div>
</body>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -