在这里,我阅读了如何在 C 中编写 .exe,以便使用特定程序打开特定文件。从代码中获取的.exe文件
#include <iostream>
#include <windows.h>
#include <Shellapi.h>
main()
{
ShellExecute(0, "Explore", "c:\\Program
Files", NULL, NULL,SW_RESTORE);
}
做它所需要的。那么为什么它不会使 .exe 文件至少从代码中获得
#include <iostream>
#include <windows.h>
#include <Shellapi.h>
main()
{
ShellExecute(0, "notepad", "c:\\2.txt",
NULL, NULL, SW_RESTORE);
}
? 它编译没有错误,打开生成的 .exe 不会导致错误。为什么这不打开任何文本文件?还是我的便携式编译器有问题?
您只需要仔细阅读文档...
可能是这样——
然后该文件将由与给定扩展名关联的应用程序打开。