Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetOpenFileName workaround #17

Closed
therustmonk opened this issue Jul 25, 2016 · 1 comment
Closed

GetOpenFileName workaround #17

therustmonk opened this issue Jul 25, 2016 · 1 comment

Comments

@therustmonk
Copy link
Contributor

Windows case: It's not always possible to call COM's functions, because it can be failed or not available (for old win versions). How about to use old plain win API if COM failed with a workaround like this:

BOOL ShowOpenFileDialog(_Out_ LPTSTR szBuffer, _In_ UINT iBufferSize)
{
    IFileDialog *pfd = NULL;
    HRESULT hr = CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER, IID_IFileDialog, (void**)&pfd);
    if (SUCCEEDED(hr))
    {
        // use IFileDialog as needed...
        pfd->Release();
    }
    else
    {
        // use GetOpenFileName() as needed...
    }
}

I haven't found this approach in the library, but I think it should be useful. Your opinion?

@mlabbe
Copy link
Owner

mlabbe commented Aug 2, 2016

There is, explicitly, no support for Windows XP in Native File Dialog right now. (See the readme). This is due to the fact that I am not using OpenFileDialog et al., and instead am using a Vista-level API. Some versions of XP support it, and they won't crash, but there is no guarantee.

I would be open to a pull request that implements nfd_win_legacy.cpp which detects the windows version, and calls APIs that are guaranteed to exist on earlier versions of windows. It should be possible to route these at runtime, so every version of windows is served by Native File Dialog without a recompile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants