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. ShellExecute(...)

ShellExecute(...)

Scheduled Pinned Locked Moved C / C++ / MFC
question
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.
  • R Offline
    R Offline
    Raphael Kindt
    wrote on last edited by
    #1

    Hi world, Does the ShellExecute function works in a console application? The first argument of the ShellExecute function is the Handle to a parent window... but a consol application doesn't have window handle!!! I only want a solution for running an application (exe with argument) in a console application!? What's the simplest solution? Hello World!!! :) from Raphaël

    R J P 3 Replies Last reply
    0
    • R Raphael Kindt

      Hi world, Does the ShellExecute function works in a console application? The first argument of the ShellExecute function is the Handle to a parent window... but a consol application doesn't have window handle!!! I only want a solution for running an application (exe with argument) in a console application!? What's the simplest solution? Hello World!!! :) from Raphaël

      J Offline
      J Offline
      Joseph Dempsey
      wrote on last edited by
      #2

      yes it works. While a console has now window you can do one of two things: 1) pass NULL, 2) pass the result of ::GetDesktopWindow(). The only thing that HWND is for is act as the parent window for any other windows that come up as result of your execution. If what you are executing has no windows it doesn't matter all. If it does they will just be directed to the desktop. Hope that helps. Joseph Dempsey joseph_r_dempsey@yahoo.com "Software Engineering is a race between the programmers, trying to make bigger and better fool-proof software, and the universe trying to make bigger fools. So far the Universe in winning." --anonymous

      R 1 Reply Last reply
      0
      • R Raphael Kindt

        Hi world, Does the ShellExecute function works in a console application? The first argument of the ShellExecute function is the Handle to a parent window... but a consol application doesn't have window handle!!! I only want a solution for running an application (exe with argument) in a console application!? What's the simplest solution? Hello World!!! :) from Raphaël

        R Offline
        R Offline
        Raphael Kindt
        wrote on last edited by
        #3

        OK... I've found the solution by myself... simply use NULL for the first argument of ShellExecute Hello World!!! :) from Raphaël

        1 Reply Last reply
        0
        • J Joseph Dempsey

          yes it works. While a console has now window you can do one of two things: 1) pass NULL, 2) pass the result of ::GetDesktopWindow(). The only thing that HWND is for is act as the parent window for any other windows that come up as result of your execution. If what you are executing has no windows it doesn't matter all. If it does they will just be directed to the desktop. Hope that helps. Joseph Dempsey joseph_r_dempsey@yahoo.com "Software Engineering is a race between the programmers, trying to make bigger and better fool-proof software, and the universe trying to make bigger fools. So far the Universe in winning." --anonymous

          R Offline
          R Offline
          Raphael Kindt
          wrote on last edited by
          #4

          Thanks for your reply... (I've replied to myself too :) ) Hello World!!! :) from Raphaël

          1 Reply Last reply
          0
          • R Raphael Kindt

            Hi world, Does the ShellExecute function works in a console application? The first argument of the ShellExecute function is the Handle to a parent window... but a consol application doesn't have window handle!!! I only want a solution for running an application (exe with argument) in a console application!? What's the simplest solution? Hello World!!! :) from Raphaël

            P Offline
            P Offline
            Peter Weyzen
            wrote on last edited by
            #5

            I am not sure how correct this is, but when I don't have my own window I often use GetDesktopWindow().

            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