[WinAPI] Cum determin numele sub care ruleaza aplicatia?

Folosire Windows API in programe C/C++ (forum moderat)
Post Reply
User avatar
Marius Bancila
Fondator
Fondator
Posts: 2344
Joined: 11 Jul 2007, 11:45
Judet: Timiş
Location: Timisoara
Contact:

[WinAPI] Cum determin numele sub care ruleaza aplicatia?

Post by Marius Bancila » 31 Jul 2007, 16:19

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


Marius Bancila
Fondator Codexpert, Microsoft MVP VC++
Site personal | Blog

Post Reply