ErrObject.LastDllError 속성

정의

DLL(동적 연결 라이브러리)을 호출하는 경우 생성되는 시스템 오류 코드를 가져옵니다.

public:
 property int LastDllError { int get(); };
public int LastDllError { get; }
public int LastDllError { [System.Security.SecurityCritical] get; }
member this.LastDllError : int
[<get: System.Security.SecurityCritical>]
member this.LastDllError : int
Public ReadOnly Property LastDllError As Integer

속성 값

DLL(동적 연결 라이브러리)에 대한 호출로 생성된 시스템 오류 코드입니다.

특성

예제

다음 예제에서는 사용 하는 방법을 보여 줍니다는 LastDllError Windows api에서 함수를 호출한 후 속성입니다. PrintWindowCoordinates 프로시저는 창을 호출 하는 핸들을 가져오고는 GetWindowRect 함수입니다. GetWindowRect 창 구성 하는 사각형의 면의 길이 사용 하 여 영역 데이터 구조를 채웁니다. 잘못 된 핸들을 전달 하면 오류가 발생 하 고 오류 번호를 통해 사용할 수는 LastDllError 속성입니다.

Declare Function GetWindowRect Lib "user32" (
    ByVal hwnd As Integer, ByRef lpRect As RECT) As Integer

Public Structure RECT
    Public Left As Integer
    Public Top As Integer
    Public Right As Integer
    Public Bottom As Integer
End Structure

Const ERROR_INVALID_WINDOW_HANDLE As Long = 1400
Const ERROR_INVALID_WINDOW_HANDLE_DESCR As String = 
    "Invalid window handle."
Private Sub PrintWindowCoordinates(ByVal hwnd As Integer)
' Prints left, right, top, and bottom positions
' of a window in pixels.

  Dim rectWindow As RECT

  ' Pass in window handle and empty the data structure.
  ' If function returns 0, an error occurred.
  If GetWindowRect(hwnd, rectWindow) = 0 Then
      ' Check LastDllError and display a dialog box if the error
      ' occurred because an invalid handle was passed.
      If Err.LastDllError = ERROR_INVALID_WINDOW_HANDLE Then
          MsgBox(ERROR_INVALID_WINDOW_HANDLE_DESCR, Title:="Error!")
      End If
  Else
      Debug.Print(rectWindow.Bottom)
      Debug.Print(rectWindow.Left)
      Debug.Print(rectWindow.Right)
      Debug.Print(rectWindow.Top)
  End If
End Sub

설명

LastDllError Visual Basic 코드에서 DLL 호출에만 속성이 적용 됩니다. 호출된 된 함수에서 일반적으로 성공 또는 실패를 나타내는 코드를 반환 해당 호출이 이루어지면 및 LastDllError 속성이 채워집니다. 성공 또는 실패를 나타내는 반환 값을 확인 하려면 DLL의 함수에 대 한 설명서를 확인 합니다. Visual Basic 애플리케이션 즉시 확인 해야 때마다 오류 코드가 반환 되는 LastDllError 속성입니다. 예외가 발생 하지 않습니다 경우는 LastDllError 속성을 설정 합니다.

참고

스마트 디바이스의 경우 이 속성은 항상 0을 반환합니다.

적용 대상

추가 정보