GetCurrentDirectory
GetModuleFileName
main函数参数 argv[0]
// crt_getcwd.c // This program places the name of the current directory in the // buffer array, then displays the name of the current directory // on the screen. Passing NULL as the buffer forces getcwd to allocate // memory for the path, which allows the code to support file paths // longer than _MAX_PATH, which are supported by NTFS. #include <direct.h> #include <stdlib.h> #include <stdio.h> int main( void ) { char* buffer; // Get the current working directory: if( (buffer = _getcwd( NULL, 0 )) == NULL ) perror( "_getcwd error" ); else { printf( "%s Length: %d ", buffer, strnlen(buffer) ); free(buffer); } }