日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
C#打開記事本實(shí)現(xiàn)實(shí)例解析

C#打開記事本的功能實(shí)現(xiàn)是如何的呢?我們在項(xiàng)目中也許會(huì)碰到這個(gè)小插曲,那么具體的實(shí)現(xiàn)方法是什么呢?,還有要實(shí)現(xiàn)給記事本添加內(nèi)容,那么下面我們通過實(shí)例向你介紹具體的實(shí)現(xiàn)過程。

創(chuàng)新互聯(lián)建站主營大姚網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營網(wǎng)站建設(shè)方案,成都app開發(fā),大姚h5重慶小程序開發(fā)搭建,大姚網(wǎng)站營銷推廣歡迎大姚等地區(qū)企業(yè)咨詢

C#打開記事本實(shí)現(xiàn)實(shí)例:

 
 
 
  1. /// ﹤summary﹥
  2. /// C#打開記事本之傳遞消息給記事本
  3. /// ﹤/summary﹥
  4. /// ﹤param name="hWnd"﹥﹤/param﹥
  5. /// ﹤param name="Msg"﹥﹤/param﹥
  6. /// ﹤param name="wParam"﹥﹤/param﹥
  7. /// ﹤param name="lParam"﹥﹤/param﹥
  8. /// ﹤returns﹥﹤/returns﹥
  9. [DllImport("User32.DLL")]
  10. public static extern int SendMessage(
  11. IntPtr hWnd, uint Msg, int wParam, string lParam);
  12. /// ﹤summary﹥
  13. /// C#打開記事本之查找句柄
  14. /// ﹤/summary﹥
  15. /// ﹤param name="hwndParent"﹥﹤/param﹥
  16. /// ﹤param name="hwndChildAfter"﹥﹤/param﹥
  17. /// ﹤param name="lpszClass"﹥﹤/param﹥
  18. /// ﹤param name="lpszWindow"﹥﹤/param﹥
  19. /// ﹤returns﹥﹤/returns﹥
  20. [DllImport("User32.DLL")]
  21. public static extern IntPtr FindWindowEx(
  22. IntPtr hwndParent, IntPtr hwndChildAfter, 
  23. string lpszClass, string lpszWindow);
  24. /// ﹤summary﹥
  25. /// C#打開記事本之記事本需要的常量
  26. /// ﹤/summary﹥
  27. public const uint WM_SETTEXT = 0x000C;
  28. #endregion
  29. private void button1_Click(object sender, EventArgs e)
  30. {
  31. #region [ 啟動(dòng)記事本 ]
  32. System.Diagnostics.Process Proc;
  33. try
  34. {
  35. // 啟動(dòng)記事本
  36. Proc = new System.Diagnostics.Process();
  37. Proc.StartInfo.FileName = "notepad.exe";
  38. Proc.StartInfo.UseShellExecute = false;
  39. Proc.StartInfo.RedirectStandardInput = true;
  40. Proc.StartInfo.RedirectStandardOutput = true;
  41. Proc.Start();
  42. }
  43. catch
  44. {
  45. Proc = null;
  46. }
  47. #endregion
  48. #region [ 傳遞數(shù)據(jù)給記事本 ]
  49. if (Proc != null)
  50. {
  51. // C#打開記事本之調(diào)用 API, 傳遞數(shù)據(jù)
  52. while (Proc.MainWindowHandle == IntPtr.Zero)
  53. {
  54. Proc.Refresh();
  55. }
  56. IntPtr vHandle = FindWindowEx(
  57. Proc.MainWindowHandle, IntPtr.Zero, "Edit", null);
  58. // C#打開記事本之傳遞數(shù)據(jù)給記事本
  59. SendMessage(vHandle, WM_SETTEXT, 0, "Message");
  60. }
  61. #endregion
  62. }

C#打開記事本的具體實(shí)現(xiàn)內(nèi)容就向你介紹到這里,希望對你了解和學(xué)習(xí)C#打開記事本的開發(fā)實(shí)現(xiàn)有所幫助。


分享文章:C#打開記事本實(shí)現(xiàn)實(shí)例解析
標(biāo)題路徑:http://www.dlmjj.cn/article/cdgcioc.html