
系统/线程/调试
文章平均质量分 60
zgl7903
iPad回帖太累人
展开
-
基于状态机的 CSV 文件数据解析
#include <tchar.h>#include <afxtempl.h>#include <stdio.h>#include <string.h>#ifndef CStringA#define CStringA CString#endif //CStringA//解析CSV行数据核心代码//chLine 输入行//szDa...原创 2019-12-27 16:32:26 · 546 阅读 · 3 评论 -
通过WMI 获取 CPU 温度
MSAcpi_ThermalZoneTemperature原创 2016-08-04 21:52:30 · 9397 阅读 · 3 评论 -
在任务栏上的时钟区域显示自己的内容
以 TrayClockWClass 为父窗口测试, 诸多不完美, 单调, 可能有闪烁, 仅作为基础测试使用 // ShellClock.cpp : Defines the entry point for the application.//#include "stdafx.h"#include "resource.h"#include #if _MSC_VER <原创 2016-07-15 07:33:32 · 1176 阅读 · 0 评论 -
使用 ShellExecuteEx 显示文件属性
ShellExecuteEX MSDN SHELLEXECUTEINFO sei; ZeroMemory(&sei,sizeof(sei)); sei.cbSize = sizeof(sei); sei.lpFile = _T("C:\\"); //or path sei.lpVerb = "properties"; sei.fMask = SEE_MASK原创 2016-07-12 08:44:13 · 1132 阅读 · 1 评论 -
SNTP 获取时间服务器UTC时间
// SntpTest.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include #include #include #pragma comment(lib, "wsock32.lib")//ref : www.ietf.org/rfc/rfc2030.txt原创 2015-05-25 15:05:47 · 3936 阅读 · 1 评论 -
CreateRemoteThread 牛刀小试
// RmtTest.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include <windows.h>#include <shlwapi.h>#pragma comment(lib, "shlwapi.lib")#pragma comment(lib, "Advapi32.lib")BOOL Set...原创 2015-06-08 07:15:10 · 2234 阅读 · 0 评论 -
我的调试输出 _TRACE 第三版
在第二版的基础上增加了非法检查功能 另外使用_WINDOWS宏来区分控制台和Windows程序#include #include #include class __CTrace{#ifdef _WINDOWS #define dbgOutputA(str) OutputDebugStringA(str) #define dbgOutputW(str) Ou原创 2015-06-05 05:36:02 · 837 阅读 · 0 评论 -
我的调试输出_TRACE 第二版
#ifdef _DEBUG class __CTrace { CString szFileAndLine; public: __CTrace(LPCTSTR szFile, int nLien) { szFileAndLine.Format(_T("%s(%d): "), szFile, nLien); }原创 2010-11-12 12:57:00 · 1096 阅读 · 0 评论 -
Enumerating All Device Drivers in the System
#include #pragma comment(lib, "psapi.lib")void EnumAllDeviceDrivers(){ do { LPVOID aDrivers[1024]; memset(aDrivers, 0, sizeof(aDrivers)); DWORD cbNeeded = 0; if ( !EnumDeviceDr原创 2014-05-16 10:14:40 · 769 阅读 · 0 评论 -
简易剪贴板查看器
//引用MSDN上的注释 The SetClipboardViewer function adds the specified window to the chain of clipboard viewers. Clipboard viewer windows receive a WM_DRAWCLIPBOARD message whenever the content of th原创 2013-12-26 11:45:05 · 2162 阅读 · 0 评论 -
枚举剪切板数据和格式名称
if(OpenClipboard()) //open clipboard { UINT uFormat = 0; while(uFormat = EnumClipboardFormats(uFormat)) //emulate format { HGLOBAL hGlobal = GetClipboardData(uFormat); //ge原创 2013-08-30 15:42:58 · 1398 阅读 · 0 评论 -
使用文件映射获取打开的文件名
#include "stdafx.h"#include #include #include #include #include #include #include #pragma comment(lib, "psapi.lib")LPCTSTR GetFileNameFromHandle(HANDLE hFile) { static TCHAR pszFilename原创 2013-08-14 10:39:52 · 1138 阅读 · 0 评论 -
使用LCMapString完成繁体中文到简体中文的相互转换
TCHAR szOutBuffer[128+1] = {0}; WORD wLanguageID = MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED); LCID Locale = MAKELCID(wLanguageID, SORT_CHINESE_PRCP); int iRet = LCMapString(Locale,原创 2012-07-19 11:22:50 · 9055 阅读 · 4 评论 -
实现 GetTickCount64
GetTickCount64API 要求在Vista/2008以上系统使用一下方法使用API 高精度计数器 和 GetTickCount 等多种方式实现GetTickCount64的功能struct _tagGlobalTickCount_t{ //API ULONGLONG WINAPI GetTickCount64(void); typedef ULONGLONG (WI原创 2013-08-13 09:59:00 · 8663 阅读 · 1 评论 -
用于自定义数组/结构体数组的剪切板应用模板类
//用于自定义数组/结构体数组的剪切板应用类template class COwnerArrayDataClipboard { //用于剪切板数据结构体 typedef struct tagMYSTRUCTARRAY_t { int iCount; //记录数据个数 MYDATA data[1]; //数据 }MYSTRUCTARRAY, *LPMYSTRU原创 2013-08-09 11:07:06 · 1286 阅读 · 0 评论 -
在任务栏上的时钟区域显示自己的内容 MFC 封装
//ClockTrayWnd.h#pragma onceclass CColockTrayWnd : public CWnd{ CWnd *m_pNotifyWnd; //通知窗口 UINT m_uNotifyMessage; //通知消息public: CColockTrayWnd() { m_pNotifyWnd = NULL; m_uNotify原创 2016-07-15 22:18:50 · 853 阅读 · 0 评论 -
FormatMessage 格式化 GetLastError 错误代码
LPCSTR _FormatErrorMessage( LPCTSTR szReason, DWORD dwErrCode ){ static TCHAR szErrMsg[1024]; memset(szErrMsg, 0, sizeof(szErrMsg)); //DWORD dwErrCode = GetLastError(); //之前的错误代码 LPVOID lpM原创 2016-07-17 13:02:49 · 1120 阅读 · 0 评论 -
RegNotifyChangeKeyValue 监控注册表变化
///////////////////////////////////////////////////////////////////////RegMonitorClass.h#pragma onceclass CRegMonitorClass{public: //标准构析函数 CRegMonitorClass(); ~CRegMonitorClass();prote...原创 2019-08-22 11:32:20 · 1817 阅读 · 0 评论 -
Windows API Monitor
文章转自http://www.rohitab.com/apimonitorAPI MonitorAPI Monitor v2 is currently in Alpha. Installers for both 32-bit and 64-bit versions are now available.Download Now.Save Capture and Moni...转载 2019-08-22 09:25:43 · 1769 阅读 · 0 评论 -
在内存创建对话框资源
//////////////////////////////////////////////////////////////////////////BaseDynDialog.h#pragma onceclass CBaseDynDialog : public CDialog{ DECLARE_DYNAMIC(CBaseDynDialog) public: ...原创 2019-05-30 18:26:04 · 508 阅读 · 0 评论 -
查表法计算CRC32
#include <stdio.h>#include <stdlib.h>#include <string.h> typedef unsigned long u_int32_t;typedef unsigned char u_char; static const u_int32_t crc32tab[256] = { 0x00000000UL...原创 2018-04-15 10:20:07 · 3935 阅读 · 0 评论 -
PSAPI 获取应用PID
#include "psapi.h"#pragma comment(lib, "psapi.lib")// Get the process name. INT GetProcessBaseName(DWORD processID, LPTSTR szProcessName, int iBuffLen){ INT iRet = 0; ZeroMemory(szProce...原创 2018-02-12 12:57:29 · 884 阅读 · 0 评论 -
解析和创建快捷方式
#include #include BOOL ResolveShortCut(LPCSTR pszShortcutFile, CHAR pszPath[MAX_PATH+1], CHAR szDescription[MAX_PATH+1]){ BOOL bRet = FALSE; *pszPath = 0; // assume原创 2017-12-15 21:28:19 · 384 阅读 · 0 评论 -
热键管理
#include class CWndHotKeyManage{protected: typedef struct _tagWKItem_t { HWND hWnd; // window to receive hot-key notification int id; // identifier of hot key UI原创 2017-12-15 21:23:05 · 439 阅读 · 0 评论 -
使用 SetDeviceGammaRamp 调整屏幕亮度
使用 SetDeviceGammaRamp 调整屏幕亮度原创 2017-08-01 10:13:57 · 4117 阅读 · 0 评论 -
使用 #pragma message 输出自定义警告信息
可以在编译窗口中输出自定义警告信息, 并且可以双击信息行 定位到文件位置//宏定义#define __STR2__(x) #x#define __STR1__(x) __STR2__(x)#define __LOC__ __FILE__ "("__STR1__(__LINE__)")"#define _warning(iCode, msgStr) message( __LOC_原创 2017-06-15 08:54:50 · 4362 阅读 · 0 评论 -
使用CreateFile API 枚举串口
使用CreateFile API 枚举串口原创 2017-07-10 16:39:44 · 910 阅读 · 0 评论 -
SetupDI 枚举串口
//具有完整的设备名 #include #include #include #pragma comment(lib, "Setupapi.lib")void main(){ HDEVINFO hDevInfo = SetupDiGetClassDevs(&GUID_DEVCLASS_PORTS, NULL, NULL, 0); if(hDevInfo) {原创 2016-12-15 14:50:43 · 1271 阅读 · 1 评论 -
线程监视 OutputDebugString 的调试输出
#include class CDBWinMonitor {#pragma pack(push, 1) typedef struct _tagDBWinBuffer_t { DWORD dwProcessId; char data[4096-sizeof(DWORD)]; }DBWINBUFFER, *LPDBWINBUFFER;#pragma p原创 2016-08-06 17:03:00 · 1812 阅读 · 1 评论 -
键盘键码代码
KeyKey code (Hex)Key modifierLEFTMOUSE100NoneF113BNoneF213CNoneF313DNoneF413EN原创 2013-06-03 09:54:32 · 1666 阅读 · 0 评论 -
CreateEvent 自动/手动重置的测试
{ HANDLE hEvent = CreateEvent(NULL, FALSE, //automatically resets TRUE, //flag for initial state NULL); WaitForSingleObject(hEvent, -1); //此处正常退出,因为前面的初始值是TRUE S原创 2013-03-26 15:25:47 · 1965 阅读 · 0 评论 -
在剪切板中使用自定义格式的数据
void TestManualFormatClipboard(){ //自定义数据结构体 typedef struct _MYSTRUCT { CHAR charVal[16]; int iVal; long lVal; double fVal; }MYSTRUCT, *LPMYSTRUCT; MYSTRUCT wrSt原创 2013-04-08 12:50:42 · 4043 阅读 · 0 评论 -
内存使用情况查看类
内存使用情况查看类class CMemoryUserge{protected: typedef struct _MEMORYSTATUS_EX { DWORD dwLength; // sizeof(MEMORYSTATUSVLM) DWORD dwMemoryLoad; // percent of memory in原创 2011-07-07 17:31:51 · 820 阅读 · 0 评论 -
测试运行时间
LARGE_INTEGER start_PerformanceCount;QueryPerformanceCounter(&start_PerformanceCount); //起始计数器//运行测试的代码Sleep(1);LARGE_INTEGER end_PerformanceCount;QueryPerformanceCounter(&end_Performa原创 2008-05-28 21:22:00 · 1163 阅读 · 0 评论 -
获取和修改显示器设置的分辨率和刷新速度
//获取更改显示器分辩率刷新速度//将显示器分辨率修改为800*600 16位色 60Hz 5秒钟后恢复{ //保存信息 DEVMODE Save_DevMode = {0}; Save_DevMode.dmSize = sizeof(DEVMODE); EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS,&Save_DevMode原创 2008-07-30 19:16:00 · 1750 阅读 · 1 评论 -
检查当前用户是否具有管理员权限
//最后修改日期 2009-10-26#include #pragma comment (lib,"Netapi32.lib") bool Is_Admin_Privilege(){ bool privilege = true; OSVERSIONINFO OSV = {sizeof(OSVERSIONINFO),0}; if(GetVersionEx(&OSV原创 2008-07-30 19:33:00 · 3930 阅读 · 3 评论 -
快照方式枚举 ProcessID
//获取ProcessID#include "stdafx.h"#include #include #include #include using namespace std; int main() { HANDLE hsnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0)原创 2008-07-30 19:56:00 · 585 阅读 · 0 评论 -
使用SetSysColors 修改系统颜色
void SetDestTopColor(){ // window elements to change int aiElements[] = { COLOR_BACKGROUND, COLOR_DESKTOP, COLOR_ACTIVEBORDER, COLOR_ACTIVECAPTION, COLOR_WINDO原创 2010-01-18 20:34:00 · 4017 阅读 · 1 评论 -
不阻塞消息队循环的Sleep延时
void _Sleep_(UINT Delay_ms){ DWORD dwTick = GetTickCount() + Delay_ms; while(GetTickCount() { MSG msg; if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if (msg.message原创 2010-03-15 19:29:00 · 2070 阅读 · 2 评论 -
Taskbar Creation Notification
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam){static UINT s_uTaskbarRestart;switch(uMessage) { case WM_CREATE: s_uTaskbarRestart = Registe翻译 2010-03-18 21:25:00 · 750 阅读 · 0 评论