日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

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

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
淺談如何利用C#枚舉所有的窗體

C#枚舉所有的窗體的兩種方法

1、直接查找游戲窗口,找到后作處理。

2、C#枚舉所有窗口,列表顯示,然后再處理。

我這里按第二種方式做。首先是一些準(zhǔn)備工作,如,了解如何調(diào)用系統(tǒng)API,見以前的博文。枚舉窗口要用的一些

API:EnumWindows,GetWindowText,GetParent,IsWindowVisible.

EnumWindows:枚舉窗口

GetWindowText:取得窗口標(biāo)題

GetParent:取得當(dāng)前窗體的父窗體(非常重要,用于判斷是否為頂級(jí)窗體)

IsWindowVisible:判斷窗體是否可見,用于過濾到不可見窗體。

C#枚舉代碼如下:

 
 
 
  1. namespaceHideProcess
  2. {
  3. publicdelegateboolCallBack(inthwnd,inty);
  4. publicpartialclassForm1:Form
  5. {
  6. [DllImport("user32.dll")]
  7. publicstaticexternintEnumWindows(CallBackx,inty);
  8. [DllImport("user32")]
  9. publicstaticexternintGetWindowText(inthwnd,StringBuilderlptrString,intnMaxCount);
  10. [DllImport("user32")]
  11. publicstaticexternintGetParent(inthwnd);
  12. [DllImport("user32")]
  13. publicstaticexternintIsWindowVisible(inthwnd);
  14. publicboolReport(inthwnd,intlParam)
  15. {
  16. intpHwnd;
  17. pHwnd=GetParent(hwnd);
  18. if(pHwnd==0&&IsWindowVisible(hwnd)==1)
  19. {
  20. StringBuildersb=newStringBuilder(512);
  21. GetWindowText(hwnd,sb,sb.Capacity);
  22. if(sb.Length>0)
  23. {
  24. this.comboBox1.Items.Add(sb.ToString());
  25. }
  26. }
  27. returntrue;
  28. }
  29. publicForm1()
  30. {
  31. InitializeComponent();
  32. }
  33. privatevoidbutton1_Click(objectsender,EventArgse)
  34. {
  35. Process[]ProcArray=Process.GetProcesses();
  36. comboBox1.Items.Clear();
  37. EnumWindows(this.Report,0);
  38. }
  39. }
  40. }

有一個(gè)combobox和button,點(diǎn)擊按鈕,將所有窗口列舉顯示在下拉框。接下來的工作就是設(shè)置窗體為隱藏。但是有一個(gè)缺點(diǎn)

隱藏后無法顯示。留待以后解決。利用C#枚舉所有的窗體就講到這里。


網(wǎng)頁(yè)名稱:淺談如何利用C#枚舉所有的窗體
分享鏈接:http://m.5511xx.com/article/ccdospe.html