Created
November 4, 2013 18:01
-
-
Save davidglezz/7306688 to your computer and use it in GitHub Desktop.
Get executable folder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <windows.h> | |
#include <stdio.h> | |
// Get Current Folder | |
void GetFolder(char *folderName) | |
{ | |
GetModuleFileName(GetModuleHandle(NULL), folderName, MAX_PATH); | |
*(strrchr(folderName, '\\')) = 0; | |
} | |
// Example | |
int main() | |
{ | |
char folderName[MAX_PATH]; | |
GetFolder(folderName); | |
printf("%s\n", folderName); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment