LocalFree(lpErrorMsg);这句话会报以上那个错误

解决方案 »

  1.   

    LZ跟踪一下看看lpErrorMsg是不是一个有效的值。
      

  2.   

    看看流程,你把if里面的LocalFree去掉就行了。
      

  3.   

    这估计是在启动另一个进程时参数用的有问题。
    以下这段代码是启动一个进程并等待其结束,你参考一下:    STARTUPINFO si;
        PROCESS_INFORMATION pi;    ZeroMemory( &si, sizeof(si) );
        si.cb = sizeof(si);
        ZeroMemory( &pi, sizeof(pi) );    // Start the child process. 
        if( !CreateProcess( NULL,   // No module name (use command line). 
            TEXT("MyChildProcess"), // Command line. 
            NULL,             // Process handle not inheritable. 
            NULL,             // Thread handle not inheritable. 
            FALSE,            // Set handle inheritance to FALSE. 
            0,                // No creation flags. 
            NULL,             // Use parent's environment block. 
            NULL,             // Use parent's starting directory. 
            &si,              // Pointer to STARTUPINFO structure.
            &pi )             // Pointer to PROCESS_INFORMATION structure.
        ) 
        {
            printf( "CreateProcess failed (%d).\n", GetLastError() );
            return;
        }    // Wait until child process exits.
        WaitForSingleObject( pi.hProcess, INFINITE );    // Close process and thread handles. 
        CloseHandle( pi.hProcess );
        CloseHandle( pi.hThread );
      

  4.   

    FORMAT_MESSAGE_ALLOCATE_BUFFER有系统分配内存,由系统释放。
    LPTSTR lpErrorMsg = (LPTSTR)LocalAlloc(LHND,appendMsgLen+errorMsgLen+sizeof(TCHAR)*2);
    //这句都多余