先上源代码
DIPSLib.DLL编译篇
这个是公共头文件CmnHdr.h
#pragma once
//#define _WIN32_WINNT _WIN32_WINNT_LONGHORN
//#define WINVER _WIN32_WINNT_LONGHORN
#ifndef UNICODE
#define UNICODE
#endif // UNICODE
#ifdef UNICODE
#ifndef _UNICODE
#define _UNICODE
#endif // !_UNICODE
#endif // UNICODE
#pragma warning(push,3)
#include<Windows.h>
#pragma warning(pop)
#pragma warning(push,4)
#include<CommCtrl.h>
#include<process.h>
#ifndef FILE_SKIP_COMPLETION_PORT_ON_SUCESS
#pragma message("You are not using the latest Platform SDK header /library")
#pragma message("files. This may prevent the project form building correctly.")
#endif // !FILE_SKIP_COMPLETION_PORT_ON_SUCESS
#define chSTR2(x) #x
#define chSTR(x) chSTR2(x)
#define chMSG(desc) message(__FILE__ "(" chSTR(__LINE__) "):" #desc)
inline void chMB(PCSTR szMsg)
{
char szTitle[MAX_PATH];
GetModuleFileNameA(NULL, szTitle, _countof(szTitle));
MessageBoxA(GetActiveWindow(), szMsg, szTitle, MB_OK);
}
inline void chFAIL(PSTR szMsg)
{
chMB(szMsg);
DebugBreak();
}
inline void chASSERTFAIL(LPCSTR file, int line, PCSTR expr)
{
char sz[2 * MAX_PATH];
wsprintfA(sz, "File %s , Linr %d : %s", file, line, expr);
chFAIL(sz);
}
#ifdef _DEBUG
#define chASSERT(x) if(!(x)) chASSERTFAIL(__FILE__,__LINE__,#x)
#else
#define chASSERT(x)
#endif // _DEBUG
#ifdef _DEBUG
#define chVERIFY(x) chASSERT(x)
#else
#define chVERIFY(x) (x)
#endif // _DEBUG
inline void chSETDLGICONS(HWND hWnd, int idi)
{
SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM)
LoadIcon((HINSTANCE)GetWindowLongPtr(hWnd, GWLP_HINSTANCE),
MAKEINTRESOURCE(idi)));
SendMessage(hWnd, WM_SETICON, ICON_SMALL, (LPARAM)
LoadIcon((HINSTANCE)GetWindowLongPtr(hWnd, GWLP_HINSTANCE),
MAKEINTRESOURCE(idi)));
}
#define chHANDLE_DLGMSG(hWnd,message,fn) \
case(message): return (SetDlgMsgResult(hWnd,message,HANDLE_##message((hWnd),(wParam),(lParam),(fn))))
创建个dialog资源用mfc 改名字Wintellect DIPS 改id IDD_DIPS
下面附上DIPSLib代码 .H文件
#pragma once
#if !defined(DIPSLIBAPI)
#define DIPSLIBAPI __declspec(dllimport)
#endif
DIPSLIBAPI BOOL __stdcall SetDIPSHook(DWORD dwThreadId);
.cpp文件
#include"CmnHdr.h"