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#
  4. Append Text to Notepad programatically

Append Text to Notepad programatically

Scheduled Pinned Locked Moved C#
csharpquestion
4 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.
  • A Offline
    A Offline
    Alomgir Miah
    wrote on last edited by
    #1

    To write to Notepad from c# without creating a file I found the following code. I need this because I dont have write permission on the client but I need to show the extracted data in the Notepad. Private Declare Ansi Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As String) As Integer Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer Private Declare Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" (ByVal hWnd1 As Int32, ByVal hWnd2 As Int32, ByVal lpsz1 As String, ByVal lpsz2 As String) As Int32 Private Const WM_SETTEXT As Integer = &HC Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim hwnd As Integer = FindWindow(vbNullString, "Untitled - Notepad") '/// assuming you have notepad open. Dim x As Integer = FindWindowEx(hwnd, 0, "Edit", vbNullString) Dim strText As String = "some text" If Not x = 0 Then SendMessage(x, WM_SETTEXT, 256, strText) End If End Sub My question is: Is there a way to append text to notepad instead of WM_SETTEXT. I need this because sometimes the data to be extracted is huge and WM_SETTEXT may not suffice. Live Life King Size Alomgir Miah Live Life King Size Alomgir Miah

    G 1 Reply Last reply
    0
    • A Alomgir Miah

      To write to Notepad from c# without creating a file I found the following code. I need this because I dont have write permission on the client but I need to show the extracted data in the Notepad. Private Declare Ansi Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As String) As Integer Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer Private Declare Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" (ByVal hWnd1 As Int32, ByVal hWnd2 As Int32, ByVal lpsz1 As String, ByVal lpsz2 As String) As Int32 Private Const WM_SETTEXT As Integer = &HC Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim hwnd As Integer = FindWindow(vbNullString, "Untitled - Notepad") '/// assuming you have notepad open. Dim x As Integer = FindWindowEx(hwnd, 0, "Edit", vbNullString) Dim strText As String = "some text" If Not x = 0 Then SendMessage(x, WM_SETTEXT, 256, strText) End If End Sub My question is: Is there a way to append text to notepad instead of WM_SETTEXT. I need this because sometimes the data to be extracted is huge and WM_SETTEXT may not suffice. Live Life King Size Alomgir Miah Live Life King Size Alomgir Miah

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      There was a question about this here a few days ago. Look for that. --- b { font-weight: normal; }

      A 1 Reply Last reply
      0
      • G Guffa

        There was a question about this here a few days ago. Look for that. --- b { font-weight: normal; }

        A Offline
        A Offline
        Alomgir Miah
        wrote on last edited by
        #3

        I was the one who asked the question. I can set text to Notepad but cannot append. Live Life King Size Alomgir Miah

        L 1 Reply Last reply
        0
        • A Alomgir Miah

          I was the one who asked the question. I can set text to Notepad but cannot append. Live Life King Size Alomgir Miah

          L Offline
          L Offline
          Luis Alonso Ramos
          wrote on last edited by
          #4

          You have to get the current text, append to it, and then set the full text altogether. -- LuisR


          Luis Alonso Ramos Intelectix - Chihuahua, Mexico Not much here: My CP Blog!

          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