-
Problem with a DLL
Hello ...
Yesterday, I posted a question about a problem with one of our VB applications.
Today, we have localized the problem on a DLL which is called to creat a process. This DLL "eats" a handle each time the process is created, but does not free it after killing the process.
(This application is running on Windows NT4 server SP4)
Why ???
Here is the VC++ Code of the DLL :
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <winbase.h>
extern __declspec (dllexport) _int16 LancSync (HWND hWnd,
char * pszBatchName,
char * pszBatchParam,
_int16 iShowHow )
{
PROCESS_INFORMATION proc;
STARTUPINFO start;
int iReturnValue;
char szTmp[200];
GetStartupInfo (&start);
start.dwFlags = start.dwFlags | STARTF_USESHOWWINDOW;
start.wShowWindow = iShowHow;
sprintf(szTmp,"%s %s",pszBatchName,pszBatchParam);
iReturnValue = CreateProcessA(NULL, szTmp, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &start, &proc);
if (iReturnValue == 0 )
return -1;
iReturnValue = WaitForSingleObject(proc.hProcess, INFINITE);
CloseHandle(proc.hProcess);
return (0);
}
Thanks a lot.
Gab
-
I am going to take a stab at this but I am not exactly sure, but you might try using the function TerminateProcess insead of CloseHandle. This will destroy the process and all of its threads.
-
just a line is missed
I find the solution : at the end of the Dll code, ye have to put the line
CloseHandle(proc.hThread)
Thanks for all your help.
Gab