Results 1 to 3 of 3

Thread: Problem with a DLL

  1. #1
    Gab
    Guest

    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

  2. #2
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    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


  3. #3
    Gab
    Guest

    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
  •  



Click Here to Expand Forum to Full Width