刚接触DLLImport.请帮帮忙
我写了个简单的DLL调用.但是把FindWindow都写成空码了还是找不到窗口.怎么回事?谢谢指教.
Imports System.Runtime.InteropServices
Imports System
Public Class Form1
Declare Auto Function FindWindow Lib "user32.dll " (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim os As Integer = FindWindow( " ", " ")
If os = 0 Then
MsgBox( "NO OK ")
Else
MsgBox( "OK ")
End If
End Sub
End Class
[解决办法]
Imports System.Runtime.InteropServices
Public Class Form1
Declare Auto Function FindWindow Lib "user32.dll " (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim os As IntPtr = FindWindow(vbNullString, "Form1 ")
If os.Equals(IntPtr.Zero) Then
MsgBox( "NO OK ")
Else
MsgBox( "OK " & os.ToString)
End If
End Sub
End Class