<p>I've accidentally removed Win2K compatibility from an application by using <a href="http://msdn.microsoft.com/en-us/library/ms683215(VS.85).aspx" rel="nofollow noreferrer">GetProcessID</a>.</p>

<p>I use it like this, to get the main HWND for the launched application.</p>

<pre><code>ShellExecuteEx(&amp;info); // Launch application
HANDLE han = info.hProcess; // Get process

cbinfo.han = han;

//Call EnumWindows to enumerate windows....
//with this as the callback

static BOOL CALLBACK enumproc(HWND hwnd, LPARAM lParam)
{
  DWORD id;
  GetWIndowThreadProcessID(hwnd, &amp;id);
  if (id == GetProcessID(cbinfo.han))
    setResult(hwnd)
 ...
}
</code></pre>

<p>Any ideas how the same function could be acheived on Win2K?</p>

There is an 'sort-of-unsupported' function: ZwQueryInformationProcess(): see
http://msdn.microsoft.com/en-us/library/ms687420.aspx
This will give you the process id (amongst other things), given the handle. This isn't guaranteed to work with future Windows versions, so I'd suggest having a helper function that tests the OS version and then uses GetProcAddress() to call either GetProcessId() for XP and above, and ZwQueryInformationProcess() for Win2K only.