windows下獲取exe目錄和當前cmd的目錄

#include <windows.h>
#include <stdio.h>
char g_exe_path[MAX_PATH];
char g_cmd_path[MAX_PATH];

void echo(char * p_text )
{
printf("%s\r\n",p_text);
}

int main()
{
memset( g_exe_path, 0, MAX_PATH*sizeof(char));
memset( g_cmd_path, 0, MAX_PATH*sizeof(char));
GetModuleFileName( NULL, g_exe_path, MAX_PATH );
echo(g_exe_path);
GetCurrentDirectory( MAX_PATH, g_cmd_path );
echo(g_cmd_path);
return TRUE;
}
相關文章
相關標籤/搜索