How do I get the process name from a dll

Hi,
  I want can get the name of parent process that is calling the dll in that dll?

Thanks
thevamAsked:
Who is Participating?
 
jkrConnect With a Mentor Commented:
Assuming that it's windows, the soultion would be

char acProcessImage [ MAX_PATH];

GetModuleFileName ( NULL, acProcessImage, MAX_PATH);

NOTE that this API returns the full path of the executable. To get the process' name, you'll have to truncate the path, e.g.

char* pc;
char* pszName = NULL;
char acProcessImage [ MAX_PATH];

GetModuleFileName ( NULL, acProcessImage, MAX_PATH);

if ( pc = strrchr ( acProcessImage, '\\'))
{
  *pc = ( char) 0;
  pc++;

  pszName = pc;
}
else pszName = acProcessImage;

Feel free to ask if you need more information!
0
 
ShevCommented:
Do you want it under Windows?
0
All Courses

From novice to tech pro — start learning today.