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. Pass paramters to an application while openning a file

Pass paramters to an application while openning a file

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestionhelp
5 Posts 3 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.
  • Y Offline
    Y Offline
    ytod
    wrote on last edited by
    #1

    Hi, everyone: I have a problem about how to open a document file with a specific application or pass some parameters into the application while opening the document file. For example: I need to open a .nrv file, a Nero file. But using ShellExecute() would always open Nero in traditional mode. I wanna open the .nrv file by Nero Express. I examine the shortcut of the Nero Express is like this: "C:\Program Files\Ahead\Nero\nero.exe" /w It looks like passing a parameter into the nero.exe, how can I do that through programming? Thanks!

    T 1 Reply Last reply
    0
    • Y ytod

      Hi, everyone: I have a problem about how to open a document file with a specific application or pass some parameters into the application while opening the document file. For example: I need to open a .nrv file, a Nero file. But using ShellExecute() would always open Nero in traditional mode. I wanna open the .nrv file by Nero Express. I examine the shortcut of the Nero Express is like this: "C:\Program Files\Ahead\Nero\nero.exe" /w It looks like passing a parameter into the nero.exe, how can I do that through programming? Thanks!

      T Offline
      T Offline
      ThatsAlok
      wrote on last edited by
      #2

      In ShellExecute

      HINSTANCE ShellExecute(
      HWND hwnd,
      LPCTSTR lpOperation,
      LPCTSTR lpFile,
      LPCTSTR lpParameters,
      LPCTSTR lpDirectory,
      INT nShowCmd
      );

      pass \W in lpParameters


      "I Think this Will Help"  Alok Gupta
       visit me at http://www.thisisalok.tk

      Y 1 Reply Last reply
      0
      • T ThatsAlok

        In ShellExecute

        HINSTANCE ShellExecute(
        HWND hwnd,
        LPCTSTR lpOperation,
        LPCTSTR lpFile,
        LPCTSTR lpParameters,
        LPCTSTR lpDirectory,
        INT nShowCmd
        );

        pass \W in lpParameters


        "I Think this Will Help"  Alok Gupta
         visit me at http://www.thisisalok.tk

        Y Offline
        Y Offline
        ytod
        wrote on last edited by
        #3

        But that would only execute Nero Express but not open the .nrv file if lpFile is passed with the path of nero.exe and lpParameters is passed with /w. On the other hand, if lpFile is passed with the path of the .nrv file, the parameter /w is ignored since it views .nrv file as a document file, as MSDN said. Actually it didn't work...:sigh: But thanks for your reply anyway...:) My code is like this: // csFilePath is a CString object which is equal to the path of the nero.exe // or the path of the .nrv file. ShellExecute(GetSafeHwnd(), NULL, csFilePath, "/w", NULL, SW_SHOWNORMAL);

        A T 2 Replies Last reply
        0
        • Y ytod

          But that would only execute Nero Express but not open the .nrv file if lpFile is passed with the path of nero.exe and lpParameters is passed with /w. On the other hand, if lpFile is passed with the path of the .nrv file, the parameter /w is ignored since it views .nrv file as a document file, as MSDN said. Actually it didn't work...:sigh: But thanks for your reply anyway...:) My code is like this: // csFilePath is a CString object which is equal to the path of the nero.exe // or the path of the .nrv file. ShellExecute(GetSafeHwnd(), NULL, csFilePath, "/w", NULL, SW_SHOWNORMAL);

          A Offline
          A Offline
          Anonymous
          wrote on last edited by
          #4

          I didn't check but what will happen if you attch your parameters right to the filename?

          1 Reply Last reply
          0
          • Y ytod

            But that would only execute Nero Express but not open the .nrv file if lpFile is passed with the path of nero.exe and lpParameters is passed with /w. On the other hand, if lpFile is passed with the path of the .nrv file, the parameter /w is ignored since it views .nrv file as a document file, as MSDN said. Actually it didn't work...:sigh: But thanks for your reply anyway...:) My code is like this: // csFilePath is a CString object which is equal to the path of the nero.exe // or the path of the .nrv file. ShellExecute(GetSafeHwnd(), NULL, csFilePath, "/w", NULL, SW_SHOWNORMAL);

            T Offline
            T Offline
            ThatsAlok
            wrote on last edited by
            #5

            ytod wrote: ShellExecute(GetSafeHwnd(), NULL, csFilePath, "/w", NULL, SW_SHOWNORMAL); Use it this way

            CString str;
            str.Format("/w %s",lpFileNameToOpen)

            then

            ShellExecute(GetSafeHwnd(), NULL, csFilePath,str, NULL, SW_SHOWNORMAL);


            "I Think this Will Help"
             Alok Gupta
             visit me at http://www.thisisalok.tk

            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