Page 1 of 1

[WinAPI] Cum determin numele sub care ruleaza aplicatia?

Posted: 31 Jul 2007, 16:19
by Marius Bancila
Intrebare: Cum determin numele sub care ruleaza aplicatia?

Raspuns: Folosing functia GetModuleFileName.

Cu std::string

Code: Select all

TCHAR szpath[MAX_PATH+1] = {0};
::GetModuleFileName(NULL, szpath, MAX_PATH);

std::string nume = szpath;
nume = nume.substr(nume.rfind("\\") + 1);
Cu CString

Code: Select all

TCHAR szpath[MAX_PATH+1] = {0};
::GetModuleFileName(NULL, szpath, MAX_PATH);

CString nume = szpath;
nume = nume.Right(nume.ReverseFind('\\') + 1);

<< Back to Windows API Index