|
-
Jun 20th, 2001, 08:26 AM
#1
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
-
Jun 20th, 2001, 12:33 PM
#2
Frenzied Member
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.
MSVS 6, .NET & .NET 2003 Pro
I HATE MSDN with .NET & .NET 2003!!!
Check out my sites:
http://www.filthyhands.com
http://www.techno-coding.com

-
Jun 26th, 2001, 03:47 AM
#3
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|