I have some problems using 'GetWindowThreadProcessId()'. I call this function from C#. If I use it to determine a ThreadID of a foreign process (for example windows calculator) it works fine. But if I use it to get a ThreadID of a selfwriten C#-Application it always returns 0.
Why it the return value always 0?
Code:
Code:
try { Process p = GlobalMethods.startProcessFromFile(this._testumgebung.TestObjektFileName);
uint dummy; uint targetThreadID = ImportedMethods.GetWindowThreadProcessId(p.MainWindowHandle, out dummy);
hmm most Windows API Functions return 0 when there is an Error. Although the MSDN says nothing about it maybe a call to GetLastError will help to determine what specific Error occurs.