1.希望这个exe通过Command Line运行时,可以识别参数、且不显示图形界面
2.如果双击exe,则显示图形界面。
用VS,C++实现,谢谢
// Q1054744.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "windows.h"
#include "resource.h"
int shouldrun;
INT_PTR CALLBACK DlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
UNREFERENCED_PARAMETER(lParam);
switch (message)
{
case WM_INITDIALOG:
return (INT_PTR)TRUE;
case WM_COMMAND:
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg, LOWORD(wParam));
shouldrun = 0;
return (INT_PTR)TRUE;
}
break;
}
return (INT_PTR)FALSE;
}
int main(int argc, _TCHAR* argv[])
{
shouldrun = 1;
HINSTANCE hInst= GetModuleHandle (0);
if (argc == 1)
{
DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG1), NULL, DlgProc);
while (shouldrun)
{
Sleep(100);
}
}
else
{
printf("Hello world");
}
return 0;
}