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. String Error using ShellExecute() in vs.net 2005

String Error using ShellExecute() in vs.net 2005

Scheduled Pinned Locked Moved C / C++ / MFC
csharpvisual-studiodata-structureshelp
8 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.
  • C Offline
    C Offline
    CNewbie
    wrote on last edited by
    #1

    I am getting an error on this line: ShellExecute(NULL,NULL,"Cisco CCNP Exam 642-801\\cd1\\CBTNuggetPlayer.exe",NULL,"",SW_SHOWDEFAULT); and the error is: error C2664: 'ShellExecuteW' : cannot convert parameter 3 from 'const char [48]' to 'LPCWSTR' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast I am using a relative path as my program will be executed from the root of a CD and will attempt to open a file 2 layer down the directory tree. thanks

    H N T 3 Replies Last reply
    0
    • C CNewbie

      I am getting an error on this line: ShellExecute(NULL,NULL,"Cisco CCNP Exam 642-801\\cd1\\CBTNuggetPlayer.exe",NULL,"",SW_SHOWDEFAULT); and the error is: error C2664: 'ShellExecuteW' : cannot convert parameter 3 from 'const char [48]' to 'LPCWSTR' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast I am using a relative path as my program will be executed from the root of a CD and will attempt to open a file 2 layer down the directory tree. thanks

      N Offline
      N Offline
      Nibu babu thomas
      wrote on last edited by
      #2

      CNewbie wrote:

      ShellExecute(NULL,NULL,"Cisco CCNP Exam 642-801\\cd1\\CBTNuggetPlayer.exe",NULL,"",SW_SHOWDEFAULT);

      ShellExecute(NULL, NULL, _T("Cisco CCNP Exam 642-801\\cd\\CBTNuggetPlayer.exe"), NULL, _T(""), SW_SHOWDEFAULT);


      Nibu thomas Software Developer

      C 1 Reply Last reply
      0
      • C CNewbie

        I am getting an error on this line: ShellExecute(NULL,NULL,"Cisco CCNP Exam 642-801\\cd1\\CBTNuggetPlayer.exe",NULL,"",SW_SHOWDEFAULT); and the error is: error C2664: 'ShellExecuteW' : cannot convert parameter 3 from 'const char [48]' to 'LPCWSTR' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast I am using a relative path as my program will be executed from the root of a CD and will attempt to open a file 2 layer down the directory tree. thanks

        H Offline
        H Offline
        HOW WHAT
        wrote on last edited by
        #3

        TEXT("Cisco CCNP Exam 642-801\\cd1\\CBTNuggetPlayer.exe") or _T("Cisco CCNP Exam 642-801\\cd1\\CBTNuggetPlayer.exe")

        1 Reply Last reply
        0
        • N Nibu babu thomas

          CNewbie wrote:

          ShellExecute(NULL,NULL,"Cisco CCNP Exam 642-801\\cd1\\CBTNuggetPlayer.exe",NULL,"",SW_SHOWDEFAULT);

          ShellExecute(NULL, NULL, _T("Cisco CCNP Exam 642-801\\cd\\CBTNuggetPlayer.exe"), NULL, _T(""), SW_SHOWDEFAULT);


          Nibu thomas Software Developer

          C Offline
          C Offline
          CNewbie
          wrote on last edited by
          #4

          Thanks that fixed the errors and taught me something :). Now it opens CBTNuggetPlayer.exe like it is supposed to but then it closes right away. No Window or anything. Why would that happen? Thanks

          N 1 Reply Last reply
          0
          • C CNewbie

            Thanks that fixed the errors and taught me something :). Now it opens CBTNuggetPlayer.exe like it is supposed to but then it closes right away. No Window or anything. Why would that happen? Thanks

            N Offline
            N Offline
            Nibu babu thomas
            wrote on last edited by
            #5

            CNewbie wrote:

            Thanks that fixed the errors and taught me something . Now it opens CBTNuggetPlayer.exe like it is supposed to but then it closes right away. No Window or anything. Why would that happen?

            Can't say anything specific. Just a guess, does it require a command line argument?


            Nibu thomas Software Developer

            C 1 Reply Last reply
            0
            • N Nibu babu thomas

              CNewbie wrote:

              Thanks that fixed the errors and taught me something . Now it opens CBTNuggetPlayer.exe like it is supposed to but then it closes right away. No Window or anything. Why would that happen?

              Can't say anything specific. Just a guess, does it require a command line argument?


              Nibu thomas Software Developer

              C Offline
              C Offline
              CNewbie
              wrote on last edited by
              #6

              no, I can go to the exe and double click and it opens fine. it is a GUI based exe. but trying to open it from my program doesnt bring up the window. Just opens the exe and then it closes without a window being drawn.

              N 1 Reply Last reply
              0
              • C CNewbie

                no, I can go to the exe and double click and it opens fine. it is a GUI based exe. but trying to open it from my program doesnt bring up the window. Just opens the exe and then it closes without a window being drawn.

                N Offline
                N Offline
                Nibu babu thomas
                wrote on last edited by
                #7

                Try this...

                ShellExecute(NULL, NULL, _T("Cisco CCNP Exam 642-801\\cd\\CBTNuggetPlayer.exe"), NULL, NULL, SW_SHOWDEFAULT);

                A suggestion: Check out CreateProcess[^]. A Demo[^]


                Nibu thomas Software Developer

                1 Reply Last reply
                0
                • C CNewbie

                  I am getting an error on this line: ShellExecute(NULL,NULL,"Cisco CCNP Exam 642-801\\cd1\\CBTNuggetPlayer.exe",NULL,"",SW_SHOWDEFAULT); and the error is: error C2664: 'ShellExecuteW' : cannot convert parameter 3 from 'const char [48]' to 'LPCWSTR' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast I am using a relative path as my program will be executed from the root of a CD and will attempt to open a file 2 layer down the directory tree. thanks

                  T Offline
                  T Offline
                  toxcct
                  wrote on last edited by
                  #8

                  also set the 2nd parameter to "open"

                  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