Advertisement
Advertisement
| 05.15.2008 at 03:46AM PDT, ID: 23404521 | Points: 200 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: |
long RunSAS(char* psScriptFile)
{
char sParams[2000];
long nRetVal = ERR_NONE;
SHELLEXECUTEINFO ShExecInfo;
SetLastError(0);
try
{
try
{
sprintf(sParams, "\"%s\" -nosplash", psScriptFile);
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_FLAG_DDEWAIT | SEE_MASK_NOCLOSEPROCESS | SEE_MASK_UNICODE;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = "open";
ShExecInfo.lpFile = "sas.exe";
ShExecInfo.lpParameters = sParams;
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_SHOWMINIMIZED;
ShExecInfo.hInstApp = NULL;
if(ShellExecuteEx(&ShExecInfo) == FALSE)
{
// Failed to call SAS
// TODO: Handle this error properly.
throw (long)GetLastError();
}
if(ShExecInfo.hProcess != NULL)
{
while(WaitForSingleObject(ShExecInfo.hProcess, 50) == WAIT_TIMEOUT)
{
;
}
// Closing process and thread handles
CloseHandle(ShExecInfo.hProcess);
}
throw ERR_NONE;
}
catch(long nErr)
{
throw nErr;
}
catch(...)
{
if(GetLastError() != 0)
{
throw (long)GetLastError();
}
throw ERR_SAS_RUN;
}
}
catch(long nErr)
{
nRetVal = nErr;
}
return nRetVal;
}
|