VB .NET FindWindow error NotSupportedException

  • Thread starter Thread starter Season
  • Start date Start date
S

Season

Hi, I am facing problem with calling FindWindow at my coding:-

Imports System.Runtime.InteropServices ' For DllImport
Public Class Form1
<DllImport("CoreDll.dll")> _
Private Shared Function FindWindow(ByVal lpClassName As String, ByVal
lpWindowName As String) As Long
End Function

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim llngHWnd As Long
llngHWnd = FindWindow("TestWinAPI2", vbNullString)
MsgBox(llngHWnd)
End Sub

End Class


Visual Studio 2005 prompted me with error at row of "llngHWnd =
FindWindow("TestWinAPI2", vbNullString)". Error displayed =
NotSupportedException. Please help. Thanks in advance.
 
Change the return type to Integer (or Int32). Native code LONG is a 32bit
integer, in .NET Long is a 64bit integer.

Peter

--
Peter Foot
Microsoft Device Application Development MVP
peterfoot.net | appamundi.com | inthehand.com
APPA Mundi Ltd - Software Solutions for a Mobile World
In The Hand Ltd - .NET Components for Mobility
 
Thanks Peter, it works perfectly now :)

Peter Foot said:
Change the return type to Integer (or Int32). Native code LONG is a 32bit
integer, in .NET Long is a 64bit integer.

Peter

--
Peter Foot
Microsoft Device Application Development MVP
peterfoot.net | appamundi.com | inthehand.com
APPA Mundi Ltd - Software Solutions for a Mobile World
In The Hand Ltd - .NET Components for Mobility
 
Back
Top