一、打开

1、WinExec("F:\\QQ\\Bin\\QQ.exe",SW_SHOW);

注意:'\'需要改成'\\',阻塞

2、

STARTUPINFO si;

PROCESS_INFORMATION pi;

ZeroMemory(&pi, sizeof(pi));

ZeroMemory(&si, sizeof(si));

si.cb = sizeof(si);

// Start the child process

if (CreateProcess(_T("C:\\测试部串口助手20161125.exe"), _T(""), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))

{

CloseHandle(pi.hProcess);

CloseHandle(pi.hThread);

}

else

{

AfxMessageBox(_T("创建失败!"));

HANDLE hProcess = GetCurrentProcess();//get current process

TerminateProcess(hProcess, 0); //close process

}//非阻塞

二、关闭

HWND hWnd = ::FindWindow(NULL, _T("content"));//conten是已开启的窗口标题,获得窗口句柄

::SendMessage(hWnd, WM_CLOSE, 0, 0);//发送关闭消息




长风破浪会有时,直挂云帆济沧海!