DWORD RasGetErrorString(
_In_ UINT uErrorValue,
_Out_ LPTSTR lpszErrorString,
_In_ DWORD cBufSize
);
說明
根據RAS錯誤代碼獲取錯誤描述內容。
參數
uErrorValue [in]
指定RAS錯誤碼,在RasError.h文件中定義。
lpszErrorString [out]
指向一個緩衝用於接收錯誤描述字符串,該參數不能爲空。
cBufSize [in]
指示lpszErrorString指向的緩衝最大容納的字符數。
返回值
成功時返回ERROR_SUCCESS。
失敗時返回以下列表中的值之一或來自Routing and Remote Access Error Codes或Winerror.h中定義的錯誤碼。該函數失敗時無法通過GetLastError函數獲取信息。
值 | 含義 |
---|---|
ERROR_INVALID_PARAMETER | 參數錯誤。 |
注意事項
沒有辦法事件知道獲取某個錯誤描述字符串需要多少字節長度。錯誤消息字符串通常不會 超過80個字符。傳入一個字符長度爲512的緩衝已足夠使用。如果緩衝長度不足會導致該函數調用失敗並且返回ERROR_INVALID_PARAMETER錯誤。注意cBufSize參數是字符長度而非字節長度,因此對於Unicode版本,實際需要傳入1024字節來保證可以接收到完整的錯誤描述字符串。
示例
#include <windows.h>
#include <stdio.h>
#include "ras.h"
#include "rasdlg.h"
#include <tchar.h>
#define ERROR_VAL 633
#define BUFFER_SIZE 256
DWORD __cdecl wmain(){
DWORD dwRetVal = ERROR_SUCCESS;
UINT uErrorValue = ERROR_VAL;
DWORD cBufSize = BUFFER_SIZE;
WCHAR lpszErrorString[BUFFER_SIZE];
dwRetVal = RasGetErrorString(uErrorValue, lpszErrorString, cBufSize);
if(dwRetVal == ERROR_SUCCESS){
wprintf(L"Error Code %d: %s\n", uErrorValue, lpszErrorString);
}else{
wprintf(L"RasGetErrorString failed, Return Value: %d", dwRetVal);
}
return 0;
}
系統支持
客戶端最小支持 | Windows 2000 專業版 |
---|---|
服務端最小支持 | Windows 2000 Server |
Header | Ras.h |
Library | Rasapi32.lib |
DLL | Rasapi32.dll |
Unicode和ANSI名稱 | RasGetErrorStringW(Unicode)和RasGetErrorStringA(ANSI) |