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. Using ShellExecute to launch notepad ???

Using ShellExecute to launch notepad ???

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionc++
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.
  • L Offline
    L Offline
    ldsdbomber
    wrote on last edited by
    #1

    I've snagged this to open a helpfile for an MFC dialog. For now, it's OK to be just a text file, though at some point an integrated help file / CHM might be better ShellExecute(this->m_hWnd,"open","notepad.exe","PTW Geske Analyse Help.txt","",SW_SHOW ); Problem is, I am not sure what the paths are involved. It opens notepad correctly but it is not finding the text file. I tried putting it in the same folder as the executable that's launching notepad but to no avail. How can I use a relative path so that if I distribute the program exe and the help file and state that they should be in the same folder, then notepad will correctly find the text file t.i.a Lee ps have seen ShellExecuteEx but it seemed the extra info (incl. path) refers to the path for notepad and not the target file PS it seems to be defaulting to desktop since thats where it saves a new file if promptedm and when I put the txt file there it does indeed open it. Perhaps I need a SetPath type instruction, but I want it to be relative to the running program and not a hard coded path.

    M T 2 Replies Last reply
    0
    • L ldsdbomber

      I've snagged this to open a helpfile for an MFC dialog. For now, it's OK to be just a text file, though at some point an integrated help file / CHM might be better ShellExecute(this->m_hWnd,"open","notepad.exe","PTW Geske Analyse Help.txt","",SW_SHOW ); Problem is, I am not sure what the paths are involved. It opens notepad correctly but it is not finding the text file. I tried putting it in the same folder as the executable that's launching notepad but to no avail. How can I use a relative path so that if I distribute the program exe and the help file and state that they should be in the same folder, then notepad will correctly find the text file t.i.a Lee ps have seen ShellExecuteEx but it seemed the extra info (incl. path) refers to the path for notepad and not the target file PS it seems to be defaulting to desktop since thats where it saves a new file if promptedm and when I put the txt file there it does indeed open it. Perhaps I need a SetPath type instruction, but I want it to be relative to the running program and not a hard coded path.

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

      Maybe check out the GetModuleFileName() API and build your full pathname from there... Mark

      "Go that way, really fast. If something gets in your way, turn."

      L 1 Reply Last reply
      0
      • L ldsdbomber

        I've snagged this to open a helpfile for an MFC dialog. For now, it's OK to be just a text file, though at some point an integrated help file / CHM might be better ShellExecute(this->m_hWnd,"open","notepad.exe","PTW Geske Analyse Help.txt","",SW_SHOW ); Problem is, I am not sure what the paths are involved. It opens notepad correctly but it is not finding the text file. I tried putting it in the same folder as the executable that's launching notepad but to no avail. How can I use a relative path so that if I distribute the program exe and the help file and state that they should be in the same folder, then notepad will correctly find the text file t.i.a Lee ps have seen ShellExecuteEx but it seemed the extra info (incl. path) refers to the path for notepad and not the target file PS it seems to be defaulting to desktop since thats where it saves a new file if promptedm and when I put the txt file there it does indeed open it. Perhaps I need a SetPath type instruction, but I want it to be relative to the running program and not a hard coded path.

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

        ldsdbomber wrote:

        ShellExecute(this->m_hWnd,"open","notepad.exe","PTW Geske Analyse Help.txt","",SW_SHOW );

        change to this :

        ::ShellExecute(NULL, _T("open"), _T("notepad.exe"), _T("PTW Geske Analyse Help.txt"), **NULL**, SW_SHOW);

        it should whork, unless the PTW Geske Analyse Help.txt file is not found in the application or system path... but you can provide its full path name


        [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

        L 1 Reply Last reply
        0
        • M Mark Salsbery

          Maybe check out the GetModuleFileName() API and build your full pathname from there... Mark

          "Go that way, really fast. If something gets in your way, turn."

          L Offline
          L Offline
          ldsdbomber
          wrote on last edited by
          #4

          many thanks!

          1 Reply Last reply
          0
          • T toxcct

            ldsdbomber wrote:

            ShellExecute(this->m_hWnd,"open","notepad.exe","PTW Geske Analyse Help.txt","",SW_SHOW );

            change to this :

            ::ShellExecute(NULL, _T("open"), _T("notepad.exe"), _T("PTW Geske Analyse Help.txt"), **NULL**, SW_SHOW);

            it should whork, unless the PTW Geske Analyse Help.txt file is not found in the application or system path... but you can provide its full path name


            [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

            L Offline
            L Offline
            ldsdbomber
            wrote on last edited by
            #5

            Thanks. This is the kind of thing I keep asking about - which books will teach me how to do things the proper way. I know the _T is a unicode thing isn't it? and the :: is some kind of namespace item, so where can I get a thorough and proper grounding in "good" MFC/C++ from start to finish

            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