![](https://img-blog.csdnimg.cn/direct/78e652f6880246c0a30e9f8a1cc8f4db.jpeg?x-oss-process=image/resize,m_fixed,h_224,w_224)
Windows
文章平均质量分 83
汇总关于 Windows 的开发、调试、脚本、使用技巧
0x0007
everything
展开
-
翻译《The Old New Thing》- How can I get the Windows Runtime HttpClient to display a ...
在传统 Win32 应用中,如何通过 `IInitializeWithWindow` 接口确保 `HttpBaseProtocolFilter` 显示基本认证对话框,解决了因线程 UI 上下文不明确导致的问题。原创 2024-06-22 07:15:00 · 827 阅读 · 0 评论 -
翻译《The Old New Thing》- When does a process ID become available for reuse?
进程 ID 何时可以被 复用?是在进程句柄变为已信号状态时(但在僵尸对象从系统中移除之前),还是只有在最后一个进程句柄被释放后(进程对象从系统中移除)才会发生?如果是前者,OpenProcess() 对僵尸进程会成功吗?(即已经终止但尚未从系统中移除的那个)原创 2024-06-22 06:45:00 · 341 阅读 · 0 评论 -
翻译《The Old New Thing》- How do I suppress the error box that appears when a LoadLibrary fails?
在 LoadLibrary 失败时,将 SEM_FAILCRITICALERRORS 标志添加到已经设置的任何标志中。原创 2024-06-16 13:27:49 · 251 阅读 · 0 评论 -
翻译《The Old New Thing》- How can I add an environment variable to a process launched via ...
本文展示了如何在 `ShellExecuteEx` 和 `IContextMenu` 调用中通过实现 `ICreatingProcess` 接口来向进程添加环境变量,并使用 C++/WinRT 库创建自定义服务站点。原创 2024-06-16 13:21:22 · 635 阅读 · 0 评论 -
翻译《The Old New Thing》- The case of the exception that a catch (…) didn’t catch
客户修复了bug但程序仍崩溃。分析发现,尽管异常被捕获,但由于两个同时发生的`E_ACCESSDENIED`错误,系统错误地匹配了异常堆栈,导致真正的问题未被正确识别。原创 2024-06-13 17:23:19 · 834 阅读 · 0 评论 -
翻译《The Old New Thing》- How does the classic Win32 ListView handle incremental searching?
经典 Win32 ListView 支持两种增量搜索模式:重复字母模式和前缀模式,根据用户输入自动切换以快速定位项目。原创 2024-06-13 17:13:54 · 744 阅读 · 0 评论 -
翻译《The Old New Thing》- Setting the contents of a Windows Runtime Vector from C++/WinRT in one call
在一次调用中设置 C++/WinRT 中 Windows 运行时向量的元素原创 2024-06-12 18:34:10 · 431 阅读 · 0 评论 -
翻译《The Old New Thing》- Is there any difference between StringFromIID and StringFromCLSID?
StringFromCLSID 和 StringFromIID 的条目是相同的。那么这两个函数之间有什么区别呢?原创 2024-06-12 18:30:48 · 310 阅读 · 0 评论 -
翻译《The Old New Thing》- How can I force a DLL to register itself if it won’t respond to regsvr32?
这篇文章讨论了如何强制注册一个不响应regsvr32命令的DLL文件。原创 2024-06-11 09:50:31 · 223 阅读 · 0 评论 -
翻译《The Old New Thing》- Why doesn‘t Explorer have an interface for creating hard links?
资源管理器未提供创建硬链接的用户界面,因为硬链接概念复杂,普通用户难以理解,且可能引发数据损坏和备份问题。原创 2024-06-10 11:22:00 · 394 阅读 · 0 评论 -
翻译《The Old New Thing》- Why do messages posted by PostThreadMessage disappear?
使用`PostThreadMessage`向显示UI的线程发送消息时,消息可能会被模态循环丢弃。为可靠通信,应创建隐藏窗口并发送消息。原创 2024-06-10 11:12:04 · 1072 阅读 · 0 评论 -
翻译《The Old New Thing》- How do I obtain the computer manufacturer’s name?
文章讲述了如何通过WMI查询获取计算机制造商信息,指出这种方法的可靠性依赖于BIOS,通常大品牌计算机显示的制造商名较为准确,而自组装机器可能仅显示"Manufacturer"。原创 2024-06-09 09:58:44 · 626 阅读 · 0 评论 -
翻译《The Old New Thing》- On 64-bit Windows, 32-bit programs run in an emulation layer, and if you ...
在64位Windows上,32位程序在仿真层上运行,如果你不喜欢那样,那就不要使用仿真器.原创 2024-06-09 09:52:46 · 552 阅读 · 0 评论 -
翻译《The Old New Thing》- Why isn’t there a SendThreadMessage function?
文章讨论了 Windows 中不存在 `SendThreadMessage` 函数的原因,指出通常应发送常规窗口消息而非线程消息,并建议使用窗口消息代替。原创 2024-06-08 21:58:54 · 755 阅读 · 0 评论 -
翻译《The Old New Thing》- ven if you have code to handle a message, you’re allowed to ...
即使你有处理消息的代码,你仍然可以调用 DefWindowProc,因为你本来就在这么做原创 2024-06-08 01:36:24 · 784 阅读 · 0 评论 -
翻译《The Old New Thing》- Why are some GDI functions named ExtXxx instead of XxxEx?
为什么一些 GDI 函数以 Ext 开头而不是 Ex?原创 2024-06-08 01:22:17 · 273 阅读 · 0 评论 -
翻译《The Old New Thing》- QueryPerformanceCounter counts elapsed time, not CPU cycles
`QueryPerformanceCounter`记录经过的时间而非CPU周期,因为其频率在系统运行时不变。创建与CPU周期相关的计数器需要定义跨架构的“CPU周期”概念,并解决多处理器和超线程情况下的计数问题。HAL编写者会为已知的有缺陷硬件添加检测和变通代码。原创 2024-06-07 09:31:41 · 306 阅读 · 0 评论 -
翻译《The Old New Thing》- What were ShellExecute hooks designed for?
ShellExecute钩子设计用于扩展可执行字符串集合,如使IE能通过"运行"对话框打开网址。滥用此钩子进行安全检查或审计,不仅违背设计初衷,也可能因其他钩子或直接调用CreateProcess而失效。原创 2024-06-07 09:28:15 · 1082 阅读 · 0 评论 -
翻译《The Old New Thing》If you return FALSE from DLL_PROCESS_ATTACH, will you get a DLL_PROCESS_DETACH?
如果从 DLL_PROCESS_ATTACH 返回 FALSE,是否会得到 DLL_PROCESS_DETACH?原创 2024-06-06 19:02:20 · 841 阅读 · 0 评论 -
翻译《The Old New Thing》- What’s with this MSH_MOUSEWHEEL message?
`MSH_MOUSEWHEEL`是为旧版Windows设计的滚轮消息,与`WM_MOUSEWHEEL`不同,它从前景窗口向外传播,需要手动处理。`WM_MOUSEWHEEL`则自动从焦点窗口向父窗口链冒泡。两者处理机制不同,导致在某些情况下`WM_MOUSEWHEEL`可能被错误地传递到非预期的子窗口。原创 2024-06-06 18:46:55 · 982 阅读 · 0 评论 -
翻译《The Old New Thing》- Why does OpenProcess succeed even when I add three to the process ID?
用户发现在Windows NT中,向进程ID加3后调用`OpenProcess`仍能成功,这是因为内核句柄管理器忽略最低两位,所以加3不影响映射。但这是实现细节,可能随时改变。原创 2024-06-05 10:11:11 · 436 阅读 · 0 评论 -
翻译《The Old New Thing》- Why do atoms start at 0xC000?
在16位Windows系统中,原子表中的指针是16位,且内存块4字节对齐,因此原子值从`0xC000`开始以区分整数原子和字符串原子。整数原子范围是`0x0000-0xBFFF`,字符串原子是`0xC000-0xFFFF`。尽管Win32不再使用编码指针,但原子的这种划分方式仍被保留。原创 2024-06-04 14:17:31 · 287 阅读 · 0 评论 -
翻译《The Old New Thing》- What‘s the difference between int and INT, long and LONG, etc?
Windows头文件中大写的`INT`、`LONG`等类型与小写的`int`、`long`现在没有区别,两者可互换使用。这源于确保跨平台一致性的需要,现在由于编译器的统一,这种区分已无实际意义。原创 2024-06-04 14:10:50 · 563 阅读 · 0 评论 -
翻译《The Old New Thing》- How do I force the ECHO command to echo?
ECHO命令用于在命令行打印文本,但存在解析参数的复杂性。要防止ECHO命令解释其参数,在其后加一个点(如`ECHO. ON`),这可以输出文字而不改变ECHO命令的状态。这种设计反映了批处理语言的演变,虽不完美,但为兼容性而存在。原创 2024-06-03 10:07:04 · 870 阅读 · 0 评论 -
翻译《The Old New Thing》- What’s the difference between the COM and EXE extensions?
COM文件是无结构的原始内存映像,而EXE文件是带有"MZ"头部和其它元数据的结构化程序。操作系统最初根据文件扩展名来区分它们,但后来改为检查MZ头部以提高兼容性,允许COM文件成长为超过64KB而不必重命名为EXE。原创 2024-06-03 10:01:09 · 834 阅读 · 0 评论 -
翻译《The Old New Thing》- What a drag: Dragging a Uniform Resource Locator (URL)
本文介绍了如何在Windows程序中实现拖拽操作,以便同时支持在Internet Explorer和Firefox浏览器中识别URL。通过修改数据对象的剪贴板格式,从`CF_TEXT`更改为`CFSTR_SHELLURL`,使得IE能够识别拖拽的文本为URL。作者承诺将在下一篇文章中展示如何创建一个单一的数据对象,使其能够兼容两个浏览器。原创 2024-06-02 16:25:56 · 713 阅读 · 0 评论 -
翻译《The Old New Thing》- What a drag: Dragging a Uniform Resource Locator (URL) and text
这篇文章主要讲述了如何在Windows编程中实现一个可以同时处理文本和URL数据的拖拽功能,通过扩展数据类型枚举、设置格式等和响应数据请求来实现。原创 2024-06-02 16:19:53 · 631 阅读 · 0 评论 -
翻译《The Old New Thing》- The history of the Windows XP common controls
Windows XP引入了新的公共控件库`UXCTRL.DLL`以增强视觉体验,但引发了兼容性问题。为解决此问题,微软采用了并行程序集,通过应用程序清单控制DLL版本,确保新旧程序兼容。原创 2024-05-31 06:15:00 · 1667 阅读 · 0 评论 -
翻译《The Old New Thing》- Why are process and thread IDs multiples of four?
在基于Windows NT的操作系统中,进程和线程ID通常是4的倍数,但这仅是代码复用的一个偶然结果,并非官方规范,因此开发者不应依赖此特性编写代码。原创 2024-05-30 10:26:33 · 276 阅读 · 0 评论 -
翻译《The Old New Thing》- There can be more than one (or zero): Converting a process to a window
文章指出,Win32程序中一个HINSTANCE可以对应多个窗口,而ShellExecute返回的HINSTANCE并不具有实际用途。正确的方法是使用GetWindowThreadProcessId和EnumThreadWindows函数来枚举和识别与特定进程或线程相关的窗口。原创 2024-05-30 10:19:53 · 539 阅读 · 0 评论 -
翻译《The Old New Thing》- Consequences of the scheduling algorithm: Low priority threads can take 100%
调度算法的控制:低优先级线程也可能占用100%的CPU原创 2024-05-29 10:15:50 · 411 阅读 · 0 评论 -
翻译《Use FILE_SHARE_DELETE in your shell extension》
本文讨论了文件操作时,FILE_SHARE_DELETE 标志的重要性及 Windows 系统对此问题处理的细节。原创 2024-05-29 06:15:00 · 1313 阅读 · 0 评论 -
翻译《The Old New Thing》- Using the “gu“ debugger command to find the infinite loop
本文介绍了如何使用 WinDbg 中的 !runaway 扩展和 gu 命令来识别和调试导致100% CPU占用的无限循环问题。通过监控线程的CPU时间变化,可以找到并逐层调试循环中的函数。原创 2024-05-16 14:10:02 · 379 阅读 · 0 评论 -
翻译《The Old New Thing》- Stupid debugger tricks: Calling functions and methods
本文介绍了如何在调试器中使用 .call 命令自动调用函数和C++方法,包括设置参数和寄存器,以及如何通过模拟已知签名的函数来调用接口方法。同时警告了这种操作可能带来的副作用。原创 2024-05-16 14:05:01 · 572 阅读 · 0 评论 -
翻译《The Old New Thing》- What does the CS_OWNDC class style do?
本文讨论了CS_OWNDC窗口类样式的影响,它让窗口管理器为窗口创建一个永久的设备上下文(DC),并始终返回同一个DC。这会导致代码中假设每次调用GetDC会得到不同DC的逻辑出现问题,因为实际上多次调用可能返回相同的DC,从而破坏了依赖于此假设的绘图代码。原创 2024-05-15 10:19:23 · 879 阅读 · 0 评论 -
翻译《The Old New Thing》- What does the CS_CLASSDC class style do?
本文讨论了CS_CLASSDC类样式的问题,指出它会导致跨窗口和线程间共享同一个设备上下文(DC),从而引发竞态条件和难以调试的错误。作者建议现代软件不应使用此样式,它仅适用于16位Windows的单线程环境。原创 2024-05-15 10:01:11 · 633 阅读 · 0 评论 -
翻译《The Old New Thing》- Taxes: Remote Desktop Connection and painting
本文讨论了在远程桌面连接环境下,如何优化Windows应用程序的绘图性能。关键技术点包括:1) 适应网络延迟和带宽限制;2) 使用双缓冲技术减少屏幕闪烁;3) 根据是否通过远程桌面连接选择绘图方法,以平衡性能和用户体验。原创 2024-05-14 11:16:40 · 867 阅读 · 0 评论 -
翻译《The Old New Thing》- Taxes: Detecting session state changes, such as a locked workstation
该文主要介绍了如何在Windows程序中通过注册会话通知和监听WM_WTSSESSION_CHANGE消息来检测工作站锁定、用户切换等会话状态变化,并用声音反馈响应这些变化。原创 2024-05-14 10:33:53 · 369 阅读 · 0 评论 -
翻译《The Old New Thing》- The redirection operator can occur in the middle of the command line
这篇文章讨论了命令行重定向操作符的位置问题。原创 2024-05-13 11:41:01 · 262 阅读 · 0 评论 -
翻译《The Old New Thing》- The first word on the command line is the program name only by convention
这篇文章讨论了在Windows编程中,命令行参数的格式和处理方式。原创 2024-05-13 11:26:59 · 589 阅读 · 0 评论