c#利用winapi遍历桌面控件算法
public enum GUIInfoType
{
guiText.
guiTextClass,
guiTextParent,
guiTextClassParent,
}
private static int level=0
public static int FindGUILike(ref int hWndArray,int hWndStart,ref string windowText,ref string className,ref string parentText)
{
int hwnd=0;
int r=0;
StringBuilder sWindowText=new StringBuilder();
StringBuilder sClassname=new StringBuilder();
StringBuilder sParentText=new StringBuilder();
if(level==0)
{
hWndTarget=0;
if(hWndTarget==0) hWndStart = GetDesktopWindow();
}
level=level+1;
hwnd=GetWindow(hWndStart,GW_CHILD);
while(hwnd!=0)
{
r=FindGUILike(ref hWndArray,hwnd windowText,ref classname,ref parentText);
sWindowText.Capacity=255;
r=GetClassName(hwnd,sWindowsText,255);
sClassname.Capacity=255;
r=GetWindowText(GetParent(hwnd),sParentText,225);
GUIInfoType guiInfoType=GetGUIInfoType(windowText,className,parentText);
ResetGUIInfo(guiInfoType,hwnd,ref hWndArray,ref windowText,ref className,ref parentText,sWindowText,sClassname,sParentText);
hwnd=GetWindow(hwnd,GW_HWNDNEXT);
}
level=level-1;
return 0;
}
private static GUIInfoType GetGUIInfoType(string winText,string winClass,string winTextParent)
{
if(winText!=''&&winClass!=''&winTextParent=='')
return GUIInfoType.guiTextClass;
else if(winText!=''&&winClass==''&winTextParent!='')
return GUIInfoType.guiTextParent;
else if(winText!=''&&winClass!=''&winTextParent=='')
return GUIInfoType.guiClassParent;
return GUIInfoType.guiText;
}
private static void ResetGUIInfo(GUIInfoType guiInfoType,int hwnd,ref int hWndTarget,ref string windowText,ref string className,ref string parentText,StringBuilder sParentText)
{
string clsStartedWith='';
if(clas
相关文档:
这些天因为工作需要,要将一些html文件转换为chm文件,当然是需要和程序结合在一起。
后来找到NDoc,里头有一段代码是相关的,于是开始分析代码,写完之后,总结:主要是利用微软的hhc.exe来编译html文件,程序需要将具体的数据写入hhp和hhc文件。
主要代码如下:
复制C#代码保存代码public void CompileProject()
{ ......
1.安装ODP(oracle data provider)
2.然后在项目中引用 Oracle.DataAccess程序集
3.接着
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
4.然后编写程序和ado.net方位sqlserver 差别不大了,就是利用下面的对象进行编程,当然,因为oracle和sqlserver有很多地方不一样,所以细节存在很大差异。
O ......
C#正则表达式编程(三):Match类和Group类用法 收藏 此文于2010-03-09被推荐到CSDN首页
如何被推荐?
前面两篇讲述了正则表达式的基础和一些简单的例子,这篇将稍微深入一点探讨一下正则表达式分组,在.NET中正则表达式分组是用Math类来代表的。
首先先看一段代码:
view plaincopy to clipboardprint?
/// &l ......
private static int level=0
public static int FindGUILike(ref int hWndArray,int hWndStart,ref string windowText,ref string className,ref string parentText)
{
int hwnd=0;
int r=0;
StringBuilder sWindowText=new StringBuilder();
StringBuilder sClassname=new StringBuilder();
StringBuilder sParentT ......
在net中有一个至关重要的关键字,那就是using
using一般有着以下几种用法:
1、直接引入命名空间
a、using System ,这个是最常用的,就是using+命名空间,这样就可以直接使用命名空间中的类型,而免去了使用详细的命名空间
b、使用全限定名
不用使用using System;直接在程序中调用System.Console.WriteLine("Hello ......