Hi, im using the following method
[DllImport("kernel32.dll", SetLastError=true)] static extern int GetProcessId(IntPtr hWnd);
to try and get the processId for a running process and the only information I have is the HWND. My problem is that it is always returning error code 6 which is ERROR_INVALID_HANDLE. I thought i might change the parameter to be of type int but that also didnt work. Im not able to enumerate the running processes because there may be more than 1 instance running at any one time.
Can anyone see if i am doing anything wrong?
NB: The process is spawned from an automation object exposed to the framework and only provides the HWND property. Perhaps there is another way to get the processID seeing as the code i wrote was responsible for running it in the first place?
My code looks something similar to this...
AutomationApplication.Application extApp = new AutomationApplication.Application(); extApp.Run(); ...