Hello all,

I have a VB.net application and a C++ DLL.
The C++ DLL has an exported function that gets called by the VB.net application.

The C++ exported function is as following:

STARTUPINFO         si;
    PROCESS_INFORMATION pi;

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

    TR::Log( "Starting ( %s )", m_fullPath.c_str() );

    // Start the child process.
     if( ! CreateProcess( const_cast<LPCSTR>(m_fullPath.c_str()), // filename of the process
        NULL,		// command line arguments if present
        NULL,             // Process handle not inheritable.
        NULL,             // Thread handle not inheritable.
        FALSE,            // Set handle inheritance to FALSE.
        DETACHED_PROCESS, // debug the process, but not spawned off childs
        NULL,             // Use parent's environment block.
        NULL,             // Use parent's starting directory.
        &si,              // Pointer to STARTUPINFO structure.
        &pi )             // Pointer to PROCESS_INFORMATION structure.
        )
    {
        TR::Log( "CreateProcess failed (%d).\n", GetLastError() );
        return;
    }
    CloseHandle(pi.hProcess);
    CloseHandle(pi.hThread);

    m_hProcess      = pi.hProcess;

    m_dwProcessID   = pi.dwProcessId;
    TR::Log( "PID %i", m_dwProcessID );

The logfile contains:

Starting ( C:\testMe.exe )
PID 1356

So it would seems everything is working(as we have a PID and CreateProcess does not fail). But the application's window does not show up(tried both with Console application and normal application) and the PID is not visible in the task manager.
Besides the application I run a driver that registered a 'Process Create Notify'. This notification routine gets called with the same PID.

I added a messagebox in the DLL's main: The DLL is initialized before CreateProcess is called. I also tried, in the DLL, to create a thread the calls the function with CreateProcesss just to be sure.

I also tried several different dwCreationFlags in CreateProcess, like CREATE_NEW_CONSOLE and just '0' etc.

Never mind, issue has been resolved by using a different design.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.