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. Passing parameter through ShellExecute

Passing parameter through ShellExecute

Scheduled Pinned Locked Moved C / C++ / MFC
jsonhelptutorialquestion
4 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.
  • N Offline
    N Offline
    neha agarwal27
    wrote on last edited by
    #1

    Hi all, I want to pass a CString parameter through ShellExecute() api to my exe.. I am doing this using this code:-

    CString CurrentPath = _T("C:\\test\\test.ini");
    ShellExecute(NULL,_T("open"),CurrentPath,NULL,NULL,SW_SHOW);

    My problem is i don't know how to access this parameter in my exe. Can anybody tell me how to do so?? Thanks in advance

    C 1 Reply Last reply
    0
    • N neha agarwal27

      Hi all, I want to pass a CString parameter through ShellExecute() api to my exe.. I am doing this using this code:-

      CString CurrentPath = _T("C:\\test\\test.ini");
      ShellExecute(NULL,_T("open"),CurrentPath,NULL,NULL,SW_SHOW);

      My problem is i don't know how to access this parameter in my exe. Can anybody tell me how to do so?? Thanks in advance

      C Offline
      C Offline
      CPallini
      wrote on last edited by
      #2

      I see no exe in the above code. :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

      N 1 Reply Last reply
      0
      • C CPallini

        I see no exe in the above code. :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

        N Offline
        N Offline
        neha agarwal27
        wrote on last edited by
        #3

        sorry i posted wrong code

        CString CurrentPath = _T("C:\\test.exe");
        CString para = _T("c:\\test.ini");
        ShellExecute(NULL,_T("open"),CurrentPath,para ,NULL,SW_SHOW);

        what i want is i want to access para value in my test.exe code

        L 1 Reply Last reply
        0
        • N neha agarwal27

          sorry i posted wrong code

          CString CurrentPath = _T("C:\\test.exe");
          CString para = _T("c:\\test.ini");
          ShellExecute(NULL,_T("open"),CurrentPath,para ,NULL,SW_SHOW);

          what i want is i want to access para value in my test.exe code

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          Hi, it depends on language and compiler. Most often you can get the command line as a string and/or the command line parts as a string array; look for: - the (optional) arguments of your main or WinMain function; - a library function such as GetCommandLine. BTW: When an array is returned, most likely the first element is the path of the EXE itself. :)

          Luc Pattyn [Forum Guidelines] [My Articles]


          This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.


          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