这是我第一次,我想使用 Windows 进行并行处理创建进程 http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425%28v=vs.85%29.aspx功能。根据 MSDN 上的示例,我创建了一个LPTSTR“(非常量)TCHAR 字符串” https://stackoverflow.com/questions/321413/lpcstr-lpctstr-and-lptstr 命令行 http://en.wikipedia.org/wiki/Command-line_interface像这样的论点
LPTSTR szCmdline[] = _tcsdup(TEXT("\C:\\MyProgram_linux_1.1\\MyProgram.exe") );
LPTSTR 和其他这里讨论 char 和 string 类型 http://www.codeproject.com/Articles/76252/What-are-TCHAR-WCHAR-LPSTR-LPWSTR-LPCTSTR-etc
命令行参数传递给CreateProcess
像这样
if (!CreateProcess(NULL, szCmdline, /*...*/) ) cout << "ERROR: cannot start CreateProcess" << endl;
这些标头存在
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <strsafe.h>
#include <direct.h>
编译时出现这样的错误:
error C3861: '_tcsdup': identifier not found
搜索发现这个错误相同的错误,但解决方案特定于使用 .NET 框架 http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/db2b883d-6f95-4ca8-8219-648db3b07b18而不是解释error C3861: '_tcsdup'
不确定是否相关,但还有一个error C2059: syntax error : ')'
on the if (!CreateProcess(NULL, szCmdline, /*...*/) ) cout << "ERROR: cannot start CreateProcess" << endl;
这个错误是如何修复的?而且,这是怎么回事?
另外,我正在使用CreateProcess作为学习 Linux 的一个学习步骤fork() https://stackoverflow.com/questions/985281/what-is-the-closest-thing-windows-has-to-fork功能 - Visual Studio 界面对我来说更容易使用,一旦调试完毕并正常工作,我将更改为 g++ 界面并更改为fork()
并从那里进行调试 - 所以一个解决方案导致fork()
如果可能的话,是最有利的。