Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Using the windows shell "Open with" ....

Using the windows shell "Open with" ....

Scheduled Pinned Locked Moved C / C++ / MFC
helplinuxjsonquestion
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Phil Benson
    wrote on last edited by
    #1

    Hi there, I´ve looked through the Shell API doc´s and searched through the MSDN, but cannot find any doc´s about programmatically using/starting the "open with" dialog box. (i.e. right click on a file and choose open with, when double-clicking on a file that has no association, the open with dialog box appears) Here´s my problem... Using ::ShellExecuteEx(...) I´m opening a file (with the path, filename etc.), I get notification from ::ShellExecuteEx if the associated program was successfully started, or an error if no application is asscoiated with the particular file. On recieving this error, I woukd like to show the "Open with" dialog. Anyone got any ideas? Thanks in advance Phil bum... and I thought I´d got rid of all the bugs :(

    Who the F*** is general failure and why is he reading my hard drive?

    H 1 Reply Last reply
    0
    • P Phil Benson

      Hi there, I´ve looked through the Shell API doc´s and searched through the MSDN, but cannot find any doc´s about programmatically using/starting the "open with" dialog box. (i.e. right click on a file and choose open with, when double-clicking on a file that has no association, the open with dialog box appears) Here´s my problem... Using ::ShellExecuteEx(...) I´m opening a file (with the path, filename etc.), I get notification from ::ShellExecuteEx if the associated program was successfully started, or an error if no application is asscoiated with the particular file. On recieving this error, I woukd like to show the "Open with" dialog. Anyone got any ideas? Thanks in advance Phil bum... and I thought I´d got rid of all the bugs :(

      H Offline
      H Offline
      Hans Ruck
      wrote on last edited by
      #2

      Call

      ShellExecute(NULL, "open", "rundll32.exe", "shell32.dll, OpenAs_RunDLL <the_file>", NULL, SW_SHOW);

      where <the_file> is the file you need to open. If you know how to do it without calling rundll32.exe please let me know. All my attempts have ended in nasty failures :mad: rechi

      P 1 Reply Last reply
      0
      • H Hans Ruck

        Call

        ShellExecute(NULL, "open", "rundll32.exe", "shell32.dll, OpenAs_RunDLL <the_file>", NULL, SW_SHOW);

        where <the_file> is the file you need to open. If you know how to do it without calling rundll32.exe please let me know. All my attempts have ended in nasty failures :mad: rechi

        P Offline
        P Offline
        Phil Benson
        wrote on last edited by
        #3

        Thanks, I´ll try it out over the weekend. I suspect that using one of the shell32.dll exported functions that are not documented will do the job... but which one ???? Thanks again, I´ll let you know if I find another way Have a nice one Phil bum... and I thought I´d got rid of all the bugs :(

        Who the F*** is general failure and why is he reading my hard drive?

        H 1 Reply Last reply
        0
        • P Phil Benson

          Thanks, I´ll try it out over the weekend. I suspect that using one of the shell32.dll exported functions that are not documented will do the job... but which one ???? Thanks again, I´ll let you know if I find another way Have a nice one Phil bum... and I thought I´d got rid of all the bugs :(

          H Offline
          H Offline
          Hans Ruck
          wrote on last edited by
          #4

          Phil.B wrote: but which one ???? That's easy: OpenAs_RunDLL. The problem was to find out the function's prototype. Check this code:

          typedef void (CALLBACK *PRUNDLLOPENAS)(HWND, HINSTANCE, LPCWSTR, int);
          //...
          HMODULE h= LoadLibrary("shell32.dll");
          PRUNDLLOPENAS pOpenAs_RunDLL = (PRUNDLLOPENAS)GetProcAddress(h, "OpenAs_RunDLL");
          pOpenAs_RunDLL(hWnd, NULL, "<the_file>", SW_SHOWNORMAL);
          FreeLibrary(h);

          The best solution. :jig: rechi

          P 1 Reply Last reply
          0
          • H Hans Ruck

            Phil.B wrote: but which one ???? That's easy: OpenAs_RunDLL. The problem was to find out the function's prototype. Check this code:

            typedef void (CALLBACK *PRUNDLLOPENAS)(HWND, HINSTANCE, LPCWSTR, int);
            //...
            HMODULE h= LoadLibrary("shell32.dll");
            PRUNDLLOPENAS pOpenAs_RunDLL = (PRUNDLLOPENAS)GetProcAddress(h, "OpenAs_RunDLL");
            pOpenAs_RunDLL(hWnd, NULL, "<the_file>", SW_SHOWNORMAL);
            FreeLibrary(h);

            The best solution. :jig: rechi

            P Offline
            P Offline
            Phil Benson
            wrote on last edited by
            #5

            Thanks once again... another question, how did you manage to get the signature for the dll call, I had a look a the dll, and found all the documented calls, but the others were all with cardinal numbers. I used the depandancy walker, not exactly high-tech I know. Anyway, thanks once again Phil bum... and I thought I´d got rid of all the bugs :(

            Who the F*** is general failure and why is he reading my hard drive?

            H 1 Reply Last reply
            0
            • P Phil Benson

              Thanks once again... another question, how did you manage to get the signature for the dll call, I had a look a the dll, and found all the documented calls, but the others were all with cardinal numbers. I used the depandancy walker, not exactly high-tech I know. Anyway, thanks once again Phil bum... and I thought I´d got rid of all the bugs :(

              H Offline
              H Offline
              Hans Ruck
              wrote on last edited by
              #6

              This article[^] in MSDN explains it all. There's no way to tell the signature of the function using only the dll's binary. Actually, it could be possible but you have to disassembly the code and hack it a bit. The function prototype is, in fact, a convention regarding the arguments and the order they have to respect while filling the stack at call-time. rechi

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups