using namespace std;
HANDLE hOneInstanceMutex;
LRESULT CALLBACK WndProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{
hOneInstanceMutex = NULL;
hOneInstanceMutex = ::CreateMutex(NULL, FALSE, _T(
"113fd4dce30d7d8e2d1c4f2211cd164e1"
));
if
(GetLastError() == ERROR_ALREADY_EXISTS)
{
hOneInstanceMutex = NULL;
MessageBox(NULL,TEXT(
"已存在113fd4dce30d7d8e2d1c4f2211cd164e1的互斥体"
),TEXT(
"提示"
),0);
return
0;
}
else
{
MessageBox(NULL,TEXT(
"启动成功"
),TEXT(
"提示"
),0);
}
WNDCLASS wndclass;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
wndclass.hCursor=LoadCursor(NULL,IDC_ICON);
wndclass.hIcon=LoadIcon(NULL,IDI_ASTERISK);
wndclass.hInstance=hInstance;
wndclass.lpfnWndProc=WndProc;
wndclass.lpszClassName=
"U"
;
wndclass.lpszMenuName=NULL;
wndclass.style=CS_VREDRAW|CS_HREDRAW;
RegisterClass(&wndclass);
HWND hwnd;
hwnd=CreateWindow(
"U"
,
""
,WS_OVERLAPPEDWINDOW,150,150,683,384,NULL,NULL,hInstance,NULL);
ShowWindow(hwnd,SW_HIDE);
UpdateWindow(hwnd);
MSG msg;
while
(GetMessage(&msg,hwnd,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return
0;
}
LRESULT CALLBACK WndProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
switch(uMsg)
{
case
WM_PAINT:
{
PAINTSTRUCT
ps
;
BeginPaint(hwnd,&
ps
);
EndPaint(hwnd,&
ps
);
break
;
}
case
WM_CLOSE:
{
return
FALSE;
break
;
}
case
WM_DESTROY:
{
return
FALSE;
break
;
}
default:
{
return
DefWindowProc(hwnd,uMsg,wParam,lParam);
break
;
}
}
return
0;
}