by
allistar >> Fri, 10 Jan 2003 22:06:35 GMT
Hi Pillick,
If this preprocessing can be done on the server node then you could make a non-gui server application that executes the DOS application, if the database server is running as a service then you won't see anything pop up (this idea is no good if the processing is done on a client node).
An alternative, as you suggest, is to do this in C++. You could write a ...dll that executes the DOS command, something like this:
//the command would be passed into the dll as a char* (a String from Jade) char *fullCommand = (char*)malloc(MAX_PATH);
sprintf(fullCommand, "someApplication.exe -someParameter");
//++++++++++++++++++++++++++++++++++++++++++++++++++
//execute the command and redirect stdout and stderr
//++++++++++++++++++++++++++++++++++++++++++++++++++
SECURITY_ATTRIBUTES sa = {0};
STARTUPINFO si = {0};
PROCESS_INFORMATION pi = {0};
HANDLE hPipeOutputRead = NULL;
HANDLE hPipeOutputWrite = NULL;
HANDLE hPipeInputRead = NULL;
HANDLE hPipeInputWrite = NULL;
BOOL bTest = 0;
DWORD dwNumberOfBytesRead=0;
CHAR szMsg[100];
CHAR szBuffer[1000];
sa.nLength = sizeof(sa);
sa.bInheritHandle=TRUE;
sa.lpSecurityDescriptor=NULL;
//Create pipe for standard output redirection
CreatePipe(&hPipeOutputRead, &hPipeOutputWrite, &sa, 0);
//Create pipe for standard input redirection
CreatePipe(&hPipeInputRead, &hPipeInputWrite, &sa, 0);
//Make child process use hPipeOutputWrite as standard out and make sure // it does not show on screen
si.cb = sizeof(si);
si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
si.wShowWindow = SW_HIDE;
si.hStdInput = hPipeInputRead;
si.hStdOutput = hPipeOutputWrite;
si.hStdError = hPipeOutputWrite;
//spawn the application
CreateProcess(conspawn, fullCommand, NULL, NULL, true, 0, NULL, NULL , &si, &pi);
//now that handles have been inherited, close it to be safe.
//Don't want to read or write to them accidentally
CloseHandle(hPipeOutputWrite);
CloseHandle(hPipeInputRead);
This should work as an external function, you would pass into this the command for the application you want to run. Another bonus is that you can read from the input pipe to get the output of the application and then that can be passed back to Jade by causing an event (although that's a bit tricky in C++, you'll need to use the JOMAPI). You should at least read the input pipe to look for errors.
We use this methodolgy for executing jadloadb.exe from our automatic upgrading application (written in C++, but it shoul d work from Jade as well).
Hope this helps,
Allistar.
------------------------------------------------------------------
Allistar Melville
Software Developer, Analyst
allistar@silvermoon.co.nz
Auckland, NEW ZEALAND
Silvermoon Software
Specialising in JADE development and consulting
Visit us at:
http://www.silvermoon.co.nz ------------------------------------------------------------------