Search code examples
windows-7windows-xpfileopendialog

Different file open dialog boxes on Windows XP, Windows Vista and Windows 7


I want to develop an application that works on all three versions of Windows XP, Vista and 7. The application allows people to select files to open and allows them to save the files after some operations. Each of the three versions of Windows has a different style of File open dialog boxes. While XP uses GetOpenFileName with OPENFILENAME structure, it is suggested that we use a "Common File Dialog" with Vista and Windows 7. I can get the file dialog in the suggested style to work for each different version of the OS. However, I would like to make sure that my application opens different styles of dialog box on each version. I do not want to build separate binary for different versions of Windows.

Is it possible to have this logic built-in the application i.e. to allow it to access native open file dialog based on which OS the application is being run.

Thanks,

Abhijit


Solution

  • You're going to have to do something like

    if (isVista())
    {
        //Use IFileDialog
    }
    else
    {
        //Use GetOpenFileName
    }
    

    Note:

    You can't do this if you'll be customizing the dialog; you'll have to use the old version.

    Try delay-loading the DLL: