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. WPF
  4. ShellExecute in WPF

ShellExecute in WPF

Scheduled Pinned Locked Moved WPF
questioncsharpwpfhelptutorial
9 Posts 3 Posters 1 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
    pix_programmer
    wrote on last edited by
    #1

    Hi! What is the namespace to include for ShellExecute to compile? I've to open a URL from WPF Emulator. How to do this? I tried

    Process.Start()

    But it opens many times. ShellExecute() doesn't compile. It gives the following error: The name 'ShellExecute' does not exist in the current context How to open a URL in WPF?

    P 1 Reply Last reply
    0
    • P pix_programmer

      Hi! What is the namespace to include for ShellExecute to compile? I've to open a URL from WPF Emulator. How to do this? I tried

      Process.Start()

      But it opens many times. ShellExecute() doesn't compile. It gives the following error: The name 'ShellExecute' does not exist in the current context How to open a URL in WPF?

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      I just use Process.Start to open a URL. Here's an example from the code I'm looking at right now:

      public static void OpenUrl(string url)
      {
      if (string.IsNullOrWhitespace(url))
      throw new ArgumentNullException("url");
      Process.Start(url);
      }

      *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

      "Mind bleach! Send me mind bleach!" - Nagy Vilmos

      CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

      P 1 Reply Last reply
      0
      • P Pete OHanlon

        I just use Process.Start to open a URL. Here's an example from the code I'm looking at right now:

        public static void OpenUrl(string url)
        {
        if (string.IsNullOrWhitespace(url))
        throw new ArgumentNullException("url");
        Process.Start(url);
        }

        *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

        "Mind bleach! Send me mind bleach!" - Nagy Vilmos

        CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

        P Offline
        P Offline
        pix_programmer
        wrote on last edited by
        #3

        Pete O'Hanlon wrote: Process.Start(url); I've used this. It's opening the URL many times. I want only one time. How to do this? What about ShellExecute with WPF?

        P 1 Reply Last reply
        0
        • P pix_programmer

          Pete O'Hanlon wrote: Process.Start(url); I've used this. It's opening the URL many times. I want only one time. How to do this? What about ShellExecute with WPF?

          P Offline
          P Offline
          Pete OHanlon
          wrote on last edited by
          #4

          It only opens it once per execution - sounds like you're hooked into calling that many times - and you would have to write interop code for ShellExecute, where you'd still get the same issue. Put a breakpoint on your Process.Start code and see how many times it's being called.

          *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

          "Mind bleach! Send me mind bleach!" - Nagy Vilmos

          CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

          P 1 Reply Last reply
          0
          • P Pete OHanlon

            It only opens it once per execution - sounds like you're hooked into calling that many times - and you would have to write interop code for ShellExecute, where you'd still get the same issue. Put a breakpoint on your Process.Start code and see how many times it's being called.

            *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

            "Mind bleach! Send me mind bleach!" - Nagy Vilmos

            CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

            P Offline
            P Offline
            pix_programmer
            wrote on last edited by
            #5

            Hi! I've to change the state of the application to minimized before opening the URL. I'm using this code.

            #if WINDOWS
            this.WindowState = WindowState.Minimized;
            #endif

            But it shows the following error: The name 'WindowState' does not exist in the current context How to minimze the application before opening the URL?

            L P 2 Replies Last reply
            0
            • P pix_programmer

              Hi! I've to change the state of the application to minimized before opening the URL. I'm using this code.

              #if WINDOWS
              this.WindowState = WindowState.Minimized;
              #endif

              But it shows the following error: The name 'WindowState' does not exist in the current context How to minimze the application before opening the URL?

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              You may need to use the FormWindowState enumeration as described here[^].

              Programming is work, it isn't finger painting. Luc Pattyn

              P 1 Reply Last reply
              0
              • P pix_programmer

                Hi! I've to change the state of the application to minimized before opening the URL. I'm using this code.

                #if WINDOWS
                this.WindowState = WindowState.Minimized;
                #endif

                But it shows the following error: The name 'WindowState' does not exist in the current context How to minimze the application before opening the URL?

                P Offline
                P Offline
                Pete OHanlon
                wrote on last edited by
                #7

                I assume you're not trying this from the main window (or from the code of any window in your application) then. To minimize the main window from another location, try:

                App.Current.MainWindow.WindowState = System.Windows.WindowState.Minimized

                *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

                "Mind bleach! Send me mind bleach!" - Nagy Vilmos

                CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

                1 Reply Last reply
                0
                • L Lost User

                  You may need to use the FormWindowState enumeration as described here[^].

                  Programming is work, it isn't finger painting. Luc Pattyn

                  P Offline
                  P Offline
                  Pete OHanlon
                  wrote on last edited by
                  #8

                  I don't think that's the problem - this error would indicate he's trying to use the minimize function from a piece of none-window code.

                  *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

                  "Mind bleach! Send me mind bleach!" - Nagy Vilmos

                  CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

                  L 1 Reply Last reply
                  0
                  • P Pete OHanlon

                    I don't think that's the problem - this error would indicate he's trying to use the minimize function from a piece of none-window code.

                    *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

                    "Mind bleach! Send me mind bleach!" - Nagy Vilmos

                    CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #9

                    I Agree; it's actually not clear which of the references is out of context.

                    Programming is work, it isn't finger painting. Luc Pattyn

                    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