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. Write to Notepad without creating a file

Write to Notepad without creating a file

Scheduled Pinned Locked Moved C#
csharptutorial
4 Posts 2 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

    Is there a way to write to Notepad from c# without creating a file. I need this because I dont have write permission on the client but I need to show the extracted data in the Notepad. Please guide me in this direction. Live Life King Size Alomgir Miah

    E 1 Reply Last reply
    0
    • A Alomgir Miah

      Is there a way to write to Notepad from c# without creating a file. I need this because I dont have write permission on the client but I need to show the extracted data in the Notepad. Please guide me in this direction. Live Life King Size Alomgir Miah

      E Offline
      E Offline
      eggie5
      wrote on last edited by
      #2

      You can do it using the windows API. I don't remember exactly, but you use FindWindow I think, with some paramter like SET_TEXT or something. There's an example that does exactly what you want somewhere on pinvoke.net[^] /\ |_ E X E GG

      A 1 Reply Last reply
      0
      • E eggie5

        You can do it using the windows API. I don't remember exactly, but you use FindWindow I think, with some paramter like SET_TEXT or something. There's an example that does exactly what you want somewhere on pinvoke.net[^] /\ |_ E X E GG

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

        Thanks a lot for your reply. 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 Live Life King Size Alomgir Miah

        E 1 Reply Last reply
        0
        • A Alomgir Miah

          Thanks a lot for your reply. 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 Live Life King Size Alomgir Miah

          E Offline
          E Offline
          eggie5
          wrote on last edited by
          #4

          cool, you found it. GOOD JOB! /\ |_ E X E GG

          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