C6335C6335

avertissement C6335 : handle d’informations de processus <handlename >warning C6335: leaking process information handle <handlename>

Cet avertissement indique que les handles d’informations de processus retournées par la famille de fonctions CreateProcess doivent être fermés à l’aide de CloseHandle.This warning indicates that the process information handles returned by the CreateProcess family of functions need to be closed using CloseHandle. Cela entraîne des fuites du handle.Failure to do so will cause handle leaks.

ExempleExample

Le code suivant génère cet avertissement :The following code generates this warning:

#include <windows.h>
#include <stdio.h>

void f( )
{
    STARTUPINFO si;
    PROCESS_INFORMATION pi;

    ZeroMemory( &si, sizeof(si) );
    si.cb = sizeof(si);
    ZeroMemory( &pi, sizeof(pi) );

    // Start the child process.
    if( !CreateProcess( "C:\\WINDOWS\\system32\\calc.exe",
                        NULL,
                        NULL,
                        NULL,
                        FALSE,
                        0,
                        NULL,
                        NULL,
                        &si,    // Pointer to STARTUPINFO structure.
                        &pi ) ) // Pointer to PROCESS_INFORMATION
  {
    puts("Error");
    return;
  }
    // Wait until child process exits.
    WaitForSingleObject( pi.hProcess, INFINITE );
    CloseHandle( pi.hProcess );
}

Pour corriger cet avertissement, appelez CloseHandle (pi.``hThread) pour fermer le handle de thread comme indiqué dans le code suivant :To correct this warning, call CloseHandle (pi.``hThread) to close thread handle as shown in the following code:

#include <windows.h>
#include <stdio.h>

void f( )
{
    STARTUPINFO si;
    PROCESS_INFORMATION pi;

    ZeroMemory( &si, sizeof(si) );
    si.cb = sizeof(si);
    ZeroMemory( &pi, sizeof(pi) );

    // Start the child process.
    if( !CreateProcess( "C:\\WINDOWS\\system32\\calc.exe",
                        NULL,
                        NULL,
                        NULL,
                        FALSE,
                        0,
                        NULL,
                        NULL,
                        &si,    // Pointer to STARTUPINFO structure.
                        &pi ) ) // Pointer to PROCESS_INFORMATION
    {
      puts("Error");
      return;
    }

    // Wait until child process exits.
    WaitForSingleObject( pi.hProcess, INFINITE );
    CloseHandle( pi.hProcess );
    CloseHandle( pi.hThread );
}

Pour plus d’informations, consultez fonction CreateProcess et fonction CloseHandle.For more information, see CreateProcess Function and CloseHandle Function.