简约 Visual C++显示窗口的应用程序
我正在尝试在 Visual Studio 2010 中创建一个符合以下条件的 C++ 应用程序:
- 显示一个空窗口
- 尽可能小(例如,在 100kb)
- 在全新空安装的 Windows XP 上运行(不 需要任何运行时、库等)
基本上,我想摆脱运行时。我唯一需要的就是调用 WinAPI 函数来显示一个窗口并在其表面上进行 BitBlt 操作。
是否可以?
I'm trying to create a C++ application in Visual Studio 2010 which matches the following criteria:
- Displays an empty window
- Is small as possible (say, under
100kb) - Runs on fresh empty install of Windows XP (does not
require any runtimes, libraries, etc)
Basically, I want to get rid of runtime. The only thing I need is to call WinAPI functions to display a window and BitBlt something to it's surface.
Is it possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
1/2: Visual Studio 可以生成一个基本模板,这正是您所需要的(显示一个空窗口)。使用
文件->新->新项目->选择“Win32 项目”->单击“完成”
创建项目。当静态链接到 C 运行时库时,Release\Win32 二进制文件为 81KB(更多信息见下文)。当然,添加代码可能会增加二进制大小。您可能需要查看优化设置,甚至二进制压缩以最小化大小。由于防病毒软件频繁误报,我不推荐后者。3:您需要静态链接到C 运行时库。这可以在配置属性 -> 下配置。 C/C++->代码生成->运行时库(选择
/MT
用于发布,选择/MTd
用于调试)。这样做将允许您在没有 Visual C++ 2010 的情况下运行可执行文件可再发行软件包 安装。请注意,使用 Visual Studio 2010 编译的二进制文件需要 Windows XP SP2 或更高版本。如果您需要定位 pre -Windows XP SP2 版本。
1/2: Visual Studio can generate a bare-bones template, which is exactly what you need (displays an empty window). Use
File -> New -> New Project -> select 'Win32 Project' -> click 'Finish'
to create the project. The Release\Win32 binary is 81KB when statically linking to the C run-time library (more on this below). Of course, adding your code will likely increase the binary size. You may want to look at optimization settings or even binary compression to minimize size. The latter I would not recommend due to frequent false positives from anti-virus software.3: You will need to statically link to the C run-time library. This can be configured under
Configuration Properties -> C/C++ -> Code Generation -> Runtime Library
(select/MT
for release and/MTd
for debug). Doing so will allow you to run the executable without the presence of the Visual C++ 2010 redistributable package installation.Note that binaries compiled with Visual Studio 2010 require Windows XP SP2 or higher. You may wish to check this workaround if you need to target pre-SP2 versions of Windows XP.
MSDN 文档 有一个很好的 WinAPI 分步示例“你好世界!”。你只需要喝一点开菲尔就可以了;)
The MSDN documentation has a nice step-by-step example of WinAPI "Hello, World!". You just need to take a bit of kefir and get into it ;)