#include "stdafx.h"
#include <Windows.h>
#include <iostream>
using std::cout;
using std::endl;
DWORD WINAPI TaskThreadExe(LPVOID lp);
typedef struct stuParam
{
std::string name;
int age;
}TstuParam;
int _tmain(int argc, _TCHAR* argv[])
{
/*
E:\Versioncheck\iCAN V001R003 集成定制专用版本\bin>VerCheckCmd.exe -b "E:\19\bas
e\iManagerM2000_CBSC_MATCH_ENG_V200R011C33SPC019.tar" -s ""E:\19\new\iManagerM20
00_CBSC_MATCH_CHS_V200R012C36SPC013_pkg.tar"" -a -r -o "E:\out"
*/
cout<<"start:>>>>>>>>>>>>>>>>>>>>>>>>"<<endl;
HANDLE s1;
TstuParam MyParam;
MyParam.name = "aaa";
MyParam.age = 12;
//通过线程去执行
s1 = CreateThread(NULL,0,TaskThreadExe,&MyParam,0,NULL);
cout<<"main thread is run:\r\n"<<endl;
::Sleep(4000);
CloseHandle(s1);
cout<<"main thread is end>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"<<endl;
char *ptr[5] = {"beijing", "shanghai", "tianjin", "chongqing","aaaaaaaa"};
int len = sizeof(ptr)/sizeof(ptr[0]);
char *ptr2[5];
for(int i=0; i<len; i++){
printf("aaaa:%s\r\n", ptr[i]);
ptr2[i] = ptr[i];
//printf("bbbb:%s\r\n", ptr2[i]);
}
cout<<">>>>>>>>>>>>>>>>>>>>>>>>"<<endl;
for(int i=0; i<len; i++){
printf("bbbb:%s\r\n", ptr2[i]);
}
cout<<len<<endl;
system("pause");
return 0;
}
void ExeCmd();
void ExecuteCmdCommand(const std::string &ToDoStr);
DWORD WINAPI TaskThreadExe(LPVOID lp)
{
cout<<">>>>>>>>>>>>>>>>>>>>>"<<endl;
TstuParam *myPara = (TstuParam *)lp;
std::string namet = myPara->name;
int aget = myPara->age;
//cout<<"姓名:"<<namet<<endl;
cout<<"年龄:"<<aget<<endl;
//cout<<"thread1 is running:\r\n"<<endl;
/* int i=0;
try
{
for (;i<2;i++)
{
cout<<"线程:>>>>>>>>>>>>>>>>>>>>>"<<i<<endl;
ExeCmd();
}
}
catch (...)
{
cout<<"出错了<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"<<i<<endl;
}
cout<<"thread is end<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"<<i<<endl;
*/
return 0;
}
void ExeCmd(){
//cout<<"线程:>>>>>>>>>>>>>>"<<endl;
std::string str = "\" \"E:\\Versioncheck\\iCAN V001R003 集成定制专用版本\\bin\\";
str += "VerCheckCmd.exe\" -b \"E:\\19\\base";
str += "\\iManagerM2000_CBSC_MATCH_ENG_V200R011C33SPC019.tar\" -s \"E:\\19\\new\\iManagerM2000_CBSC_MATCH_CHS_V200R012C36SPC013_pkg.tar\"";
str += " -c -f -p -r \"";
//str = "\" \"E:\\workProject\\VersionCheck\\集成\\Code\\debug\\VerCheckCmd.exe \"";
ExecuteCmdCommand(str);
//system(str.c_str());
}
void ExecuteCmdCommand(const std::string &ToDoStr)
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
ZeroMemory(&pi, sizeof(pi));
si.cb = sizeof(si);
si.dwFlags = STARTF_USESHOWWINDOW ;
si.wShowWindow = SW_HIDE;
std::string str("C:\\WINDOWS\\system32\\cmd.exe /c ");//+ToDoStr
str += ToDoStr;
//LPTSTR pSter = _T(str);
LPSTR pSter;
pSter = new char[str.length()+1];
::strcpy(pSter,str.c_str());
BOOL ret = CreateProcess(NULL, pSter, NULL, NULL, FALSE,0, NULL, NULL, &si, &pi);
//str.clear();
::WaitForSingleObject(pi.hProcess,INFINITE);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
return;
}
#include <Windows.h>
#include <iostream>
using std::cout;
using std::endl;
DWORD WINAPI TaskThreadExe(LPVOID lp);
typedef struct stuParam
{
std::string name;
int age;
}TstuParam;
int _tmain(int argc, _TCHAR* argv[])
{
/*
E:\Versioncheck\iCAN V001R003 集成定制专用版本\bin>VerCheckCmd.exe -b "E:\19\bas
e\iManagerM2000_CBSC_MATCH_ENG_V200R011C33SPC019.tar" -s ""E:\19\new\iManagerM20
00_CBSC_MATCH_CHS_V200R012C36SPC013_pkg.tar"" -a -r -o "E:\out"
*/
cout<<"start:>>>>>>>>>>>>>>>>>>>>>>>>"<<endl;
HANDLE s1;
TstuParam MyParam;
MyParam.name = "aaa";
MyParam.age = 12;
//通过线程去执行
s1 = CreateThread(NULL,0,TaskThreadExe,&MyParam,0,NULL);
cout<<"main thread is run:\r\n"<<endl;
::Sleep(4000);
CloseHandle(s1);
cout<<"main thread is end>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"<<endl;
char *ptr[5] = {"beijing", "shanghai", "tianjin", "chongqing","aaaaaaaa"};
int len = sizeof(ptr)/sizeof(ptr[0]);
char *ptr2[5];
for(int i=0; i<len; i++){
printf("aaaa:%s\r\n", ptr[i]);
ptr2[i] = ptr[i];
//printf("bbbb:%s\r\n", ptr2[i]);
}
cout<<">>>>>>>>>>>>>>>>>>>>>>>>"<<endl;
for(int i=0; i<len; i++){
printf("bbbb:%s\r\n", ptr2[i]);
}
cout<<len<<endl;
system("pause");
return 0;
}
void ExeCmd();
void ExecuteCmdCommand(const std::string &ToDoStr);
DWORD WINAPI TaskThreadExe(LPVOID lp)
{
cout<<">>>>>>>>>>>>>>>>>>>>>"<<endl;
TstuParam *myPara = (TstuParam *)lp;
std::string namet = myPara->name;
int aget = myPara->age;
//cout<<"姓名:"<<namet<<endl;
cout<<"年龄:"<<aget<<endl;
//cout<<"thread1 is running:\r\n"<<endl;
/* int i=0;
try
{
for (;i<2;i++)
{
cout<<"线程:>>>>>>>>>>>>>>>>>>>>>"<<i<<endl;
ExeCmd();
}
}
catch (...)
{
cout<<"出错了<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"<<i<<endl;
}
cout<<"thread is end<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"<<i<<endl;
*/
return 0;
}
void ExeCmd(){
//cout<<"线程:>>>>>>>>>>>>>>"<<endl;
std::string str = "\" \"E:\\Versioncheck\\iCAN V001R003 集成定制专用版本\\bin\\";
str += "VerCheckCmd.exe\" -b \"E:\\19\\base";
str += "\\iManagerM2000_CBSC_MATCH_ENG_V200R011C33SPC019.tar\" -s \"E:\\19\\new\\iManagerM2000_CBSC_MATCH_CHS_V200R012C36SPC013_pkg.tar\"";
str += " -c -f -p -r \"";
//str = "\" \"E:\\workProject\\VersionCheck\\集成\\Code\\debug\\VerCheckCmd.exe \"";
ExecuteCmdCommand(str);
//system(str.c_str());
}
void ExecuteCmdCommand(const std::string &ToDoStr)
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
ZeroMemory(&pi, sizeof(pi));
si.cb = sizeof(si);
si.dwFlags = STARTF_USESHOWWINDOW ;
si.wShowWindow = SW_HIDE;
std::string str("C:\\WINDOWS\\system32\\cmd.exe /c ");//+ToDoStr
str += ToDoStr;
//LPTSTR pSter = _T(str);
LPSTR pSter;
pSter = new char[str.length()+1];
::strcpy(pSter,str.c_str());
BOOL ret = CreateProcess(NULL, pSter, NULL, NULL, FALSE,0, NULL, NULL, &si, &pi);
//str.clear();
::WaitForSingleObject(pi.hProcess,INFINITE);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
return;
}