Update contrib.
1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Perl.cpp: allows running of a perl script and waiting for its completion.
19 #include "usbio.h" // USBIO Dev Kit
23 static char THIS_FILE[]=__FILE__;
27 // define the CreateProcess strings for Perl
28 #define APPNAME "C:\\Apps\\Perl\\Bin\\Perl.exe"
29 #define APPTITLE "Perl Script"
31 #define WAIT_SLEEP 1000 // checks for for perl script completion every second
32 #define EXIT_WAIT 900 // exits if not complete within 15 minutes
35 DWORD PerlScript(char * scriptName)
38 PROCESS_INFORMATION pi;
39 DWORD exitCode = STILL_ACTIVE;
41 ZeroMemory( &si, sizeof(si) );
43 ZeroMemory( &pi, sizeof(pi) );
45 if (!CreateProcess (APPNAME,scriptName,NULL,NULL,FALSE,0,NULL,NULL,&si,&pi))
46 return USBIO_ERR_INVALID_PROCESS;
48 for (int i = 0; i < EXIT_WAIT && exitCode == STILL_ACTIVE; i++)
51 GetExitCodeProcess(pi.hProcess,(LPDWORD)&exitCode);
54 // Force an unclean process termination only if necessary
55 if (exitCode == STILL_ACTIVE)
57 TerminateProcess(pi.hProcess,0);
58 return USBIO_ERR_TIMEOUT;