Is there any way to get the process name of a process, with Windows API, or otherwise?
ProcessName()?
BlitzPlus Forums/BlitzPlus Programming/ProcessName()? Yes... but I have no idea how you would do this in Blitz.
You obviously need the process ID of the process you want to get the name of, so call GetCurrentProcessID(). It doesn't take any parameters.
This code is from my network packet sniffer, and is part of my port to process mapper routine. I can't vouch for it working on Windows 9x, but it should work on Win2K and above.
Neil
BOOL ProcessPathByPID(ULONG pid,char* moduleName,DWORD moduleNameLength) { HANDLE hProcess; HMODULE module; BOOL result; DWORD cbNeeded,nameLength; result=FALSE; hProcess=OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_VM_READ,FALSE,pid); if(hProcess){ result=EnumProcessModules(hProcess,&module,sizeof(HMODULE),&cbNeeded); if(result){ nameLength=GetModuleFileNameEx(hProcess,module,moduleName,moduleNameLength); if(nameLength==0) sprintf(moduleName,"System"); else GetFileNameFromPath(moduleName); }else{ sprintf(moduleName,"System"); } CloseHandle(hProcess); } return result; }
You obviously need the process ID of the process you want to get the name of, so call GetCurrentProcessID(). It doesn't take any parameters.
This code is from my network packet sniffer, and is part of my port to process mapper routine. I can't vouch for it working on Windows 9x, but it should work on Win2K and above.
Neil
why not simply make a userlib out of that code for him?