C++打开具有 2 个约束的文件
C++ open a file with 2 constraints
在 c++ 中,我想用记事本打开我的文本文件,但是:
- 不要停止程序或等待关闭记事本...
- 不创建控制台/cmd选项卡(我正在使用Visual Studio 2017,Windows(
可能吗?
我有这个: _popen("记事本.exe C:\X\X\X.txt", "R"(; 但它会打开一个 cmd 选项卡。
(仅限Windows的解决方案(
通过修改示例:https://learn.microsoft.com/en-us/windows/win32/procthread/creating-processes
对于C++:
#include <iostream>
#include <Windows.h>
int main(int argc, char* argv[])
{
if (argc != 2)
{
std::cout << "Usage: " << argv[0] << " [cmdline]n";
return EXIT_FAILURE;
}
STARTUPINFOA si = {sizeof(si)};
PROCESS_INFORMATION pi = {};
// Start the child process.
if (!CreateProcessA(nullptr, // No module name (use command line)
argv[1], // Command line
nullptr, // Process handle not inheritable
nullptr, // Thread handle not inheritable
false, // Set handle inheritance to FALSE
0, // No creation flags
nullptr, // Use parent's environment block
nullptr, // Use parent's starting directory
&si, // Pointer to STARTUPINFO structure
&pi)) // Pointer to PROCESS_INFORMATION structure
{
std::cout << "CreateProcess failed (" << GetLastError() << ").n";
return EXIT_FAILURE;
}
// Wait until child process exits.
//WaitForSingleObject(pi.hProcess, INFINITE);
// Close process and thread handles.
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
return EXIT_SUCCESS;
}
相关文章:
- .cpp和.h文件中的模板专用化声明
- 为什么两个不同的未命名名称空间可以共存于一个cpp文件中
- 文本文件中的单词链表
- CMake-按正确顺序将项目与C运行时对象文件链接
- 使用新行和不使用新行读取文件
- 在C++程序中输入的文本文件将不起作用,除非文本被复制和粘贴
- 挂起和取消挂起一个文件DLL
- 如何确定我已使用非编码文件到达 EOF?
- 命名空间中具有.h和.cpp文件的类
- 如何使用ndk-build.cmd构建Android.so文件
- 从包含m行的文件中提取n行,必要时(惰性地)重复该文件
- 读取文件并输入到矢量中
- 在C++中查找文件
- c++库的公共头文件中应该包含什么
- 用c++从输入文件中读取另一行
- Cppcheck生成xml转储文件
- 读取文件的最后一行并输入到链接列表时出错
- C++打开具有 2 个约束的文件
- 检查特定txt文件中的项目是否符合"名称编号USACO"中的约束
- 将约束添加到Qwidget的CSS文件中