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. Managed C++/CLI
  4. Executing a programm from my application

Executing a programm from my application

Scheduled Pinned Locked Moved Managed C++/CLI
c++jsonquestionlearning
6 Posts 4 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.
  • M Offline
    M Offline
    Manfr3d
    wrote on last edited by
    #1

    Hello guys, I'm trying to execute a *.exe file from an own win api. Of course I looked through the internet but all i could find was ShellExecute() and CreateProcess() which, for any reason, don't work in VC++2008. Do I need to include any special library files or headers to get access to these functions, or is there another way to start a program from my win api? Thanks ans best wishes, Manfred

    L M 2 Replies Last reply
    0
    • M Manfr3d

      Hello guys, I'm trying to execute a *.exe file from an own win api. Of course I looked through the internet but all i could find was ShellExecute() and CreateProcess() which, for any reason, don't work in VC++2008. Do I need to include any special library files or headers to get access to these functions, or is there another way to start a program from my win api? Thanks ans best wishes, Manfred

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

      Hi, if you want to create a process, maybe you should read up on the Process class? :)

      Luc Pattyn [Forum Guidelines] [My Articles]


      Voting for dummies? No thanks. X|


      1 Reply Last reply
      0
      • M Manfr3d

        Hello guys, I'm trying to execute a *.exe file from an own win api. Of course I looked through the internet but all i could find was ShellExecute() and CreateProcess() which, for any reason, don't work in VC++2008. Do I need to include any special library files or headers to get access to these functions, or is there another way to start a program from my win api? Thanks ans best wishes, Manfred

        M Offline
        M Offline
        Mark Salsbery
        wrote on last edited by
        #3

        Austrian_Programmer wrote:

        Do I need to include any special library files or headers to get access to these functions

        ShellExecute() Header - shellapi.h Import library - shell32.lib CreateProcess() Header - Declared in Winbase.h; include Windows.h. Library - Use Kernel32.lib.

        M 1 Reply Last reply
        0
        • M Mark Salsbery

          Austrian_Programmer wrote:

          Do I need to include any special library files or headers to get access to these functions

          ShellExecute() Header - shellapi.h Import library - shell32.lib CreateProcess() Header - Declared in Winbase.h; include Windows.h. Library - Use Kernel32.lib.

          M Offline
          M Offline
          Manfr3d
          wrote on last edited by
          #4

          Thanks, but you need windows.h in both cases. I tried the ShellExecute() function with the included header and library, but nothing happens, the specified program didn't start. #pragma once #pragma comment(lib, "shell32.lib") #include #include // ... char *pcOp = "open"; char *pcPath = "calc.exe"; ShellExecute(NULL, (LPCWSTR)pcOp, (LPCWSTR)pcPath, NULL, NULL, SW_SHOWNORMAL); As I run this code I didn't get any error messages but nothing happened. What am I doing wrong?

          L M 2 Replies Last reply
          0
          • M Manfr3d

            Thanks, but you need windows.h in both cases. I tried the ShellExecute() function with the included header and library, but nothing happens, the specified program didn't start. #pragma once #pragma comment(lib, "shell32.lib") #include #include // ... char *pcOp = "open"; char *pcPath = "calc.exe"; ShellExecute(NULL, (LPCWSTR)pcOp, (LPCWSTR)pcPath, NULL, NULL, SW_SHOWNORMAL); As I run this code I didn't get any error messages but nothing happened. What am I doing wrong?

            L Offline
            L Offline
            led mike
            wrote on last edited by
            #5

            Austrian_Programmer wrote:

            As I run this code I didn't get any error messages but nothing happened. What am I doing wrong?

            What was the return value from ShellExecute?

            led mike

            1 Reply Last reply
            0
            • M Manfr3d

              Thanks, but you need windows.h in both cases. I tried the ShellExecute() function with the included header and library, but nothing happens, the specified program didn't start. #pragma once #pragma comment(lib, "shell32.lib") #include #include // ... char *pcOp = "open"; char *pcPath = "calc.exe"; ShellExecute(NULL, (LPCWSTR)pcOp, (LPCWSTR)pcPath, NULL, NULL, SW_SHOWNORMAL); As I run this code I didn't get any error messages but nothing happened. What am I doing wrong?

              M Offline
              M Offline
              Mark Salsbery
              wrote on last edited by
              #6

              Austrian_Programmer wrote:

              ShellExecute(NULL, (LPCWSTR)pcOp, (LPCWSTR)pcPath, NULL, NULL, SW_SHOWNORMAL); As I run this code I didn't get any error messages but nothing happened. What am I doing wrong?

              Casting char*s to wchar_t*s is not good. You shouldn't use casts unless absolutely necessary. If it doesn't compile without the casts, then I recommend looking at the types involved before covering the problem with a cast. Mark

              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