随笔分类 - win32
摘要:该函数经常被用来处理UTF-8和ANSI格式的字符串,将它们转换为宽字节(UTF-16) #include <iostream> #include <Windows.h> #include <string> #define MAXBUFFERSIZE 1024 using namespace std
阅读全文
摘要:可以从Windows Sockets 2开始, 虽然微软提供了官方工具, Microsoft Network Monitor 3.4, 不过我们如果能够通过相关的代码和api的调用来深入研究的话,那就大大提升了我们的学习水平。 主要用到socket, bind 和 recvfrom函数。 代码样本:
阅读全文
摘要:目标:创建一个app,使用CreateToolhelp32Snapshot扫描所有的进程,并将进程的pid和exe名字映射到内存中,再在另一个app中使用OpenFileMapping打开该映射读取相关数据 Project 1: #define _CRT_SECURE_NO_WARNINGS #in
阅读全文
摘要:官方示例: CommonFileDialogModes.cpp 如果我们想要自己创建一个通用的文件对话框,则可以使用IFileOpenDialog接口,代码参考: HRESULT BasicFileOpen() { // CoCreate the File Open Dialog object. I
阅读全文
摘要:#include <Windows.h> #include <stdio.h> #pragma warning(disable:4996) void PasswordCheck() { char message_console[MAX_PATH]; char key_accepted[MAX_PAT
阅读全文
摘要:需要先从麦克风中采样,代码样本可以参考官方示例: WASAPI Capture Shared Event Driven 官方示例采样10s, 我们需要在WriteWaveFile函数下添加生成原始音频的代码。 // Write the contents of a WAV file. We take
阅读全文
摘要:如果要将exe的输出重定向到cmd,则可以使用匿名管道将子进程的标准输入和输出句柄重定向。请注意,命名管道也可以用于重定向进程I / O //CMD.exe #include <windows.h> #include <tchar.h> #include <stdio.h> #include <st
阅读全文
摘要:跟创建普通的win32窗口一样,线程中的窗口也需要注册和窗口处理过程 // Test_WM_CLOSE.cpp : Defines the entry point for the application. // #include "framework.h" #include "Test_WM_CLO
阅读全文
摘要:#include <iostream> #include <Windows.h> #include <ShlObj.h> #include <Shlwapi.h> #pragma comment(lib, "Shell32.lib") #pragma comment(lib, "Shlwapi.li
阅读全文
摘要:Suspend: 挂起指定的线程 备注:不要永远挂起线程, 因为在Win32中,进程堆是线程安全的对象,并且由于在不访问堆的情况下很难在Win32中完成很多工作,因此在Win32中挂起线程极有可能使进程死锁。 那么,为什么首先还要有SuspendThread函数呢? 调试器在调试过程中使用它冻结进程
阅读全文
摘要:ListView_GetItemPosition : Gets the position of a list-view item 理论上获得桌面图标的正确方法是使用shell项,=> IFolderView::GetItemPosition 但是为了学习ListView_GetItemPositio
阅读全文
摘要:比如: Google Chrome: 类似于任务管理器中显示名字,见下图 那么我们就需要使用VerQueryValue, 从指定的版本信息资源中检索指定的版本信息。若要检索适当的资源,在调用VerQueryValue之前,必须首先调用GetFileVersionInfoSize函数,然后再调用Get
阅读全文
摘要:两种方法: 第一种是使用WMI进行后台轮询 第二种是查询注册表对应的DNS键值 Here: HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces[\interface-name] 使用RegNotifyChangeKey
阅读全文
摘要:简单的demo: #include <iostream> #include <fstream> #include <windows.h> typedef struct { std::uint32_t biSize; std::int32_t biWidth; std::int32_t biHeigh
阅读全文
摘要:文档:将格式化的数据写入指定的缓冲区。根据格式字符串中相应的格式说明,将转换任何参数并将其复制到输出缓冲区。该函数在其写入的字符后附加一个终止空字符,但返回值的字符计数中不包含终止空字符。 例子: #include <Windows.h> #include <stdio.h> int main()
阅读全文
摘要:在Windows XP,Windows Server 2003和Windows操作系统的早期版本中,所有服务都与登录控制台的第一个用户在同一会话中运行。该会话称为会话0。在会话0中一起运行服务和用户应用程序会带来安全风险,因为服务以提升的特权运行,因此是寻求提高自身特权级别的手段的恶意代理的目标。
阅读全文
摘要:#include <Windows.h> #include <psapi.h> int main() { DWORD process_ID = 0; WCHAR process_name[MAX_PATH] = {}; HWND notepad = FindWindow(NULL, L"print.
阅读全文
摘要:PeekNamedPipe: 将数据从命名管道或匿名管道复制到缓冲区中,而不将其从管道中删除。它还返回有关管道中数据的信息。 示例: #include <iostream> #include <windows.h> #include <vector> using namespace std; int
阅读全文
摘要:Dll: // dllmain.cpp : Defines the entry point for the DLL application. #include "pch.h" #include <sstream> std::wstringstream wss; std::wstring str; c
阅读全文
摘要:#include <windows.h> #include <shobjidl_core.h> #include <windowsx.h> #include <shlobj_core.h> #pragma comment(lib,"Shell32.lib") #define MAX_LOADSTRI
阅读全文