-
-
[求助]求助各位帮忙看看CreateMutex怎么用OD调不了
-
发表于:
2014-1-10 13:32
3627
-
[求助]求助各位帮忙看看CreateMutex怎么用OD调不了
#define _CRT_SECURE_NO_WARNINGS
#include <windows.h>
#include <string>
#include <stdio.h>
#include <Dbt.h>
#include <iostream>
#include "io.h"
#include "tlhelp32.h"
#include "stdio.h"
#include <tchar.h>
#include <conio.h>
#include <fstream>
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;
}
用OD调试的时候,Ctrl+N里有,回车进去断点,,然后F9运行,程序没停下来
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!