如何向打开的记事本写入一段文本???

zwq78 2005-10-26 12:32:40
代码如下:
Dim p As System.Diagnostics.Process = System.Diagnostics.Process.Start("notepad.exe")
Dim str As String = ReadCurrRecord(ds, currMasterID)
SendMessage(p.MainWindowHandle.ToInt32, WM_SETTEXT, 0, str)

为什么记事本里总是空的呢????
...全文
166 5 打赏 收藏 举报
写回复
5 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
兔子-顾问 2005-10-26
Mark and learn
  • 打赏
  • 举报
回复
zwq78 2005-10-26
thx pupo(泡泡)
  • 打赏
  • 举报
回复
zwq78 2005-10-26
to:pupo(泡泡)
发现在第一次有效果,但关掉记事本后,再执行一次,记事本里没什么反应,空白一片,怎么回事呢???
  • 打赏
  • 举报
回复
pupo 2005-10-26
Public Declare Function GetWindow Lib "user32" Alias "GetWindow" (ByVal hwnd As IntPtr, ByVal wCmd As Integer) As IntPtr
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As String) As Integer

Public Const WM_SETTEXT = &HC
Public Const GW_CHILD = 5

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim p As Process = Process.Start("notepad")
Dim hwnd As IntPtr = GetWindow(p.MainWindowHandle, GW_CHILD)
SendMessage(hwnd, WM_SETTEXT, 0, "abcd")
End Sub
  • 打赏
  • 举报
回复
相关推荐
发帖
VB

1.6w+

社区成员

VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
帖子事件
创建了帖子
2005-10-26 12:32
社区公告
暂无公告