| 1 |
joko |
1.1 |
Attribute VB_Name = "RasErrorHandler" |
| 2 |
|
|
Option Explicit |
| 3 |
|
|
|
| 4 |
|
|
Public Declare Function RasGetErrorString _ |
| 5 |
|
|
Lib "rasapi32.dll" Alias "RasGetErrorStringA" _ |
| 6 |
|
|
(ByVal uErrorValue As Long, ByVal lpszErrorString As String, _ |
| 7 |
|
|
cBufSize As Long) As Long |
| 8 |
|
|
|
| 9 |
|
|
Public Declare Function FormatMessage _ |
| 10 |
|
|
Lib "kernel32" Alias "FormatMessageA" _ |
| 11 |
|
|
(ByVal dwFlags As Long, lpSource As Any, _ |
| 12 |
|
|
ByVal dwMessageId As Long, ByVal dwLanguageId As Long, _ |
| 13 |
|
|
ByVal lpBuffer As String, ByVal nSize As Long, _ |
| 14 |
|
|
Arguments As Long) As Long |
| 15 |
|
|
|
| 16 |
|
|
Function VBRasErrorHandler(rtn As Long) As String |
| 17 |
|
|
Dim strError As String, i As Long |
| 18 |
|
|
strError = String(512, 0) |
| 19 |
|
|
If rtn > 600 Then |
| 20 |
|
|
RasGetErrorString rtn, strError, 512& |
| 21 |
|
|
Else |
| 22 |
|
|
FormatMessage &H1000, ByVal 0&, rtn, 0&, strError, 512, ByVal 0& |
| 23 |
|
|
End If |
| 24 |
|
|
i = InStr(strError, Chr$(0)) |
| 25 |
|
|
If i > 1 Then VBRasErrorHandler = Left$(strError, i - 1) |
| 26 |
|
|
End Function |
| 27 |
|
|
|