- 注册时间
- 2021-4-16
- 最后登录
- 2023-11-9
- 在线时间
- 4 小时
编程入门
- 龙马币
- 108
|
分享一种常见的CPU优化C++源码
- BOOL __stdcall NewPeekMessage(
- _Out_ LPMSG lpMsg,
- _In_opt_ HWND hWnd,
- _In_ UINT wMsgFilterMin,
- _In_ UINT wMsgFilterMax,
- _In_ UINT wRemoveMsg)
- {
- BOOL ulRet = FALSE;
- ULONG ulStatus = 0;
- ULONG ulFightStatus = 0;
- char lpszText[100];
- char lpszGameText[100];
- PeekMessage_1 OldPeekMessage;
- OldPeekMessage = (PeekMessage_1)PeekMessageHookZone;
- ulRet = OldPeekMessage(lpMsg,hWnd,wMsgFilterMin,wMsgFilterMax,wRemoveMsg);
- //输入输出的不优化
- //鼠标消息也不优化,不然很卡
- if (lpMsg->message == WM_INPUT ||
- lpMsg->message == WM_MOUSEMOVE ||
- lpMsg->message == WM_LBUTTONDOWN ||
- lpMsg->message == WM_LBUTTONUP ||
- lpMsg->message == WM_LBUTTONDBLCLK ||
- lpMsg->message == WM_RBUTTONDOWN ||
- lpMsg->message == WM_RBUTTONUP ||
- lpMsg->message == WM_RBUTTONDBLCLK ||
- lpMsg->message == WM_MBUTTONDOWN ||
- lpMsg->message == WM_MBUTTONUP ||
- lpMsg->message == WM_MBUTTONDBLCLK)
- {
- return ulRet;
- }
- //极小模式
- if (bFixCPU == 0)
- {
- return ulRet;
- }
- //一般模式
- if (bFixCPU == 1)
- {
- SleepEx(5,FALSE);
- return ulRet;
- }
- //中级模式
- if (bFixCPU == 2)
- {
- SleepEx(10,FALSE);
- return ulRet;
- }
- //下面就是超级模式了
- SleepEx(10,FALSE);
- if (lpMsg->message != WM_TIMER)
- {
- SleepEx(50,FALSE);
- }
- return ulRet;
- }
复制代码
|
|