Calling GetOpenFileName without internally opening the file RRS feed

  • Question

  • Hi!

    I need to call the GetOpenFileName Win32 API but the problem is that this API internally opens the file before returning the selected file path. So, the real problem is that if the user has OneDrive for Business Desktop installed (the utility that shows the OneDrive for BI files in the local file system), and that user selects a file that was not yet locally synchronized (it exists in the server but not locally showing a white cloud), then if the file is for example 10 GB, OneDrive will first download 10 GB for this file (because it detects that an application internally called the CreateFile API and it synchronizes it) and finally GetOpenFileName will return the file path. This is clearly a big problem since I only need the path, I don't need the file to get downloaded.

    I tested with all the possible flags (including the FlagsEx) but non of them prevented the file from being downloaded. I also tested using the OFN_ENABLEHOOK flag and when the CDN_FILEOK event gets called the file is already downloaded

    Contrary to the GetOpenFileName API, if I use the IFileOpenDialog COM interface, and if I specify the FOS_SUPPORTSTREAMABLEITEMS flag, the file does not get downloaded (because it does not get opened). The problem is that I cannot use this interface.

    Any help will be useful.


    Tuesday, July 14, 2020 1:14 PM

All replies

  • Hi,

    Thanks for posting here.

    According to the document GetOpenFileName: [Starting with Windows Vista, the Open and Save As common dialog boxes have been superseded by the Common Item Dialog. We recommended that you use the Common Item Dialog API instead of these dialog boxes from the Common Dialog Box Library.] Such as the IFileOpenDialog you've metioned. 

    The problem is that I cannot use this interface.

    Could you please share the reason that you cannot use this interface, is that you are developing on an earlier window than Windows Vista? 

    This “General Windows Desktop Development Issues” Forum will be migrating to a new home on Microsoft Q&A, please refer to this sticky post for more details. 

    Best Regards,


    "Win32 API" forum will be migrating to a new home on Microsoft Q&A !
    We invite you to post new questions in the "Win32 API" forum’s new home on Microsoft Q&A !
    For more information, please refer to the sticky post.

    Wednesday, July 15, 2020 7:26 AM