for*_*son 5 c++ fork createprocess lptstr visual-studio-2008
这是我的第一次,我想使用Windows CreateProcess函数进行并行处理.根据MSDN上的示例,我创建了一个LPTSTR"(非常量)TCHAR字符串" 命令行参数,如下所示
LPTSTR szCmdline[] = _tcsdup(TEXT("\C:\\MyProgram_linux_1.1\\MyProgram.exe") );
Run Code Online (Sandbox Code Playgroud)
这里讨论 LPTSTR和其他char和字符串类型
命令行参数传递给CreateProcess这样
if (!CreateProcess(NULL, szCmdline, /*...*/) ) cout << "ERROR: cannot start CreateProcess" << endl;
Run Code Online (Sandbox Code Playgroud)
并且这些标题存在
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <strsafe.h>
#include <direct.h>
Run Code Online (Sandbox Code Playgroud)
在编译时这是错误:
error C3861: '_tcsdup': identifier not found
Run Code Online (Sandbox Code Playgroud)
搜索此错误发现相同的错误,但解决方案特定于使用.NET框架而不是解释error C3861: '_tcsdup'
不知道是否有关,但也有一个error C2059: syntax error : ')'上if (!CreateProcess(NULL, szCmdline, /*...*/) ) cout << "ERROR: cannot start CreateProcess" << endl;
这个错误是如何修复的?而且,这是怎么回事?
此外,我正在使用CreateProcess学习Linuxfork()功能的学习步骤 - 我更容易使用Visual Studio界面,一旦调试并运行,我将转换到g ++界面并fork()从那里切换到调试 - 所以fork()如果可能的话,导致最有益的解决方案.
添加以下内容包括:
#include <tchar.h>
Run Code Online (Sandbox Code Playgroud)