.net – 如何从Windows窗体应用程序中打开记事本并在其中放置一
发布时间:2020-12-14 02:14:57 所属栏目:Windows 来源:网络整理
导读:我正在使用VB.NET和Visual Studio 2008. 我的问题是:如何从Windows窗体应用程序中打开记事本,然后在记事本窗口中放置一些文本字符串? 解决方法 使用Process.Start将属性ShellExecute设置为true; 使用剪贴板: http://www.dreamincode.net/forums/topic/400
我正在使用VB.NET和Visual Studio 2008.
我的问题是:如何从Windows窗体应用程序中打开记事本,然后在记事本窗口中放置一些文本字符串? 解决方法
>使用Process.Start将属性ShellExecute设置为true;
>使用剪贴板: http://www.dreamincode.net/forums/topic/40011-how-do-i-put-text-in-another-program/ 更新 Process.Start返回一个具有MainWindowHandle属性的Process对象.在上面提到的链接中发送文本而不是FindWindow时使用该句柄. 更新2 一些代码 Const WM_SETTEXT As Integer = &HC <DllImport("user32.dll")> _ Private Shared Function SendMessage(hWnd As IntPtr,Msg As Integer,wParam As IntPtr,<MarshalAs(UnmanagedType.LPStr)> lParam As String) As IntPtr End Function Private Shared Sub Main() 'ProcessStartInfo is used to instruct the Process class ' on how to start a new process. The UseShellExecute tells ' the process class that it (amongst other) should search for the application ' using the PATH environment variable. Dim pis As ProcessStartInfo = New ProcessStartInfo("notepad.exe") pis.UseShellExecute = True ' The process class is used to start the process ' it returns an object which can be used to control the started process Dim notepad As Process = Process.Start(pis) ' SendMessage is used to send the clipboard message to notepad's ' main window. Dim textToAdd As String = "Text to add" SendMessage(notepad.MainWindowHandle,WM_SETTEXT,IntPtr.Zero,textToAdd) End Sub (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 从Windows使用32feet.net库发送bMessage到消息访问服务器C#
- Windows – 来自同一用户帐户的LocalServer32 EXE的COM激活
- Windows主机和Linux Docker容器之间的通信
- windows-server-2003 – 如何审核Windows Server 2003中的特
- windows – 如何确定驱动器是否已安装在网络上?
- 如何在不事先知道其本地化名称的情况下使用Windows安全组?
- 检查MS-DOS(C/C++)中的键是否关闭
- 使用WindowChrome在WPF窗口上显示默认窗口按钮
- windows – 我应该将所有服务器都放入我的域名吗?
- windows – 通过tf.exe确定TFS工作区的本地路径