1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

ShellExecute can't open files that WinExplorer can

Discussion in 'MFC' started by hsifelbmur, Sep 20, 2006.

  1. hsifelbmur

    hsifelbmur New Member

    Joined:
    Sep 20, 2006
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    our application opens documents using shellexecute and the
    following code:

    lRet = ShellExecute(GetDesktopWindow(), sOperation, sFile, sArgs,
    sDirectory, sShowCMD)

    where...
    GetDesktopWindow = Windows API function that returns a handle to the
    desktop window
    sOperation = "open"
    sArgs = ""
    sDirectory = vbNullString
    sShowCMD = SW_SHOW = 5

    Lately we have been having a few problems with this code: After working with our app for a few hours, during which the above code works fine, suddenly one of the following problems starts. These problems are completely random and non-reproducible, and happen only on some computers (different clients):

    1. PDF documents just don't open: shellexecute returns 42 and does nothing. The same documents that don't open through our app open fine using Windows Explorer. When the close our app and re-start it everything works fine again.

    2. HTML documents don't open either: shellexecute returns FILE_NOT_FOUND, even through the files exist and open fine using Windows Explorer. When the close our app and re-start it everything works fine again.

    3. Word documents open fine, but for some reason, if we make changes to them and close Word, it doesn't prompt us to save. Some users have reports saving these documents (through Word - without our app's intervention), and seeing later that they were not saved. Needless to say, while this problems goes on with our app, the same documents open fine from Windows Explorer. When the close our app and re-start it everything works fine again.

    We have looked everywhere and couldn't find an answer. Someone recommended passing NULL instead of GetDesktopWindow but this did not help.

    Has anyone encountered this before?
     

Share This Page