OPENFILENAME



  • Ich hab das Problem das sich der FileDialog einfach nicht öffnen will.
    Mit GetLastError() hab ich als Errorcode "87 = ERROR_INVALID_PARAMETER" rausbekommen. Allerdings find ich den fehler nicht.
    So siehts bis jetzt aus:

    OPENFILENAME ofn;       
    char szFilePath[260];       
    HWND hWnd = 0;                           
    
    ZeroMemory(&ofn, sizeof(OPENFILENAME));
    ofn.lStructSize = sizeof(OPENFILENAME);
    ofn.hwndOwner = hWnd;
    ofn.lpstrFile = szFilePath;
    ofn.nMaxFile = sizeof(szFilePath);
    ofn.lpstrFilter = "Executable\0*.exe\0";
    ofn.nFilterIndex = 1;
    ofn.lpstrFileTitle = NULL;
    ofn.nMaxFileTitle = 0;
    ofn.lpstrInitialDir = NULL;
    ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
    
    if (GetOpenFileName(&ofn) == TRUE)
    {
    	cout << szFilePath;
    }
    


  • Setz das Array szFilePath auf 0. Das sollte helfen.

    char szFilePath[260]={0};
    


  • Danke, danach hab ich garnicht geguckt 😃


Anmelden zum Antworten