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. To Open logfile in a notepad !!!!!!!!!!!!!

To Open logfile in a notepad !!!!!!!!!!!!!

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

    I am using WinExec("C:\\logfile.txt",SW_SHOW) to open my file in a notepad on pressing a certain button but the file is not opened in the notepad. Infact nothing is happening when I press the button. I am using the same code of line WinExec("Notepad.exe,SW_SHOW") to open the notepad and it is working properly there. Plz give me its solution, by just giving the path of our file, it could open in a notepad. thanx Reply me soon

    H T 2 Replies Last reply
    0
    • S summo

      I am using WinExec("C:\\logfile.txt",SW_SHOW) to open my file in a notepad on pressing a certain button but the file is not opened in the notepad. Infact nothing is happening when I press the button. I am using the same code of line WinExec("Notepad.exe,SW_SHOW") to open the notepad and it is working properly there. Plz give me its solution, by just giving the path of our file, it could open in a notepad. thanx Reply me soon

      H Offline
      H Offline
      Hans Dietrich
      wrote on last edited by
      #2

      summo wrote: I am using WinExec("C:\\logfile.txt",SW_SHOW) to open my file in a notepad According to MSDN, the first parameter of WinExec is "Pointer to a null-terminated character string that contains the command line (file name plus optional parameters) for the application to be executed". In other words, first parameter must include name of program you want to execute. WinExec is not shell-oriented, i.e., it does not "associate" file types with applications. What you want is ShellExecute, which is shell-oriented:

      ShellExecute(NULL, "open", "C:\\logfile.txt", NULL, NULL, SW_SHOW);

      Best wishes, Hans

      1 Reply Last reply
      0
      • S summo

        I am using WinExec("C:\\logfile.txt",SW_SHOW) to open my file in a notepad on pressing a certain button but the file is not opened in the notepad. Infact nothing is happening when I press the button. I am using the same code of line WinExec("Notepad.exe,SW_SHOW") to open the notepad and it is working properly there. Plz give me its solution, by just giving the path of our file, it could open in a notepad. thanx Reply me soon

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

        Did you try WinExec("Notepad.exe C:\\logfile.txt", SW_SHOW)? WinExec("C:\\logfile.txt", SW_SHOW) tries to execute logfile.txt which is not an executable file. // Afterall I realized that even my comment lines have bugs

        A 1 Reply Last reply
        0
        • T Toni78

          Did you try WinExec("Notepad.exe C:\\logfile.txt", SW_SHOW)? WinExec("C:\\logfile.txt", SW_SHOW) tries to execute logfile.txt which is not an executable file. // Afterall I realized that even my comment lines have bugs

          A Offline
          A Offline
          Anonymous
          wrote on last edited by
          #4

          Thanks Alot Toni78, u r really genious. yest the code is working, now tell me, after writing WinExec("Notepad.exe C:\\logfile.txt",SW_SHOW) i want that the file logfile.txt opened in notepad must be maximized. thanx

          T 1 Reply Last reply
          0
          • A Anonymous

            Thanks Alot Toni78, u r really genious. yest the code is working, now tell me, after writing WinExec("Notepad.exe C:\\logfile.txt",SW_SHOW) i want that the file logfile.txt opened in notepad must be maximized. thanx

            T Offline
            T Offline
            Toni78
            wrote on last edited by
            #5

            Well, thank you. Instead of SW_SHOW use SW_SHOWMAXIMIZED. // Afterall I realized that even my comment lines have bugs

            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