/***************************************************************************** FUNCTION NAME : VeriStand Exit. DESCRIPTION : Exit the VeriStand Application. PARAMETERS DESCRIPTION : pcBuffer - ptr to char string containing error description. Return Value : HRESULT: 0 = Success, Non-Zero = Failure. ******************************************************************************/ int CviVeristandExit() { int IStatus = 0; /*IStatus =Close_NationalInstruments_VeriStand (); if (IStatus != 0 ) { strcpy (pcBuffer, "Close_VeriStand"); return IStatus; } IStatus =Close_NationalInstruments_VeriStand_APIInterface (); if (IStatus != 0 ) { strcpy (pcBuffer, "Close_APIInterface"); return IStatus; }*/ IStatus = Close_NationalInstruments_VeriStand_ClientAPI (); if (IStatus != 0 ) { strcpy (pcBuffer, "Close_ClientAPI"); return IStatus; } CDotNetDiscardHandle(instance_handle); CDotNetDiscardHandle(VSworkspace2_Handle); CDotNetDiscardHandle(IProject_Handle); CDotNetDiscardHandle(IModel_Handle); CDotNetDiscardHandle(VSchannelfault_Handle); CDotNetDiscardHandle(exception_Handle); TerminateExecutable (VSHandle); RetireExecutableHandle (VSHandle); return IStatus; }
////////////////////////////////////////////////////////////////////selfdefined function////////////////////////////////////// static int ExecutableProcess(char *cmd, char *checkpoint) { FILE *hFile; char buffer[300]; // long enough for single line of output from ipconfig char tempFileName[L_tmpnam]; char command[L_tmpnam + 25]; int hProc; int res=0; int checkflag = 0; tmpnam(tempFileName); sprintf(command, "cmd.exe /C %s > %s", cmd,tempFileName); // sprintf(command, "cmd.exe /C %s", cmd); // if (LaunchExecutableEx(command, LE_SHOWNORMAL, &hProc) >= 0) if (LaunchExecutableEx(command, LE_HIDE, &hProc) >= 0) { SetLed("running...please wait...",0); ProcessSystemEvents (); WriteLog(); ResetTextBox (panelHandle, PANEL_TEXTBOX, ""); while (!ExecutableHasTerminated(hProc)); { RetireExecutableHandle(hProc); } if (hFile = fopen(tempFileName, "r")) { while (fgets(buffer, (int)sizeof(buffer), hFile)) { SetCtrlVal (panelHandle, PANEL_TEXTBOX, buffer); if (!checkflag) { if(NULL != strstr (buffer, checkpoint)) { checkflag = 1; res = 1; } } } fclose(hFile); // DeleteFile(tempFileName); remove (tempFileName); } } return res; }
void KillSubprocess(void) { char command[300]; int hProc; memset(command,0,300); strcpy(command,"cmd.exe /C TASKKILL /F /IM RemoteAction.exe"); if (LaunchExecutableEx(command, LE_HIDE, &hProc) >= 0) { WriteLog(); while (!ExecutableHasTerminated(hProc)); { RetireExecutableHandle(hProc); } } }