Converting a IntPtr to HWND ?
-
Ok, on previous posts you may have noticed that I have been playing around with processes and the like. I have created a Console application that fires up NOTEPAD and access the menus but I need to ensure that it remains as the
ForegroundWindow
. To do this I need to acquire the Handle of the process that I started then apply it to theForegroundWindow
property - this is where I am having trouble. The following is how I start NOTEPAD then return it'sMainWindowHandle
which is aIntPtr
:IntPtr Hnd; Process^ Proc = gcnew Process; Proc->StartInfo->FileName = "NOTEPAD.EXE"; Proc->Start(); Proc->WaitForInputIdle(); Hnd = Proc->MainWindowHandle;
Now when I include the following line:SetForegroundWindow(Hnd);
I get the following error when compiling:error C2664: 'SetForegroundWindow' : cannot convert parameter 1 from 'System::IntPtr' to 'HWND'
Can I conver aIntPtr
to aHWND
? Pete -
Ok, on previous posts you may have noticed that I have been playing around with processes and the like. I have created a Console application that fires up NOTEPAD and access the menus but I need to ensure that it remains as the
ForegroundWindow
. To do this I need to acquire the Handle of the process that I started then apply it to theForegroundWindow
property - this is where I am having trouble. The following is how I start NOTEPAD then return it'sMainWindowHandle
which is aIntPtr
:IntPtr Hnd; Process^ Proc = gcnew Process; Proc->StartInfo->FileName = "NOTEPAD.EXE"; Proc->Start(); Proc->WaitForInputIdle(); Hnd = Proc->MainWindowHandle;
Now when I include the following line:SetForegroundWindow(Hnd);
I get the following error when compiling:error C2664: 'SetForegroundWindow' : cannot convert parameter 1 from 'System::IntPtr' to 'HWND'
Can I conver aIntPtr
to aHWND
? Pete -
G'Day Pete Give this a go ::SetForegroundWindow((HWND)(Hnd.ToPointer()));
System.IO.Path.IsPathRooted() does not behave as I would expect
G'Day Josh, Yep.... look'n good. Thanks again and have a great Xmas. Pete