C#打开记事本的功能实现是如何的呢?我们在项目中也许会碰到这个小插曲,那么具体的实现方法是什么呢?,还有要实现给记事本添加内容,那么下面我们通过实例向你介绍具体的实现过程。

创新互联建站主营大姚网站建设的网络公司,主营网站建设方案,成都app开发,大姚h5重庆小程序开发搭建,大姚网站营销推广欢迎大姚等地区企业咨询
C#打开记事本实现实例:
- /// ﹤summary﹥
 - /// C#打开记事本之传递消息给记事本
 - /// ﹤/summary﹥
 - /// ﹤param name="hWnd"﹥﹤/param﹥
 - /// ﹤param name="Msg"﹥﹤/param﹥
 - /// ﹤param name="wParam"﹥﹤/param﹥
 - /// ﹤param name="lParam"﹥﹤/param﹥
 - /// ﹤returns﹥﹤/returns﹥
 - [DllImport("User32.DLL")]
 - public static extern int SendMessage(
 - IntPtr hWnd, uint Msg, int wParam, string lParam);
 - /// ﹤summary﹥
 - /// C#打开记事本之查找句柄
 - /// ﹤/summary﹥
 - /// ﹤param name="hwndParent"﹥﹤/param﹥
 - /// ﹤param name="hwndChildAfter"﹥﹤/param﹥
 - /// ﹤param name="lpszClass"﹥﹤/param﹥
 - /// ﹤param name="lpszWindow"﹥﹤/param﹥
 - /// ﹤returns﹥﹤/returns﹥
 - [DllImport("User32.DLL")]
 - public static extern IntPtr FindWindowEx(
 - IntPtr hwndParent, IntPtr hwndChildAfter,
 - string lpszClass, string lpszWindow);
 - /// ﹤summary﹥
 - /// C#打开记事本之记事本需要的常量
 - /// ﹤/summary﹥
 - public const uint WM_SETTEXT = 0x000C;
 - #endregion
 - private void button1_Click(object sender, EventArgs e)
 - {
 - #region [ 启动记事本 ]
 - System.Diagnostics.Process Proc;
 - try
 - {
 - // 启动记事本
 - Proc = new System.Diagnostics.Process();
 - Proc.StartInfo.FileName = "notepad.exe";
 - Proc.StartInfo.UseShellExecute = false;
 - Proc.StartInfo.RedirectStandardInput = true;
 - Proc.StartInfo.RedirectStandardOutput = true;
 - Proc.Start();
 - }
 - catch
 - {
 - Proc = null;
 - }
 - #endregion
 - #region [ 传递数据给记事本 ]
 - if (Proc != null)
 - {
 - // C#打开记事本之调用 API, 传递数据
 - while (Proc.MainWindowHandle == IntPtr.Zero)
 - {
 - Proc.Refresh();
 - }
 - IntPtr vHandle = FindWindowEx(
 - Proc.MainWindowHandle, IntPtr.Zero, "Edit", null);
 - // C#打开记事本之传递数据给记事本
 - SendMessage(vHandle, WM_SETTEXT, 0, "Message");
 - }
 - #endregion
 - }
 
C#打开记事本的具体实现内容就向你介绍到这里,希望对你了解和学习C#打开记事本的开发实现有所帮助。
                网站题目:C#打开记事本实现实例解析
                
                网站URL:http://www.csdahua.cn/qtweb/news39/402139.html
            
网站建设、网络推广公司-快上网,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 快上网