首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > VB Dotnet >

刚接触DLLImport.请帮帮忙,该如何解决

2012-01-11 
刚接触DLLImport.请帮帮忙我写了个简单的DLL调用.但是把FindWindow都写成空码了还是找不到窗口.怎么回事?

刚接触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

热点排行