MFC弹出console界面
char path[MAX_PATH];
GetModuleFileName(NULL, path, MAX_PATH);
for (size_t p = strlen(path)-1; p>=0; p--)
{
if (path[p] != '\\')
path[p] = '\0';
else
break;
}
strcat(path, "nodebug");
printf("current directory: %s\n", path);
FILE *fp_debug = fopen(path, "rb");
if (fp_debug == NULL)
{
AllocConsole();
freopen( "CONOUT$", "w", stdout );
freopen( "CONOUT$", "w", stderr );
freopen( "CONIN$", "r", stdin );
}
else
fclose(fp_debug);
代码之中加入代码,当前目录中含有nodebug文件时候,不会弹出黑色窗口。