旧的新win32api
此页面提供了指向Raymond Chen著名博客《旧事物》帖子子集的链接列表。该子集主要限于Win32API和一些与COM相关的东西。
我维护此页面的原因是,它通常提供MSDN上缺少的信息或以隐秘的方式描述的信息,也是因为博客不容易搜索。
这里的链接按其主题而不是按时间顺序排列进行分类。有时,在适当的情况下,单个帖子可能会分为多个类别。
在某些(罕见)的情况下,如果发现有用的话,将包括指向其他来源的链接。
免责声明:我没有声称任何链接内容的作者身份。这仅是关于雷蒙德多年来撰写的《伟大文章》的有用组织。
目录
- 过程和线程
- 同步
WaitOnAddress()
-
WaitForMultipleObjects()
和亲戚 - 无锁模式
- dlls
- 资源
- 位图和图标资源
- 对话模板
- 菜单模板和加速器资源
- 字符串资源
- 版本模板
- 数据和自定义资源
- 应用(整体)
HWND
(一般观点)- 顶级窗口
- 窗框和标题
- DWM
- 对话
- 嵌套和嵌入式对话框
- 常见的对话
- 控制导航
- 对话管理经理
- 方式
- 财产表
- 控件
- 动画控件
- 按钮
- 组合盒
- 编辑控件
- 列表视图
- 丰富的文本控件
- 滚动条
- 静态控制
- 工具栏
- 工具提示
- 跟踪栏
- 树列表视图
- 消息处理
- 特定消息
- 通知
- 窗户建设和破坏
- 窗口几何消息
- 窗户绘画消息
- 窗口聚焦消息
- 键盘消息
- 鼠标消息
- 对话消息
- 其他窗口消息
- 系统消息
- GDI
- 光标
- 刷子
- 笔
- 位图
- dib
-
LockWindowUpdate()
- 绘画标准元素
UXTHEME.DLL
- 多个监视器
- 可访问性
- com
- 声明COM接口
- com公寓
- com初始化
- com静态商店
- com宣教
- com错误处理
- com异步接口
- 指导
- com字符串
- com变体
IUnknown
-
IMoniker
-
ICallback
-
IContextMenu
-
IFileDialog
-
IMultiLanguage
-
INamespaceWalk
-
IStream
-
IVirtualDesktopManager
- 剪贴板
- 拖放
- 枚举
- 壳
- 未分类的com东西
- 记忆
- 输入和输出
- 安全权限,属性和标识符
- 注册表
- 字符串和地区
- NT服务
- 未分类
过程和线程
过程
CreateProcess
不等待该过程开始- 为什么
CreateProcess
函数会修改其输入命令行? - 人们为什么要锁定
CreateProcess
电话? - 禁用程序崩溃对话框
- 启动过程时,如何将大量数据传递给该过程?
-
WinMain
的hPrevInstance
参数的目的是什么? -
RunAsInvoker
是一个秘密,甚至更高的UAC设置吗? - 如何防止子进程显示Windows错误报告对话框?
-
WriteProcessMemory
如何成功写入仅阅读内存? - 让
WriteProcessMemory
为我管理页面保护是一个好主意吗? - 我如何从我提升的过程Redux启动未提升的过程
- 如何检查流程的完整性级别?
- 从结构化的异常处理程序中提出结构化的异常是真的吗?
- 在作业对象中创建过程的更直接和错误的方法
线程
- 无效的线程和进程ID
- 为什么我的线句柄突然变坏了?我所做的就是等待它!
- 如果您只从线程回调返回
_beginthread
和_beginthreadex
会发生什么? - 为什么你永远不要暂停线程
- 在UI线程上睡觉的危险
- 追求消息队列
- 在一个过程中枚举线程
- WIN32用户界面工作本质上是单线程
- 线程退出后很长一段时间延迟关闭螺纹手柄有多糟?
- 如果我将
GetExitCodeThread
称为我肯定已退出的线程,为什么它仍然说STILL_ACTIVE
? - 64位系统上的
CreateRemoteThread
有问题吗? -
TerminateThread
函数是否同步? - 从代码中删除
TerminateThread
,等待作业对象为空 FreeLibraryAndExitThread
的意义是什么?- 如果我为堆栈订单和堆栈储备提供矛盾的价值,会发生什么?
线程池
msWindowLength
参数到SetThreadpoolTimer
到底是什么意思?-
CreateTimerQueueTimer
和SetThreadpoolTimer
有什么区别? - 取消线程池回调时,如何避免访问释放内存
- 取消线程池回调时避免僵局,第1部分:外部回调数据
- 取消线程池回调时避免僵局,第2部分:引用到包含的对象
- GOTCHA:ThreadPool周期性计时器将不等待上一个刻度完成
- 为什么在过程关闭期间,我从线程池中得到例外?
- 从传递给
QueueUserWorkItem
函数返回的值会发生什么? -
StartThreadpoolIo
的心理模型 - 如何检测线程池工作项目的时间太长?
- 如何关闭线程池并取消排队的所有工作?
物体的线程亲和力
- 用户界面对象的线程亲和力,第1部分:窗口句柄
- 用户界面对象的线程亲和力,第2部分:设备上下文
- 用户界面对象的线程亲和力,第3部分:菜单,图标,光标和加速器表
- 用户界面对象的线程亲和力,第4部分:GDI对象和其他关于亲和力的注释
- 用户界面对象的线程亲和力,第5部分:对象清理
- 用户界面对象的线程亲和力:附录
线程堆栈
- 如何在运行时扩展线程的堆栈?
- 使用纤维在运行时扩展线程的堆栈,第1部分
- 使用纤维在运行时扩展线程的堆栈,第2部分
- 使用纤维在运行时扩展线程的堆栈,第3部分
- 使用纤维在运行时扩展线程的堆栈,第4部分
- 使用纤维在运行时扩展线程的堆栈,第5部分
- 使用纤维在运行时扩展线程的堆栈,第6部分
- 将纤维与线程进行比较,以便在运行时扩展线程的堆栈
- 确定大约有多少堆栈空间,第1部分
- 确定大约有多少堆栈空间,第2部分
纤维
- 螺纹退出时在线程上运行的纤维会发生什么?
- 使用纤维很好,但是每个人都必须加入计划
- 纤维再也没有用。它只有一个角落仍然有用,原因是与纤维无关的原因
同步
- 了解
WAIT_ABANDONED
的后果 - Windows Keyed事件,关键部分和新的Vista同步功能
- 结合不同事件的工作队列,订单并不重要,并进行自动递归事件
- SRW锁有多公平,尤其是当读者和作家既有?
- 您也可以将文件作为同步对象
- 我可以等待内核事件变得未信号吗?
- 如果Slim Reader/Writer Lock(
SRWLOCK
)不记得共享的锁所有者是谁,这是否意味着可以递归地获取它?
WaitOnAddress()
-
WaitOnAddress
可让您从任何数据变量中创建一个同步对象,甚至是字节 - 根据
WaitOnAddress
实施同步障碍 - 根据
WaitOnAddress
实施关键部分 - 根据
WaitOnAddress
扩展我们的关键部分以支持超时 - 将
WaitOnAddress
与futexes进行比较(futexi?futexen?) - 从
WaitOnAddress
创建信号 - 从
WaitOnAddress
创建具有最大计数的信号量 - 通过
WaitOnAddress
创建手动递归事件 - 从
WaitOnAddress
创建自动递归事件
WaitForMultipleObjects()
和亲戚
MsgWaitForMultipleObjects
和队列状态- 您可以
MsgWaitForMultipleObjects
带有零把手 - 在等待一段时间的同时泵送消息
- 等待使用
MsgWaitForMultipleObjects
等待所有手柄是一个错误等待发生 - 为什么所有参数对我有效时,为什么
WaitForMultipleObjects
返回ERROR_INVALID_PARAMETER
? - 如果多个对象导致
WaitForMultipleObjects
返回,我该如何了解其他对象? - 将一个永不信号的事件传递给
MsgWaitForMultipleObjects
的意义是什么?
无锁模式
- 锁定免费的许多制造商/单一消费者模式:与任务合并的工作队列
- 锁定免费的许多制作人/单一消费者模式:最后一个胜利的工作队列
- 锁定免费的许多生产者/单一消费者模式:相同非煤气事件的工作队列
- 锁定免费的许多生产者/单一消费者模式:不同事件的工作队列,顺序不重要
- 锁定免费的许多制作人/单一消费者模式:不同事件的工作队列,FIFO
- 锁定免费的许多制造商/单一消费者模式:不同事件的工作队列,顺序不重要,后续问题
dlls
- 不要相信返回地址
- 为什么我不能
GetProcAddress
我dllexport的函数? -
HINSTANCE
和HMODULE
有什么区别? - 从静态库访问当前模块的
HINSTANCE
-
LoadLibraryEx(DONT_RESOLVE_DLL_REFERENCES)
从根本上有缺陷 - 为什么在“错误”订单中卸载DLL?
- DLL函数如何在32位窗口中导出?
- 出口的功能,真正是逆转的功能
- 重新考虑DLL导出的方式为32位窗口解决
- 导入库中的名称被装饰是有原因的
- 当您弄错了Dllimport时会发生什么?
- 与强迫为导入功能创建存根有关的问题
- 跨模块边界分配和释放内存
- DLL转发与延迟加载不同
- 什么是DLL进口提示?
- 什么是DLL进口绑定?
-
FreeLibraryAndExitThread
的意义是什么? - 通过
LOAD_LIBRARY_AS_DATAFILE
(或类似标志)加载的库在任何驯鹿模块游戏中都无法玩 - 在您自己的过程中调用
GetModuleFileNameEx
有任何问题吗? - 如何指定我的DLL应该从DLL所在的同一目录中解决DLL依赖性?
- 在我完成DLL延迟加载另一个DLL后,我的DLL开始崩溃的过程分离代码
- 不同种类的DLL种植
- 为什么
GetModuleInfo
无法为可执行文件产生切入点? -
SizeOfImage
在MODULEINFO
结构中的含义是什么? - 如何抑制
LoadLibrary
失败时出现的错误框?
DllMain()
- 有些原因不在您的
DllMain
中做任何可怕的事情 - 另一个原因不在您的
DllMain
中做任何可怕的事情:无意的僵局 - 一些原因不在您的
DllMain
中做任何恐怖的原因,第3部分 - 获取
DLL_PROCESS_DETACH
通知的线程不一定是获得DLL_PROCESS_ATTACH notification
线程 - 您如何在
DLL_PROCESS_DETACH
期间加载DLL,甚至没有意识到 - 当
DLL_PROCESS_DETACH
告诉您该过程正在退出时,最好的选择就是返回而无需做任何事情
资源
- 资源编译器默认为
CP_ACP
,即使面对细微的提示,该文件是UTF-8 - 32位窗口中的模块资源与资源衍生的对象之间的关系
FreeResource
和例如DestroyAcceleratorTable
有什么区别- PE资源必须是4字节对齐的,但这并不能阻止人们尝试其他协调
- 我怎么能说有人使用
MAKEINTRESOURCE
宏来走私指针内的整数? - 令人恐惧的讨厌的人:
FindResource
and FindResourceEx
位图和图标资源
- 为什么与设备无关的位图上下颠倒?
- 位图资源的格式
- 图标资源的格式
- 重新审视图标资源的格式
- ICO文件格式的演变,第1部分:单色开始
- ICO文件格式的演变,第2部分:现在为彩色!
- ICO文件格式的演变,第3部分:alpha混合图像
- ICO文件格式的演变,第4部分:PNG图像
- 如何将GDI位图的Alpha通道设置为255?
消息字符串资源
- 为什么
FormatMessage
说%0
终止消息而没有尾随新线?它秘密地增加了新线吗?
对话模板
- 关于在Win32对话框模板中获得像素完美布局的困难
- 对话模板的演变-32位经典模板
- 对话模板的演变-32位扩展模板
- 对话模板的演变 - 摘要
- 资源编译器将为您添加窗口样式,但是如果您自己构建对话框模板,则不会获得帮助
菜单模板和加速器资源
- 菜单模板的演变:简介
- 菜单模板的演变:32位经典菜单
- 菜单模板的演变:32位扩展菜单
- 加速器表资源的格式
字符串资源
- 字符串资源的格式
LoadString
可以用嵌入式nulls加载字符串,但是您的包装功能可能不会
版本模板
- 版本资源的演变-32位版本资源
- 版本资源的演变 - 损坏的32位版本资源
数据和自定义资源
应用(整体)
- 哪个窗口出现在
Alt+Tab
列表中? - Windows Vista略微更改了
Alt+Tab
Order - WIN32用户界面工作本质上是单线程
STARTF_USESHOWWINDOW
何时覆盖传递给ShowWindow
参数?-
WaitForInputIdle
应该被称为WaitForProcessStartupComplete
-
WaitForInputIdle
等待任何线程,这可能不是您关心的线程 - 管理标准手柄的惯例是什么?
- 标准手柄实际上是针对单线程程序的
- 如果只有DLL可以获取
DllMain
通知,那么EXE在创建线程时如何收到通知?
命令行
- 命令行上的第一个单词仅是按照惯例的程序名称
- 如何使用
CommandLineToArgvW
函数? -
CommandLineToArgvW
的引号和后斜线的奇怪处理方式发生了什么
任务栏
- 我如何防止用户将程序固定到任务栏上?
- 而不是创建某些东西,然后尝试隐藏它,而是首先不要创建它(托盘图标)
- 如果我的应用程序实际上是两个应用程序捆绑到一个文件中,而我希望它们将它们收集到Windows 7中的任务栏上的两个组,该怎么办?
- 如何自定义如何将应用程序窗口分组到任务栏中?
- 在任务栏按钮上显示覆盖层
- 在任务栏预览窗口上显示控制按钮
- 显示用于您的应用程序的自定义缩略图(当您使用时,一个自定义实时预览)
- 如何查询任务栏的位置在辅助监视器上?
- 当我安装它时,该程序如何设法将自己固定在我的任务栏上?
- 如果我有两个在逻辑上是一个应用程序,我希望将它们视为任务栏上的一个组怎么办?
- 为什么用于分组窗口的任务栏图标会更改为怪异的东西?
HWND
(一般观点)
- 窗口是Unicode意味着什么?
- 如何获得实际的窗口过程地址而不是thunk?
- 从
GWLP_WNDPROC
返回的这些奇怪值是什么? -
GWLP_USERDATA
的奖励窗口字节 WM_DESTROY
和WM_NCDESTROY
有什么区别?- 发送一个窗户
WM_DESTROY
消息就像恶作剧打电话给假装是警察的人 GetWindowText
的秘密生活- 为什么
GetWindowText
的规则如此奇怪? - 只有在屏幕上可见窗户时才绘画
- 确定您的窗户是否覆盖
- 最小化时获得窗口的尺寸和位置
- 为什么要立即呼叫
SetForegroundWindow
,然后GetForegroundWindow
不返回同一窗口? - Windows如何决定新创建的窗口是否应使用LTR或RTL布局?
Windows层次结构
- 桌面窗口有什么特别之处?
- 窗口嵌套限制是多少?
-
HWND_TOP
和HWND_TOPMOST
有什么区别? - 窗口可以有父母或所有者,但不能同时
- 为什么我的控件在我进行修复后将其通知发送到错误的窗口?
-
WindowFromPoint
, ChildWindowFromPoint
, RealChildWindowFromPoint
,什么时候结束? -
GetParent
,就像EnumClaw
一样令人困惑,但这是一个实际功能! ( GetAncestor()
, GetWindow()
) - 从另一个过程中拥有一个所有者窗口很棘手,但有时是正确的事情
SetParent
的文档试图告诉我有关同步UI状态的文档?- 证明父母和子女窗口具有不同的UI状态时会发生什么
- 让父母和子窗口具有相同的UI状态
窗户样式
- 哪个窗口样式属于谁?
- 我如何表明我希望窗口遵循左至左的布局规则?
- 为什么我透明的静态控制不透明? (
WS_EX_TRANSPARENT
) - 像蛋糕一样,
WS_EX_TRANSPARENT
是谎言,或者至少不是整个事实 - 我使用
WS_EX_COMPOSITED
摆脱了我的重新闪烁,但导致响应缓慢 - 如何使用
WS_CLIPCHILDREN
并仍然能够绘制具有透明背景的控件?
窗口类
HINSTANCE
传递给了CreateWindow
和RegisterClass
用于使用的?- 在
RegisterClass
中使用错误的HINSTANCE
就像身份盗用 - 如果
RegisterClass
功能占据自定义背景刷的所有权,为什么会泄漏? - 更改窗口类别会影响属于该类的所有窗口
CS_SAVEBITS
做什么?-
CS_OWNDC
类样式做什么? -
CS_CLASSDC
类样式做什么? - 修改
CS_NOCLOSE
样式的确会影响类的所有窗口,而不一定以立即明显的方式 - 为什么
PrintWindow
讨厌CS_PARENTDC
?因为每个人都讨厌CS_PARENTDC
! - 为什么
PrintWindow
讨厌CS_PARENTDC
? redux - 更安全的子类别
- 私人课程,超级阶级和全球子类
- 是什么使
RealGetWindowClass
比GetClassName
更真实? - 为什么
CreateWindowEx
将扩展样式参数作为其第一个参数而不是最后一个参数? - 我什么时候应该使用
CS_GLOBALCLASS
? - 当我调用
SetWindowSubclass
时,UIDSubClass参数的独特性?
顶级窗口
窗框和标题
- 获取标题图标的自定义右键单击菜单
- 即使没有活动,也要绘制活跃的字幕
- 我如何仅在一个窗口中抑制完整的窗口拖动/调整大小?
- 如何在普通和全屏之间切换窗口?
- 我如何在标题栏中启用和禁用最小化,最大化和关闭按钮?
- 在标题栏中获取关闭按钮的位置
- 从Windows 2000或Windows XP获取标题栏中关闭按钮的位置
- 为什么最大化窗口的尺寸大于监视器?
- 创建一个只能在一个方向上调整大小的窗口
- 您为什么不转发
WM_GETMINMAXINFO
并夹紧结果?
DWM
- 当我要求标志性表示时,为什么我的程序不收到
WM_DWMSENDICONICTHUMBNAIL
消息? -
DwmExtendFrameIntoClientArea
函数的MARGINS
控制帧延伸到客户端区域 - 如何抑制当我隐藏或显示窗口时发生的默认动画?
- 显示用于您的应用程序的自定义缩略图(当您使用时,一个自定义实时预览)
- 如何检测我的窗口被外壳从屏幕上抑制了? (“窗帘”)
对话
- 为什么我不能创建对话框?新秀错误#1
- 为什么我不能创建对话框?新秀错误#2
- 从对话框过程中返回值
- 不同类型的对话过程
- 另一个不同类型的对话过程
- 每个对话框的默认答案是“取消”
- 旋转Z阶
- 使用
TAB
键在非拨号中导航 - 使用
TAB
键在非二元格中导航,redux - 防止编辑控制文本在对话框中自动选择
- 那些不了解对话经理注定要重新进化的人很糟糕
WM_GETDLGCODE
的其他技巧GetDialogBaseUnits
是一个crock- 为什么
MapDialogRect
映射对话框矩形不? - 为什么最初创建的对话框隐藏?
-
DS_SHELLFONT
标志有什么关系? - 为什么
DS_SHELLFONT = DS_FIXEDSYS | DS_SETFONT
? - 如何将重点放在对话框中
- 切勿关注残疾人控制
- 恢复以前的窗口位置的微妙之处
- 您已经知道的事情:如何等到我的对话框显示之前,才能做某事?
-
TranslateAccelerator
做什么? - 如果我有一个带有自定义加速器的无模式对话框,我应该先致电:
IsDialogMessage
或TranslateAccelerator
- 温柔的提醒:在对话框上,请勿给予确定并取消加速器
- 为什么用于隐藏控件的加速器仍然处于活动状态?
- 如何使我的加速器仅在主窗口中使用时使用,而不是在用户使用模型对话框时使用?
- 为什么我标记为
WS_TABSTOP
控件上的TAB
键不起作用? - 您不能在对话框中使用
WM_USER
消息 - 如何在运行时右至左的对话框?
- 对话框管理器如何计算字符的平均宽度?
嵌套和嵌入式对话框
DS_CONTROL
样式是什么?- 有关使用
DS_CONTROL
样式的更多注释 - 在对话框上使用相同的ID给出多个控件不是一个好主意
- 在另一个内部嵌入对话框时,请确保您不会意外创建重复的控制ID
- 当调用默认的按钮时,Invoke将转到顶级对话框
常见的对话
- 为什么我的
MessageBox
不在正确的位置? - 如何自定义文件打开对话框的最喜欢的链接部分?
- 为什么通用文件对话框更改当前目录?
- 您可以使用通配符过滤常见的文件对话框
- 如何以编程方式显示查找打印机对话框?
- 为什么共享文件夹中的打开文件列表不显示我的所有打开文件?
- 关联扩展的共同控制是逾期的
- 过滤出现在浏览中的文件夹对话框中的文件夹
- 打开具有特定文件夹预选的经典文件夹浏览器对话框
- 为什么公共文件保存对话框创建一个临时文件然后删除?
- 定制标准色彩挑选对话框
- 如何将“文件打开”对话框的初始目录设置为虚拟目录?
- 当我在“文件打开”对话框中选择多个文件时,为什么最后一项首先出现?
- 我在
OPENFILENAME
结构中设置了OFN_NONETWORKBUTTON
选项,但它对导航窗格中的网络项目没有影响 - 如何将自定义控件添加到公共文件打开或保存对话框中?
- 我如何在
FileOpenPicker
或FolderPicker
选择的同一文件夹中打开我的FileSavePicker
? (帖子末尾提到的win32/com同等学历)
控制导航
- 使用
TAB
键在非拨号中导航 - 使用
TAB
键在非二元格中导航,redux - 管理加速器的UI状态并集中矩形
- 对话框中的自定义导航,redux
- 对话框将焦点返回到上次切换时焦点的控件;如何为自己的窗户加入该动作?
- 如何在我的Win32对话框中创建非圆形标签顺序或其他类型的自定义订购?
对话管理经理
- 对话经理,第1部分:热身
- 对话框管理器,第2部分:创建框架窗口
- 对话框经理,第3部分:创建控件
- 对话管理员,第4部分:对话框循环
- 对话框管理器,第5部分:将非模式对话框转换为模态
- 对话框管理器,第6部分:消息循环中的微妙之处
- 对话框管理器,第7部分:消息循环中的更多微妙之处
- 对话管理员,第8部分:对话框中的自定义导航
- 对话管理员,第9部分:对话框中的自定义加速器
方式
- 禁用和启用窗口的正确订单
- 模式,第1部分:UI模式与代码模式
- 模式,第2部分:代码模式与UI模式
- 模式,第3部分:
WM_QUIT
消息 - 模式,第4部分:为模态UI设置正确所有者的重要性
- 模式,第5部分:为模态UI设置正确的所有者
- 模式,第6部分:与已模态的程序进行互动
- 模式,第7部分:定时
MessageBox
,便宜的版本 - 模式,第8部分:定时
MessageBox
,更好的版本 - 模式,第9部分:为模态UI设置正确的所有者,实践考试
- 线程消息是通过模态循环食用的
- 通过消息过滤器从模态循环中拯救线程消息
财产表
DS_SHELLFONT
在属性表页面上还有什么其他效果?-
PSM_ISDIALOGMESSAGE
是IsDialogMessage
调的属性表 - 您可以使用自己的奖励数据扩展
PROPSHEETPAGE
结构 - 每次激活向导页面时,都会发送
PSN_SETACTIVE
通知 - 将额外有效载荷附加到
PROPSHEETPAGE
结构 - 如何将一系列可变大小的
PROPSHEETPAGE
结构传递给PropertySheet?
控件
动画控件
- 外壳动画控制的局限性
- 为什么版本6动画控件不使用背景线程?
按钮
BS_PUSHLIKE
按钮样式是什么? (不要使用,如今已经完全过时了。使用复选框或广播按钮。)
组合盒
- 加快将项目添加到Combobox或ListBox(
WM_SETREDRAW
)
编辑控件
EM_SETHILITE
消息有什么关系?- 防止编辑控制文本在对话框中自动选择
- 如何抑制密码编辑控件上的
CapsLock
警告? -
ES_NUMBER
编辑控制样式的早期历史 - 如何使用
ES_NUMBER
编辑控制样式允许负数? - 我如何允许将负符号输入我的编辑控件,但仅当它是第一个字符时?
列表视图
- 定位与非定位的ListView视图
- 显示折叠和展开的ListView项目的信息
- 计算背景中的ListView Infotip
-
LVM_HITTEST
和LVM_INSERTMARKHITTEST
有什么区别? - 当已经有一个完美的
LVN_ODSTATECHANGED
Notification时,为什么有LVN_ITEMCHANGED
? - 在某些项目上创建带有复选框的listView,但不是其他项目
- 如何编程调整ListView列的大小以适合其内容?
- 如何为ListView项目创建禁用的复选框?
- 加快将项目添加到Combobox或ListBox(
WM_SETREDRAW
)
丰富的文本控件
默里·萨金特(Murray Sargent)的Richedit控制的历史(该帖子只是一个(断开的)链接https://blogs.msdn.microsoft.com/murrays/2006/10/19/some-richedit-history/)- 如何将整个文件加载到丰富的文本控件中?
- 如何将超过32,000个字符放入丰富的文本控制中?
- 如何打印丰富的文本控制的内容?
滚动条
- 刮擦程序
- 滚动条,第2部分
- 滚动条,第3部分:优化油漆周期
- 滚动条,第4部分:添加一个比例的卷轴
- 可能的第5部分:滚动条的键盘可访问性
- 第5部分的附录:键盘代码中的微妙之处
- 滚动条第6部分 - 轮子
- 滚动条第7部分 - 完整性
- 滚动条第8部分 - 整体交互式调整大小
- 滚动条第9部分 - 维护隐喻
- 滚动条第10部分 - 更深入地了解
WM_NCCALCSIZE
消息 - 滚动条第11部分:更深入地了解
WM_NCCALCSIZE
消息 - 从滚动条第11部分中锻炼的答案
- 滚动条第12部分:将
WM_NCCALCSIZE
应用于我们的卷轴样本 - Scrollbars Redux:第12部分
- 有两种类型的卷轴
- 为什么选择
WHEEL_DELTA
为120,而不是更方便的价值(例如100甚至10)? - 为什么首次设置水平滚动条范围也设置了垂直范围,反之亦然?
- 自动滚动阻力,第1部分:基本实现
- 第2部分自动滚动:如果我扭动鼠标,为什么滚动滚动速度更快?
- 在阻力上自动滚动,第3部分:基于鼠标位置的动态自动滚动
- 拖动自动滚动,第4部分:基于逃逸速度的动态自动滚动
- 自动滚动拖动,第5部分:添加Wiggle-scroll以逃避速度
静态控制
- 静态控件何时会自动删除将图像加载到其中,何时是应用程序的责任?
选项卡控件
- 我应该如何在具有选项卡控件的对话框上创建控件?
- 我应该如何创建Win32 Tab Control的孩子?
工具栏
- 为什么都有
TBSTYLE_EX_VERTICAL
和CCS_VERT
? - 如何创建一个位于任务栏中的工具栏?
- 如何创建一个右键的工具栏按钮?
- 在跳跃列表上创建自定义任务
工具提示
- 对面工具的编码
- 在工具提示中使用自定义绘制来调整字体
- 将多个工具多路复用到工具提示中
- 动态生成工具提示文本
- 为什么我不能为禁用窗口显示工具提示?
- 过度记录的
TTM_RELAYEVENT
及其为何会导致一秒钟的周期性计时器,只要可见工具提示
跟踪栏
- 添加一个
Ctrl
+箭头加速器,用于将跟踪栏移动一个单元,第1部分:初始跌幅 - 添加一个
Ctrl
+箭头加速器,用于将跟踪栏移动一个单元,第二部分:第二次尝试 - 我如何防止用户使用鼠标将跟踪栏拇指拖到不是五个倍数的位置?第1部分:重新构架问题
- 我如何防止用户使用鼠标将跟踪栏拇指拖到不是五个倍数的位置?第2部分:轻推拇指位置
树列的视图
TVS_CHECKBOXES
风格很古怪,这是一种说这太疯狂的方式- 使用
TVS_CHECKBOXES
样式时要当心泄漏的图像列表 - 创建树视图复选框手动:简单状态图像列表
- 创建树视图手动复选框:响应点击
- 创建树视图手动复选框:主题复选框
- 树视图复选框:肮脏的历史记录
- 树视图复选框:扩展复选框状态
消息处理
- 哪个消息号属于谁?
- 发送消息的各种方式
- 广播用户定义的消息
- 线程什么时候可以接收窗口消息?
-
GetKeyState
和GetAsyncKeyState
有什么区别? - 线程消息是通过模态循环食用的
- 通过消息过滤器从模态循环中拯救线程消息
- 过滤窗口消息的危险
- 您无法使用
PostMessage
模拟键盘输入 - 在等待一段时间的同时泵送消息
- 追求消息队列
- 不,真的,您需要将所有未手持的消息传递给
DefWindowProc
- 即使您有执行消息的代码,也允许您致电
DefWindowProc
,因为无论如何您都在这样做 Get/SetMessageExtraInfo
曾经使用过什么?- 为什么
GetWindowLongPtr
在64位窗口上返回垃圾价值? -
TrackMouseEvent
跟踪窗口中的鼠标事件,但前提是事件属于您的窗口 - 不要忘记将消息队列包括在锁层次结构中
SendMessageTimeout
到达超时时,已发送消息会发生什么?- 为什么我不能
PostMessage
WM_COPYDATA
消息,但是我可以SendMessageTimeout
它以微小的超时发送呢? - 即使按需生成鼠标移动,油漆和计时器消息,仍然有可能进入队列
- 即使稍后发布,已发布的消息是在输入消息之前处理的
- 只有消息的窗口可以收到什么样的消息?
- 如果
DispatchMessageA
和DispatchMessageW
的原型相同,为什么两者都有? - 那些不了解对话经理注定要重新进化的人很糟糕
- 更改某些内部应用程序状态后,如何触发鼠标光标的恢复?
- 更改某些内部应用状态后,如何触发鼠标光标的重新校准?
-
GetQueueStatus
和队列状态
钩
HINSTANCE
传递给了SetWindowsHookEx
使用的是什么?- 当光标更改时,如何通知?
-
SetWindowsHookEx
的线程参数实际上是什么意思? - 为什么
SetFocus
失败而不告诉我为什么?
特定消息
通知
WM_NOTIFY
消息的wParam
与NMHDR
结构中的idFrom
有什么区别。- 重述有关
WM_COMMAND
消息的明显 - 重述有关
WM_NOTIFY
消息的明显
窗户建设和破坏
WM_DESTROY
和WM_NCDESTROY
有什么区别?- How can I determine the reason why my window is closing? (
WM_CLOSE
)
Window Geometry Messages
- Use
WM_WINDOWPOSCHANGED
to react to window state changes - Use
WM_WINDOWPOSCHANGING
to intercept window state changes
Window Painting Messages
- Paint messages will come in as fast as you let them (
WM_PAINT
) - What happens if I don't paint when I get a
WM_PAINT
message? - What is the implementation of
WM_PRINTCLIENT
? - There's a default implementation for
WM_SETREDRAW
, but you might be able to do better - Speeding up adding items to a combobox or listbox (
WM_SETREDRAW
) - Using
WM_SETREDRAW
to speed up adding a lot of elements to a control
Window Focus Messages
-
WM_KILLFOCUS
is the wrong time to do field validation - The dangers of playing focus games when handling a
WM_KILLFOCUS
message - Why doesn't the
MoveWindow
function generate the WM_GETMINMAXINFO
message?
Keyboard Messages
- How do I respond to the
WM_MENUCHAR
message?
Mouse Messages
- Why is there no
WM_MOUSEENTER
message? - Why do I get spurious
WM_MOUSEMOVE
messages? - Sure, I can get spurious
WM_MOUSEMOVE
messages, but why do they keep streaming in? - How do I get mouse messages faster than
WM_MOUSEMOVE
? - Logical consequences of the way Windows converts single-clicks into double-clicks
- Implementing higher-order clicks
- How slow do you have to slow-double-click for it to be a rename?
- How can I prevent the mouse from moving in response to touch input?
Dialog Messages
- Those who do not understand the dialog manager are doomed to reimplement it, badly
- Managing the UI state of accelerators and focus rectangles (
WM_CHANGEUISTATE
, WM_QUERYUISTATE
and WM_UPDATEUISTATE
) - Untangling the confusingly-named
WM_UPDATEUISTATE
and WM_CHANGEUISTATE
messages - Who sends the initial
WM_UPDATEUISTATE
message? - How can I prevent the keyboard focus rectangle from appearing on a control I created?
- Other tricks with
WM_GETDLGCODE
- How do I prevent multi-line edit controls from eating the Enter key?
- Why do
DLGC_WANTALLKEYS
and DLGC_WANTMESSAGE
have the same value?
Other Window Messages
- The dangers of messing with activation when handling a
WM_ACTIVATE
message - Why does my window get a
WM_ACTIVATE
message when it isn't active? - A timed context menu (
WM_CANCELMODE
) - Pitfalls in handling the
WM_CONTEXTMENU
message ( WM_CONTEXTMENU
) -
WM_NCHITTEST
is for hit-testing, and hit-testing can happen for reasons other than the mouse being over your window - How likely is it that a window will receive a
WM_NULL
message out of the blue? ( WM_NULL
) - Why is there a special
PostQuitMessage
function? ( WM_QUIT
) - How does
PostQuitMessage
know which thread to post the quit message to? ( WM_QUIT
) - Who is responsible for destroying the font passed in the
WM_SETFONT
message? ( WM_SETFONT
) - When I send a
WM_GETFONT
message to a window, why don't I get a font? ( WM_GETFONT
) - If my
WM_TIMER
handler takes longer than the timer period, will my queue fill up with WM_TIMER
messages? - Killing a window timer prevents the
WM_TIMER
message from being generated for that timer, but it doesn't retroactively remove ones that were already generated
系统消息
- If one program blocks shutdown, then all programs block shutdown (
WM_QUERYENDSESSION
, WM_ENDSESSION
) - Why do I have to return this goofy value for
WM_DEVICECHANGE
? ( WM_DEVICECHANGE
) - Windows doesn't close windows when a user logs off; that's your call (
WM_ENDSESSION
) - Once you return from the
WM_ENDSESSION
message, your process can be terminated at any time ( WM_ENDSESSION
)
GDI
- Why are
RECT
s endpoint-exclusive? - Can you create an information context for the display?
- What does the
CS_OWNDC
class style do? - What does the
CS_CLASSDC
class style do? - How do you detect "Large Fonts"? (DPI)
- Drawing a monochrome bitmap with transparency
- Let GDI do your RLE compression for you
- The mysterious stock bitmap: There's no way to summon it, but it shows up in various places
- Why is my icon being drawn at the wrong size when I call
DrawIcon
? - You must flush GDI operations when switching between direct access and GDI access, and direct access includes other parts of GDI
- How do I get the dimensions of a cursor or icon?
- What are the dire consequences of not selecting objects out of my DC?
- Of what use is the
RDW_INTERNALPAINT
flag? - Functions that return GDI regions rarely actually return regions
- Color-aware ClearType requires access to fixed background pixels, which is a problem if you don't know what the background pixels are, or if they aren't fixed
- What is the correct way of using
SaveDC
and RestoreDC
? - How are
BitBlt
raster opcodes calculated? - Notes on
DrawText
and tab stops - Why doesn't
GetTextExtentPoint
return the correct extent for strings containing tabs? - Why are there trivial functions like
CopyRect
and EqualRect
? - More on trivial functions like
CopyRect
and EqualRect
- What are the consequences of increasing the per-process GDI handle limit?
- The focus rectangle says, “I'm not orange.我只是那样画画。”
光标
- The effect of
SetCursor
lasts only until the next SetCursor
- What can or should I do with the cursor handle returned by
SetCursor
? - What is the deal with the
SM_CXCURSOR
system metric? - How do I find out the size of the mouse cursor?
刷子
- The hollow brush
- Other uses for bitmap brushes
- What is the DC brush good for?
- I know I can change the color of the DC pen, but what about the other attributes?
- How can I extract the color from a solid color GDI brush?
笔
- Is there a difference between creating a null pen with
CreatePen
and just using the stock null pen?
Bitmaps
- How do I set the alpha channel of a GDI bitmap to 255?
dib
- A survey of the various ways of creating GDI bitmaps with predefined data
- Blitting between color and monochrome DCs
- Manipulating the DIB color table for fun and profit
- Using DIB sections to perform bulk color mapping
- The fun and profit of manipulating the DIB color table can be done without having to modify it
- Separating the metadata from the DIB pixels: Precalculating the
BITMAPINFO
- Separating the metadata from the DIB pixels: Changing the raster operation
- The disembodiment of DIBs from the DIB section
- What is the
hSection
parameter to CreateDIBSection
for?
LockWindowUpdate()
- What does
LockWindowUpdate
do? - How is
LockWindowUpdate
meant to be used? - With what operations is
LockWindowUpdate
meant to be used? - With what operations is
LockWindowUpdate
not meant to be used? - Final remarks on
LockWindowUpdate
Painting Standard Elements
- Rendering standard Windows elements
- Rendering menu glyphs is slightly trickier
- What states are possible in a
DRAWITEMSTRUCT
structure?
UXTHEME.DLL
-
BeginBufferedPaint
: It's not just for buffered painting any more - How do
IsThemeActive
, IsAppThemed
, and IsCompositionActive
differ? - How do I get the tabbed dialog effect on my own custom tabbed dialog?
- How do I revert a control back to its default theme?
多个监视器
- For better performance, set all your monitors to the same color format
- How do I get a handle to the primary monitor?
- Why does the primary monitor have
(0,0)
as its upper left coordinate? - How do I get the color depth of the screen?
- How does the window manager adjust
ptMaxSize
and ptMaxPosition
for multiple monitors?
可访问性
- Accessibility is not just for people with disabilities
- How to retrieve text under the cursor (mouse pointer)
- How do I set an accessible name on an unlabeled control?
- How can I get notified when some other window is destroyed?
- Using accessibility to monitor windows as they come and go
- How can I write a program that monitors another window for a title change?
- How can I write a program that monitors another window for a change in size or position?
com
Declaring COM Interfaces
- The macros for declaring COM interfaces, revisited: C version
- The macros for declaring COM interfaces, revisited: C++ version
- The macros for declaring COM interfaces, revisited: C++ implementation
- The oracle always tells the truth, even when it is wrong: COM method calls with a user-defined type as a return value (on problems of COM interfaces called from C code)
- The COM interface contract rules exist for a reason
- Giving a single object multiple COM identities, part 1
- Giving a single object multiple COM identities, part 2
- Giving a single object multiple COM identities, part 3
- Giving a single object multiple COM identities, part 4
- How do I consume raw COM interfaces from a Windows Runtime metadata file?
COM Apartments
- The dreaded "main" threading model
- A slightly less brief introduction to COM apartments (but it's still brief)
- Yo dawg, I hear you like COM apartments, so I put a COM apartment in your COM apartment so you can COM apartment while you COM apartment
- What kind of apartment is the private apartment I created via
CLSID_ContextSwitcher
? - Setting up private COM contexts to allow yourself to unload cleanly
- How do you get into a context via
IContextCallback::ContextCallback
? - Using contexts to return to a COM apartment later
- What do the output values from
CoGetApartmentType
mean? - User interface code + multi-threaded apartment = death
- Other problems traced to violating COM single-threaded apartment rules in the shell
- What's the point of
APTTYPE_CURRENT
? I mean, of course I'm current. - How do I get a foothold in the neutral apartment?
- What is so special about the Application STA?
- What does it mean when a call fails with
0x8000001F = RO_E_BLOCKED_CROSS_ASTA_CALL
?
COM Initialization
- What does the
COINIT_SPEED_OVER_MEMORY
flag to CoInitializeEx
do? - Crashing in COM after I call
CoUninitialize
, how can COM be running after it is uninitalized?
COM Static Store
- The COM static store, part 1: Introduction
- The COM static store, part 2: Race conditions in setting a singleton
- The COM static store, part 3: Avoiding creation of an expensive temporary when setting a singleton
- The COM static store, part 4: Aggregating into a single object
- The COM static store, part 5: Using COM weak references
- The COM static store, part 6: Using C++ weak references
COM Marshaling
- 什么是com套,我该如何使用?
- On proper handling of buffers in COM and RPC methods
- What are the rules for
CoMarshalInterThreadInterfaceInStream
and CoGetInterfaceAndReleaseStream
? - What are the rules for
CoMarshalInterface
and CoUnmarshalInterface
? -
CoGetInterfaceAndReleaseStream
does not mix with smart pointers - The COM marshaller uses the COM task allocator to allocate and free memory
- Why do I get a
QueryInterface(IID_IMarshal)
and then nothing? - We batched up our COM requests and return a single stream of results, but the performance is still slow
- What are the various usage patterns for manually-marshaled interfaces?
- An initial look at the mechanics of how COM marshaling is performed
- https://devblogs.microsoft.com/oldnewthing/20220616-00/?p=106757
- Writing a marshal-by-value marshaler, part 1
- Writing a marshal-by-value marshaler, part 2
- Writing a compound marshaler
- Understanding the marshaling flags: The free-threaded marshaler
COM Error Handling
- What happens to my COM server-side object when clients die unexpectedly?
- Why does COM require output pointers to be initialized even on failure?
- How do I convert an
HRESULT
to a Win32 error code? - How can I tell the WIL
RETURN_IF_FAILED
macro that some errors are ignorable? - Do not overload the
E_NOINTERFACE
error - What does it mean when a call fails with
0x8000001F = RO_E_BLOCKED_CROSS_ASTA_CALL
? - What does it mean when my cross-thread COM call fails with
RPC_E_SYS_CALL_FAILED
? - Understanding a mysterious
RPC_E_WRONGTHREAD
exception when we're on the right thread
COM Asynchronous Interfaces
- COM asynchronous interfaces, part 1: The basic pattern
- COM asynchronous interfaces, part 2: Abandoning the operation
- COM asynchronous interfaces, part 3: Abandoning the operation after a timeout
- COM asynchronous interfaces, part 4: Doing work while waiting for the asynchronous operation
- COM asynchronous interfaces, part 5: The unreliable server
- COM asynchronous interfaces, part 6: Learning about completion without polling
- COM asynchronous interfaces, part 7: Being called directly when the operation completes
- COM asynchronous interfaces, part 8: Asynchronous release, the problems
- COM asynchronous interfaces, part 9: Asynchronous release, assembling a solution
指导
- What's the difference between
UuidFromString
, IIDFromString
, CLSIDFromString
, GUIDFromString
... - What is the difference between
UuidToString
, StringFromCLSID
, StringFromIID
, and StringFromGUID2
? - Why are there four functions for parsing strings into GUIDs, and why are they in three different DLLs?
- Why does COM express GUIDs in a mix of big-endian and little-endian? Why can't it just pick a side and stick with it?
COM Strings
- Why is there a
BSTR
cache anyway? - Raymond's complete guide to
HSTRING
semantics - What is the correct way of using the string buffer returned by the
WindowsPreallocateStringBuffer
function?
COM Variants
- What's the difference between
VARIANT
and VARIANTARG
? - Nasty gotcha:
VarCmp
vs VariantCompare
- Why can't
VarDateFromStr
parse back a Hungarian date that was generated by VarBstrFromDate
?
IUnknown
- The layout of a COM object
- Under what conditions will the
IUnknown::AddRef
method return 0? - The ways people mess up
IUnknown::QueryInterface
- The ways people mess up
IUnknown::QueryInterface
, episode 2 - The ways people mess up
IUnknown::QueryInterface
, episode 3 - The ways people mess up
IUnknown::QueryInterface
, episode 4 - COM object destructors are very sensitive functions
- Avoiding double-destruction when an object is released
- I'd like an
IUnknown
, I know you have many, I'll take any of them - A very brief introduction to patterns for implementing a COM object that hands out references to itself
- Giving a single object multiple COM identities, part 1
- Giving a single object multiple COM identities, part 2
- Giving a single object multiple COM identities, part 3
- Giving a single object multiple COM identities, part 4
- Reducing chattiness by querying for multiple interfaces at once, part 1
- Reducing chattiness by querying for multiple interfaces at once, part 2
IMoniker
- Pidls and monikers do roughly the same thing, just backwards
ICallback
- A very brief introduction to patterns for implementing a COM object that hands out references to itself
IContextMenu
- Why an object cannot be its own enumerator
- How to host an
IContextMenu
, part 1 - Initial foray - How to host an
IContextMenu
, part 2 - Displaying the context menu - How to host an
IContextMenu
, part 3 - Invocation location - How to host an
IContextMenu
, part 4 - Key context - How to host an
IContextMenu
, part 5 - Handling menu messages - How to host an
IContextMenu
, part 6 - Displaying menu help - How to host an
IContextMenu
, part 7 - Invoking the default verb - How to host an
IContextMenu
, part 8 - Optimizing for the default command - How to host an
IContextMenu
, part 9 - Adding custom commands - How to host an
IContextMenu
, part 10 - Composite extensions - groundwork - How to host an
IContextMenu
, part 11 - Composite extensions - composition - Simplifying context menu extensions with
IExecuteCommand
- How do I launch a file as if it were a text file, even though its extension is not
.txt
? - Do not access the disk in your
IContextMenu
handler, no really, don't do it - Sure, we do that: Context menu edition
- Psychic debugging: Why your
IContextMenu::InvokeCommand
doesn't get called even though you returned success from IContextMenu::QueryContextMenu
- Don't forget to implement canonical names for verbs in your shell context menu extension
IFileDialog
- The
SetClientGuid
method of the common file and folder dialogs lets you give names to those dialogs, too (multiple contexts for open/save dialogs) - How can I get my
FileSavePicker
to open in the same folder that was picked by the FileOpenPicker
or FolderPicker
? (win32/COM equivalent mentioned at the end of the post) - Why does IFileDialog still show non-filesystem folders when I pass
FOS_FORCEFILESYSTEM
?
IMultiLanguage
- Converting between
LCID
s and RFC 1766 language codes - Feel free to stop using
IMultiLanguage2::DetectInputCodepage
INamespaceWalk
- How can I control which parts of the shell namespace the
INamespaceWalk::Walk
operation will walk into? - How can I cancel the
INamespaceWalk::Walk
operation? - Cancelling the
INamespaceWalk::Walk
operation a little faster
IStream
- The subtleties of
CreateStreamOnHGlobal
, part 1: Introduction and basic usage - The subtleties of
CreateStreamOnHGlobal
, part 2: Suppressing the deletion of an unknown HGLOBAL
- The subtleties of
CreateStreamOnHGlobal
, part 3: Suppressing the deletion of a shared HGLOBAL
- The subtleties of
CreateStreamOnHGlobal
, part 4: Non-movable memory - A practical use for
GetHGlobalFromStream
when sharing was never your intention
IVirtualDesktopManager
- Virtual desktops are an end-user window management feature, not a programmatic one
剪贴板
- How ownership of the Windows clipboard is tracked in Win32
- What happens when applications try to copy text by sending
Ctrl+C
- How do I make it so that users can copy static text on a dialog box to the clipboard easily?
- What is the proper handling of
WM_RENDERFORMAT
and WM_RENDERALLFORMATS
? - Copying a file to the clipboard so you can paste it into Explorer or an email message or whatever
- Printing the contents of the clipboard as text to
stdout
- Improving the performance of
CF_HDROP
by providing file attribute information - What's up with the
CF_SYLK
and CF_DIF
clipboard formats? - How can I wait more than 30 seconds for a delay-rendered clipboard format to become rendered?
拖放
- What a drag: Dragging text
- What a drag: Dragging a Uniform Resource Locator (URL)
- What a drag: Dragging a Uniform Resource Locator (URL) and text
- What a drag: Dragging a virtual file (
HGLOBAL
edition) - What a drag: Dragging a virtual file (
IStream
edition) - What a drag: Dragging a virtual file (
IStorage
edition) - You can drag multiple virtual objects, you know
- Reading a contract from the other side: Simulating a drop
- Simulating a drop, part two
- What happens if I drag the mouse by exactly the amount specified by
SM_CXDRAG
? - How do I accept files to be opened via
IDropTarget
instead of on the command line? - How do I accept files to be opened via
IDropTarget
instead of on the command line? - bonus content - Using Explorer's fancy drag/drop effects in your own programs
- Drag/drop effects: The little drop information box
- Why isn't my shell namespace extension getting every single
DragOver
mouse message? - Why doesn't my program get fancy drag/drop effects in high contrast mode with
CLSID_DragDropHelper
?
枚举
- Using fibers to simplify enumerators, part 1: When life is easier for the enumerator
- Using fibers to simplify enumerators, part 2: When life is easier for the caller
- Using fibers to simplify enumerators, part 3: Having it both ways
- Using fibers to simplify enumerators, part 4: Filtering
- Using fibers to simplify enumerators, part 5: Composition
壳
- When does
SHLoadInProc
unload a DLL? - What does
SHGFI_USEFILEATTRIBUTES
mean? - What's the difference between
SHGetMalloc
, SHAlloc
, CoGetMalloc
, and CoTaskMemAlloc
- Querying information from an Explorer window
- Execute a file as if it were a program, even though its extension is not
EXE
- How do I launch a file as if it were a text file, even though its extension is not
.txt
? - What does the
SEE_MASK_UNICODE
flag in ShellExecuteEx
actually do? - Simple things you can do with the
ShellExecuteEx
function - What were
ShellExecute
hooks designed for? - Why does
ShellExecute
return SE_ERR_ACCESSDENIED
for nearly everything? - How do I
ShellExecute
a file, but with a specific program instead of the default program? - What is the difference between
CSIDL_DESKTOP
and CSIDL_DESKTOPDIRECTORY
? -
SHCIDS_CANONICALONLY
is the moral equivalent in the shell namespace of the Unicode ordinal comparison - Don't forget to double-null-terminate those strings you pass to
SHFileOperation
- Why does
SHFileOperation
have internal error codes for DVD? - Why do non-folders in my shell namespace extension show up in the folder tree view?
-
SHAutoComplete
giveth, and SHAutoComplete
taketh away - What is the
lpClass
member of SHELLEXECUTEINFO
used for? - Some known folders cannot be moved, but others can, and you'll just have to accept that
- One possible reason why
ShellExecute
returns SE_ERR_ACCESSDENIED
and ShellExecuteEx
returns ERROR_ACCESS_DENIED
- Why does
SHGetSpecialFolderPath
take such a long time before returning a network error? - How do you obtain the icon for a shortcut without the shortcut overlay? (
SHGetFileInfo()
) - How can I get information about the items in the Recycle Bin?
- Modernizing our simple program that retrieves information about the items in the Recycle Bin
- Invoking commands on items in the Recycle Bin
- How do I perform shell file operations while avoiding shell copy hooks?
- Command line tool to manage Windows 7 Libraries, with source code (
IShellLibrary
) -
IShellFolder::BindToObject
is a high-traffic method; don't do any heavy lifting - Obtaining the parsing name (and pidl) for a random shell object
- Creating a simple pidl: For the times you care enough to send the very fake
- Creating a simple shell item, just as fake as a simple pidl
- Displaying a property sheet for multiple files
- How do I get a high resolution icon for a file?
- How do I extract an icon at a nonstandard size if
IExtractIcon::Extract
tells me to go jump in a lake? - How do I read the "Double-click to open an item (single-click to select)" setting in Folder Options?
- The wonderful world of shell bind context strings
- Helper functions to make shell bind contexts slightly more manageable
- Customizing item enumeration with
IShellItem
- Customizing item enumeration with
IShellItem
, the old-fashioned way - How do I create an
IShellItemArray
from a bunch of file paths? - How do I invoke a verb on an
IShellItemArray
? - How does a shell namespace extension provide icons for virtual items that track the standard icons set by the user's file associations?
- How do I get the user-customed name of My Computer or Recycle Bin?
- How do I get the user-customized name of a mapped network drive?
- Enumerating all the programs that can open a particular file extension
- Enumerating all the programs that can launch a particular protocol
- How do I register a command on the desktop background context menu? (And how do I remove one I don't like?)
- How can I get the canonical name for a known folder?
- Peeking inside an
IShellItem
to see what it's made of - Why does
SHGetKnownFolderPath
return E_FAIL
for a known folder? - Why does
SHGetKnownFolderPath
fail when impersonating? - Why can't I use
SHSetKnownFolderPath
to change the location of FOLDERID_LocalAppData
? - How do I programmatically add a folder to my Documents library?
- Why doesn't
SHGetFileInfo
give me customized folder icons? - How can I detect that a shell item refers to a virtual folder, or to a file system inside a file?
- Why is there a limit of 15 shell icon overlays?
- The case of the
SHGetFolderPath(CSIDL_COMMON_DOCUMENTS)
that returned ERROR_PATH_NOT_FOUND
- Why is the
HSHELL_WINDOWDESTROYED
notification raised when a window is hidden, even if it hasn't been destroyed? - Why am I receiving
HCNE_UPDATEDIR
notifications that my code never generates? - Why am I receiving
SHCNE_UPDATEDIR
notifications that my code never generates? - How can I get the original target of a shortcut without applying any 32-bit adjustments?
- How does Explorer calculate the “Date” of a file?
Uncategorized COM Stuff
- The macros for declaring and implementing COM interfaces
- An introduction to COM connection points
- Dispatch interfaces as connection point interfaces
- Adjustor thunks
- What is the underlying object behind a COM interface pointer?
- How to turn off the exception handler that COM "helpfully" wraps around your server
- Shortcuts are serializable objects, which means that they can be stored in places other than just a file
- Why does
IFileOperation
skip junctions even though I passed FOFX_NOSKIPJUNCTIONS
? - Nasty gotcha:
STGM_READ | STGM_WRITE
does not grant read/write access - How can I get the list of programs the same way that Programs and Features gets it?
- How do I obtain the computer manufacturer's name via C++? (
IWbemClassObject
) - The stream pointer position in
IDataObject::GetData
and IDataObject::GetDataHere
is significant - The sad implementation history of COM component categories and why it means you have to click twice to see your newly-installed taskbar toolbar
- How do I request that my out-of-process COM server run unelevated?
- How can a desktop app use a Windows Runtime object that infers UI context from its thread? The
IInitializeWithWindow
pattern ( IInitializeWithWindow
) - How do I protect myself against a COM call that can hang? I'm already running the server out-of-process.
- What can I do about timer build-up when waiting for COM outbound calls to complete?
- Manipulating the positions of desktop icons
- A reminder about the correct way of accessing and manipulating the position of icons on the desktop
- The oracle always tells the truth, even when it is wrong: COM method calls with a user-defined type as a return value (on problems of COM interfaces called from C code)
- Notes on COM aggregation: Obtaining a pointer to your aggregated partner without introducing a reference cycle
- Notes on COM aggregation: How do you implement tear-offs in an aggregated object?
- The theory behind the
IHttpFilter
interface
记忆
- Stupid memory-mapping tricks
- Creating a shared memory block that can grow in size
- Why do I have to pass a valid page protection value to
VirtualAlloc
even if it ignores it? - How can I include/exclude specific memory blocks in user-mode crash dumps?
-
IsBadXxxPtr
should really be called CrashProgramRandomly ( IsBadWritePtr()
et al.) - A closer look at the stack guard page
- The case of the stack overflow exception when the stack is nowhere near overflowing
- How to allocate address space with a custom alignment or in a custom address region
输入和输出
- Mount points, volumes, and physical drives, oh my!
- What's the difference between an asynchronous
PIPE_WAIT
pipe and a PIPE_NOWAIT
pipe? - Be careful when redirecting both a process's
stdin
and stdout
to pipes, for you can easily deadlock - Looking at the problem at the wrong level: Closing a process's
stdin
-
ReadDirectoryChangesW
reads directory changes, but what if the directory doesn't change? - How do
FILE_FLAG_SEQUENTIAL_SCAN
and FILE_FLAG_RANDOM_ACCESS
affect how the operating system treats my file? - I used
FILE_FLAG_SEQUENTIAL_SCAN
but it didn't seem to speed up my sequential scanning - You can use an
OVERLAPPED
structure with synchronous I/O, too - We're currently using
FILE_FLAG_NO_BUFFERING
and FILE_FLAG_WRITE_THROUGH
, but we would like our WriteFile
to go even faster - On using
ILE_FLAG_WRITE_THROUGH
and FILE_FLAG_NO_BUFFERING
for memory-mapped files - On the interaction between the
FILE_FLAG_NO_BUFFERING
and FILE_FLAG_WRITE_THROUGH
flags - Why does my synchronous overlapped
ReadFile
return FALSE
when the end of the file is reached? - Why does
SetFileValidData
fail even though I enabled the SE_MANAGE_VOLUME_NAME
privilege? - Is
GENERIC_ALL
equivalent to GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE
? -
CancelIoEx
can cancel I/O on console input, which is kind of nice -
CancelIoEx
can cancel synchronous I/O, which is kind of nice - Why does
IsPathRelative
return FALSE
for paths that are drive-relative? - The security check happens at the acquisition of the handle
- Taking a shortcut: You can query properties from a volume, and it will forward to the physical drive
- https://devblogs.microsoft.com/oldnewthing/20201023-00/?p=104395
- How do I disassociate a thread from an I/O completion port?
- Is it okay to call
MapViewOfFile
on the same mapping handle simultaneously from different threads? - What are these dire multithreading consequences that the
GetFullPathName
documentation is trying to warn me about? - How can I force a
WriteFile
or ReadFile
to complete synchronously or hang, in order to test something? - How can I perform a
CopyFile
, but also flush the file buffers before the destination handle is closed?
Asynchronous Input and Output
- Developing the method for taking advantage of the fact that the
OVERLAPPED
associated with asynchronous I/O is passed by address - Ready... cancel... wait for it! (第1部分)
- Ready... cancel... wait for it! (第2部分)
- Ready... cancel... wait for it! (第3部分)
- If you're waiting for I/O to complete, it helps if you actually have an I/O to begin with
- Why does my asynchronous I/O complete synchronously?
- If an asynchronous I/O completes synchronously, is the
hEvent
in the OVERLAPPED
structure signaled anyway? - You can use an
OVERLAPPED
structure with synchronous I/O, too - Why does my synchronous overlapped
ReadFile
return FALSE
when the end of the file is reached? - If I issue a second overlapped I/O operation without waiting for the first one to complete, are they still guaranteed to complete in order?
- Why are my file write operations synchronous, even though I opened the file as
FILE_FLAG_OVERLAPPED
? - File-extending writes are not always synchronous, which is entirely within the contract
- Why you might need additional control over the secret event hiding inside the file object
- Why doesn't my asynchronous read operation complete when I close the handle?
- The mental model for
StartThreadpoolIo
- How can I force a
WriteFile
or ReadFile
to complete synchronously or hang, in order to test something? - If I issue multiple overlapped I/O requests against the same region of a file, will they execute in the order I issued them?
- What are the potentially-erroneous results if you don't pass
NULL
as the lpNumberOfBytesRead
when issuing overlapped I/O?
文件和目录
- The Definitive Guide on Win32 to NT Path Conversion
- How can I tell that a directory is really a recycle bin?
- How can I tell that a directory is weird and should be excluded from the user interface?
- How do I get information about the target of a symbolic link?
- How do I access a file without updating its last-access time?
- How do I show the contents of a directory while respecting the user's preferences for hidden and super-hidden files as well as the user's language preferences?
- You can use a file as a synchronization object, too
- How can I append to a file and know where it got written, even if the file is being updated by multiple processes?
- The
FILE_FLAG_DELETE_ON_CLOSE
flag applies to the handle, also known as the file object, which is not the same as the file - How long do I have to keep the
SECURITY_ATTRIBUTES
and SECURITY_DESCRIPTOR
structures valid after using them to create a file? - How do I create a directory where people can create subdirectories but cannot mess with those created by other users?
- How can I tell whether a file is on a removable drive, a fixed drive, or a remote drive?
- How can I tell whether a file is on an SSD?
- Why does a non-recursive
ReadDirectoryChangesW
still report files created inside subdirectories? - The early history of Windows file attributes, and why there is a gap between System and Directory
- Even if you open a file with GUID, you can still get its name, or at least one of its names (
GetFinalPathNameByHandle()
) - How do I get from a file path to the volume that holds it?
- How do I get from a volume to the physical disk that holds it?
- Renaming a file is a multi-step process, only one of which is changing the name of the file
- How can I recognize file systems that don't support 64-bit unique file identifiers?
- How can I recognize whether two handles refer to the same underlying file?
ACL
- The
MoveSecurityAttributes
policy affects only how Explorer recalculates ACLs when a file is moved; everybody else is on their own - How to create a folder that inherits its parent's ACL, and then overrides part of it
Security Permissions, Attributes and Identifiers
- The security check happens at the acquisition of the handle
- What is the default security descriptor?
- How do I convert a SID between binary and string forms?
- What are these SIDs of the form
S-1-15-2-xxx
? - What are these SIDs of the form
S-1-15-3-xxx
? - An easy way to determine whether you have a particular file permission
- What are the access rights and privileges that control changing ownership of an object?
- How do the names in the file security dialog map to access control masks?
- If you ask for
STANDARD_RIGHTS_REQUIRED
, you may as well ask for the moon - A user's SID can change, so make sure to check the SID history
- Detecting whether a SID is well-known SID
- SIDs are really just another a fancy way of creating unique IDs in a decentralized way
- What's the point of giving my unnamed object proper security attributes since unnamed objects aren't accessible outside the process anyway (or are they?)
- Is a SID with zero subauthorities a valid SID?这取决于你问谁
- What's the difference between duplicating the handle to a token and duplicating a token?
- I called
AdjustTokenPrivileges
, but I was still told that a necessary privilege was not held - I called
AdjustTokenPrivileges
, but I was still told that a necessary privilege was not held, redux - The history of the
EncodePointer
function for obfuscating pointers - Additional helpful pseudo-handles: The process token, the thread token, and the effective token
- How can I tell whether my process is running as SYSTEM?
- A brief summary of the various versions of the Security Descriptor Definition Language (SDDL)
- How do I free the pointers returned by functions like
GetTokenInformation
? - A clarification on the multithreading constraints of the
EncryptMessage
function
注册表
- Beware of non-null-terminated registry strings
- The performance cost of reading a registry key
- So how bad is it that I'm calling
RegOpenKey
instead of RegOpenKeyEx
? - If I simply want to create a registry key but don't intend to do anything else with it, what security access mask should I ask for?
- How can I programmatically inspect and manipulate a registry hive file without mounting it?
- Why doesn't
RegSetKeySecurity
propagate inheritable ACEs, but SetSecurityInfo
does? - Why does
RegNotifyChangeKeyValue
stop notifying once the key is deleted? - How can I emulate the
REG_NOTIFY_THREAD_AGNOSTIC
flag on systems that don't support it?第1部分 - How can I emulate the
REG_NOTIFY_THREAD_AGNOSTIC
flag on systems that don't support it?第2部分 - How can I emulate the
REG_NOTIFY_THREAD_AGNOSTIC
flag on systems that don't support it?第3部分 - How can I emulate the
REG_NOTIFY_THREAD_AGNOSTIC
flag on systems that don't support it?第4部分 - How can I emulate the
REG_NOTIFY_THREAD_AGNOSTIC
flag on systems that don't support it?第5部分 - The history of passing a null pointer as the key name to
RegOpenKeyEx
- On the failed unrealized promise of
RegOverridePredefKey
(ie don't use it.)
Strings and Locales
-
TEXT
vs. _TEXT
vs. _T
, and UNICODE
vs. _UNICODE
- The sad history of Unicode
printf
-style format specifiers in Visual C++ - Nasty gotcha:
SetThreadUILanguage
cannot be used to restore the thread UI language - How can
CharUpper
and CharLower
guarantee that the uppercase version of a string is the same length as the lowercase version? (use LCMapStringEx()
in any new code) - Is there a code page that matches ASCII and can round trip arbitrary bytes through Unicode?
- A consequence of being the first to adopt a standard is that you may end up being the only one to adopt it: The sad story of Korean jamo
- The
activeCodePage
manifest element can be used for more than just setting UTF-8 as the active code page - Feel free to stop using
IMultiLanguage2::DetectInputCodepage
- On the proper care and feeding of the enigmatic
GetDistanceOfClosestLanguageInList
function - How can I get
WideCharToMultiByte
to convert strings encoded in UTF-16BE?
NT Services
- Calling
ShutdownBlockReasonCreate
from my service doesn't stop the user from shutting down - What does it mean when my attempt to stop a Windows NT service fails with
ERROR_BROKEN_PIPE
? - How can I configure my Windows NT service to autostart when the system gains Internet access?
- On the confusing names for the Windows service SID types
未分类
- How do I determine the processor's cache line size? (
GetLogicalProcessorInformation()
) - Why are structure sizes checked strictly?
- What's the difference between
CreateMenu
and CreatePopupMenu
? - Why are
HANDLE
return values so inconsistent? - How to retrieve text under the cursor (mouse pointer)
- How to detect programmatically whether you are running on 64-bit Windows
- A timed context menu
- The importance of passing the
WT_EXECUTELONGFUNCTION
flag to QueueUserWorkItem
- If your callback fails, it's your responsibility to set the error code
- The double-click time tells the window manager how good your reflexes are
- The cursor isn't associated with a window or a window class; it's associated with a thread group
- Menu item states are not reliable until they are shown because they aren't needed until then
- How can I display a live screenshot of a piece of another application?
- Converting from a UTC-based
SYSTEMTIME
directly to a local-time-based SYSTEMTIME
- Programmatically uploading a file to an FTP site
- How can you use both versions 5 and 6 of the common controls within the same module?
- How can I tell if Windows Update is waiting for the system to reboot?
- How do I call
SetTimer
with a timer ID that is guaranteed not to conflict with any other timer ID? - A window can't have two timers with the same ID, so how do I assign an ID that nobody else is using?
- What does it mean when a display change is temporary?
- How do I obtain the comment for a share?
- How accurate are the various Windows time-querying functions?
- How can I detect whether the user is logging off?
- Why are timer IDs and dialog control IDs 64-bit values on 64-bit Windows? Did you really expect people to create more than 4 billion timers or dialog controls?
- If you suppress GDI+ background thread, then you are expected to pump messages yourself
- If one program blocks shutdown, then all programs block shutdown (
WM_QUERYENDSESSION
, WM_ENDSESSION
) - When I ask the
GetIpAddrTable
function to sort the results, how are they sorted? - How can I detect that the system is no longer showing a UAC prompt? (
EVENT_SYSTEM_DESKTOPSWITCH
) - How can I get the number of processors in the system, when there are more than 64?
- Why are some system functions exported as stubs instead as forwarders?
- How can I check whether the user has disconnected from the session?
- Why does
PF_VIRT_FIRMWARE_ENABLED
return false even when virtualization is enabled in the firmware? - How can I convert between IANA time zones and Windows registry-based time zones?
- The focus rectangle says, “I'm not orange.我只是那样画画。”
- Why does the precise point at which I get a stack overflow exception change from run to run? (structured exception handling aka SEH)
- How do I programmatically reposition monitors in a multiple-monitor system? (
ChangeDisplaySettingsEx()
) - How do I upgrade a 32-bit tick count to a 64-bit one?
- The error code you get might not be the one you want
- How can I find out which processor architectures are supported via emulation by the current system?
- How can I detect whether the system has a keyboard attached? On the
GetRawInputDeviceList
function - Filtering out fake keyboards from the
GetRawInputDeviceList
function - How expensive is
PssCaptureSnapshot
?它有多快? How much memory does it consume? - What is the
CreateExplorerShellUnelevatedTask
scheduled task? - Under what conditions can I modify the memory that I received in the form a
STGMEDIUM
? - Is it true that raising a structured exception from a structured exception handler terminates the process?
- Why are many Windows user interface elements positioned at multiples of 4 or 8 pixels? (DPI,
DEVICE_SCALE_FACTOR
) - A history of the
fd_set
, FD_SETSIZE
, and how it relates to WinSock - How can I detect programmatically whether Windows is an N or KN version?
- How should I interpret the various values of
NLM_CONNECTIVITY
? - How can I find out the last time a user logged on from C++?
- How can I specify icons for my app to use on the Start menu in high contrast mode?
- How can I add an environment variable to a process launched via
ShellExecuteEx
or IContextMenu
? - Functions that return the size of a required buffer generally return upper bounds, not tight bounds