Monday, September 22, 2008

Retrieve the Application Directory

// With standard string

char szAppPath[MAX_PATH] = "";

char szAppDirectory[MAX_PATH] = "";

::GetModuleFileName(0, szAppPath, sizeof(szAppPath) - 1);

// Extract directory

strncpy(szAppDirectory, szAppPath, strrchr(szAppPath, '\\') - szAppPath);

szAppDirectory[strlen(szAppDirectory)] = '\0';

No comments: