我已经声明了以下 WinAPI 调用
<DllImport("USER32.DLL", EntryPoint:="GetActiveWindow", SetLastError:=True,
CharSet:=CharSet.Unicode, ExactSpelling:=True,
CallingConvention:=CallingConvention.StdCall)>
Public Shared Function GetActiveWindowHandle() As System.IntPtr
End Function
<DllImport("USER32.DLL", EntryPoint:="GetWindowText", SetLastError:=True,
CharSet:=CharSet.Unicode, ExactSpelling:=True,
CallingConvention:=CallingConvention.StdCall)>
Public Shared Function GetActiveWindowText(ByVal hWnd As System.IntPtr, _
ByVal lpString As System.Text.StringBuilder, _
ByVal cch As Integer) As Integer
End Function
然后,我调用这个子程序来获取活动窗口标题栏中的文本
Public Sub Test()
Dim caption As New System.Text.StringBuilder(256)
Dim hWnd As IntPtr = GetActiveWindowHandle()
GetActiveWindowText(hWnd, caption, caption.Capacity)
MsgBox(caption.ToString)
End Sub
最后,我收到以下错误
无法在 DLL 'USER32.DLL' 中找到名为 'GetWindowText' 的入口点
我该如何解决这个问题?