Monday, December 1, 2008

Get 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: