window核心编程 22.3 DIPS.exe的踩坑逻辑梳理

先上源代码

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"
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值