How to get list of selected files when using GetOpenFileName() with multiselect flag?

后端 未结 5 903
予麋鹿
予麋鹿 2021-01-15 19:20

I have tried googling, but people seem to have the same problem: we can\'t get a list of the selected files.

This is a simple piece of working code that is similar t

5条回答
  •  自闭症患者
    2021-01-15 19:43

    Try this:

    wchar_t file[1025] = {0}; // room for an extra null terminator, just in case
    ...
    ofn.nMaxFile = 1024;
    ...
    wchar_t* ptr = ofn.lpstrFile;
    ptr[ofn.nFileOffset-1] = 0;
    std::wcout << L"Directory: " << ptr << std::endl;
    ptr += ofn.nFileOffset;
    while (*ptr)
    {
        std::wcout << L"File: " << ptr << std::endl;
        ptr += (lstrlenW(ptr)+1);
    }
    

提交回复
热议问题