为 Windows 3.1 改造 WM_COPYDATA 消息
本文介绍了如何在 Windows 3.1 系统上为老旧应用程序改造并支持 WM_COPYDATA 消息。由于 Windows 3.1 原生不支持该消息机制,作者通过技术手段实现了进程间数据传递功能,使旧版系统也能与现代应用程序兼容。
背景速读
- **Raymond Chen** is a veteran Microsoft developer who writes "The Old New Thing" blog, a long-running deep-dive into Windows history, kernel internals, and design decisions.
- **WM_COPYDATA** is a Windows message that allows one running program to safely send a block of data to another program's window. It was introduced in Windows 3.1 (1992) as a standard inter-process communication (IPC) mechanism.
- This article reveals that the WM_COPYDATA message was actually retrofitted onto Windows 3.1 after its initial release — the original 3.1 didn't have it. It was added via a maintenance update (often called "Windows 3.1a" or similar), and the API was designed to be forward-compatible so newer programs could detect whether the OS supported it.
- The story matters because it shows how pragmatic Microsoft's design process was back then: they shipped the feature late, maintained backward compatibility, and relied on runtime detection rather than requiring users to upgrade. It's a small case study in how real-world OS APIs evolve under constraints.