My name is Ali. I am writing a dll with Visual C++ (it 's not an MFC' dll). I want to recognize which process is using the dll. With _getpid () I could get the process id. And now, how can I get the name of the process?!
The API function GetStartupInfo retrieves data about the curent process in a LPSTARTUPINFO structure. One of its member lpTitle is the main window caption/process name.
VOID GetStartupInfo(
LPSTARTUPINFO lpStartupInfo // startup information
);
Hope this helps, s-)
Blessed is he who in the name of justice and good will, shepards the week through the valley of darknees...
There are no easy ways to do it, if You need name of another Process (with ID != GetCurrentProcessId()). You must enum all Processes in System and compare founded IDs with Your ID. For that You need:
1) Windows 95/98/2000 - use CreateToolhelp32Snapshot() and another Functions of this Group (search help of Visual Studio for source sample).
2)Windows NT- use Functions of PSAPI.DLL (EnumProcesses() and it's callback - You can find source in search.microsoft.com).
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.