URGENT-Problems with FindWindow API function
Posted on 2006-05-17
In my code I need to retrieve the handle to an explorer window if it's running. The Window name is "C:\Test"
I used FindWindow and it worked great. Here is my code:
Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
ptrRet = FindWindow(vbNullString, "C:\Test")
If ptrRet.ToInt32 > 0 Then
MsgBox("Window not found")
If ptrRet.ToInt32 = 0 Then
Dim temp As Int32 = Marshal.GetLastWin32Error()
Dim errMsg As String = New Win32Exception(Marshal.GetLastWin32Error()).Message
MsgBox("ERROR: " & temp & " - " & errMsg)
I ran this program on Windows XP and it was fine, but when I tried running it on Windows XP Embedded, FindWindow started returning 0
and the error I retrive is Error 5 - Access Denied
I was wondering if there is an equivalent of FindWindow that I could use instead?