GRussell31
New member
- Joined
- Jan 14, 2009
- Messages
- 2
- Programming Experience
- 10+
Hi,
I've written an application in Vb.Net 2005 which uses the GetProcessesByName function to find all instances of an application which I then want to hide from the user.
I'm using the MainHandleWindow function to return the window handle from each process which I am then passing to the ShowWindow API to hide the window.
This all works fine, and I can happily hide the windows. The problem comes when I try to show the window again! When I call the ShowWindow API with the same window handle that I used to hide nothing happens (the window doesn't appear) and the method call returns 0.
My Code (edited to display here)...
My API Declaration:
I'm using windows Vista and trying to hide any Internet Explorer windows.
I just find it strange that it can hide the window but not show it again afterwards.
Can anyone offer any advice?
Thanks,
-Graham
I've written an application in Vb.Net 2005 which uses the GetProcessesByName function to find all instances of an application which I then want to hide from the user.
I'm using the MainHandleWindow function to return the window handle from each process which I am then passing to the ShowWindow API to hide the window.
This all works fine, and I can happily hide the windows. The problem comes when I try to show the window again! When I call the ShowWindow API with the same window handle that I used to hide nothing happens (the window doesn't appear) and the method call returns 0.
My Code (edited to display here)...
VB.NET:
Dim SW_HIDE As Integer = 0
Dim SW_SHOW As Integer= 5
Dim proc As Process() = Process.GetProcessesByName("iexplore")
Dim iRet, a asInteger
iRet = CType(proc(0).MainWindowHandle, Integer)
' This hides the window
a = ShowWindow(iRet, SW_HIDE)
' This does not make it appear
a = ShowWindow(iRet, SW_SHOW)
My API Declaration:
VB.NET:
<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Private Shared Function ShowWindow(ByVal hWnd As Long, ByVal nCmdShow As Int32) As Boolean
End Function
I'm using windows Vista and trying to hide any Internet Explorer windows.
I just find it strange that it can hide the window but not show it again afterwards.
Can anyone offer any advice?
Thanks,
-Graham