Thanks rcari and MulderR. The LoadLibrary / GetProcAddress approach works well. Using QLibrary the working code looks like
[code]
// get process handle
DWORD pidwin;
GetWindowThreadProcessId(foregroundWindow, &pidwin);
HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pidwin);
// get process path
WCHAR szProcessPath[MAX_PATH];
DWORD bufSize = MAX_PATH;
QueryFullProcessImageName pQueryFullProcessImageName = NULL;
pQueryFullProcessImageName = (QueryFullProcessImageName) QLibrary::resolve("kernel32", "QueryFullProcessImageNameW");
QString processPath;
if(pQueryFullProcessImageName != NULL) {
pQueryFullProcessImageName(hProcess, 0, (LPWSTR) &szProcessPath, &bufSize);
processPath = QString::fromUtf16((ushort*)szProcessPath, bufSize);
}
[/code]
More information on which function to use for the different windows versions - http://msdn.microsoft.com/en-us/library/windows/desktop/ms684919(v=vs.85).aspx