CreateProcessA Problem



  • Hallo

    #include <iostream>
    #include <windows>
    
    int main(int argc, char* argv[])
    {
    LPCSTR lpCmdLine = "File.exe";
    UINT uCmdShow = 0;
    
         STARTUPINFOA StartupInfo;
         PROCESS_INFORMATION  ProcessInformation;
         DWORD dosErr;
    
         RtlZeroMemory(&StartupInfo, sizeof(StartupInfo));
         StartupInfo.cb = sizeof(STARTUPINFOA);
         StartupInfo.wShowWindow = (WORD)uCmdShow;
         StartupInfo.dwFlags = 0;
    
         CreateProcessA(NULL, (PVOID)lpCmdLine,
                             NULL,
                             NULL,
                             FALSE,
                             0,
                             NULL,
                             NULL,
                             &StartupInfo,
                             &ProcessInformation );
    
            return 0;
    }
    

    Was ist hier dran falsch ? &ProcessInformation

    [C++ Fehler] Unit1.cpp(27): E2034 Konvertierung von 'void *' nach 'char *' nicht möglich

    Laut MSDN darf der 2te Parameter NULL sein.

    [C++ Fehler] Unit1.cpp(27): E2342 Keine Übereinstimmung des Typs beim Parameter 'lpCommandLine' ('char *' erwartet, 'void *' erhalten)



  • An "&ProcessInformation" ist nichts falsch, lass den Cast beim 2. Parameter einfach weg. Dann wird dir wahrscheinlich auch mitgeteilt, dass CreateProcessA einen char* (LPSTR) und keinen const char* (LPCSTR) erwartet.

    char lpCmdLine[] = "File.exe";
    


  • Was ist hieran unverständlich?

    _< schrieb:
    [C++ Fehler] Unit1.cpp(27): E2342 Keine Übereinstimmung des Typs beim Parameter 'lpCommandLine' ('char *' erwartet, 'void *' erhalten)

    Du übergibst
    (PVOID)lpCmdLine
    einen void - Pointer, die Funktion hätte aber gerne einen char - Pointer.


Anmelden zum Antworten