NO

Author Topic: filename extracting  (Read 2619 times)

Claudy

  • Guest
filename extracting
« on: December 26, 2007, 02:10:36 PM »
hi,

How can I get the filename of an exe file, from within that executable, while it is running, with the condition that the filename must be extracted BEFORE any window is created?

In other words: I run 'MyApp.exe', in that app before creating any window, I wish to get the filename "MyApp" in a string, extracted from 'MyApp.exe'.
Is this possible?

Claude Put     Belgium

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
Re: filename extracting
« Reply #1 on: December 26, 2007, 03:14:27 PM »
Use GetModuleFileName()
You get programname with path

Code: [Select]
int nIdx, nLen;
char szExe[260], szTitle[80];

GetModuleFileName(0, szExe, sizeof(szExe));
strcpy(szTitle, strrchr(szExe, '\\')+1);
nLen = strlen(szTitle);
if (nLen > 4) szTitle[nLen-4] = 0;

May the source be with you

Claudy

  • Guest
Re: filename extracting
« Reply #2 on: December 31, 2007, 09:47:34 PM »
Thank you timovjl, just what I needed...

Put Claude   Belgium