C# 句柄是什么时候生成的?同一父类下的两个同类名子类该怎么获得句柄?
具体问题:我用WinExec(filePath, SW_MAXIMIZE);打开了一个外部exe程序,为了获得句柄,我写了如下代码,但是在执行完WinExec后,发现对于同类名的子类只能获得第一个也就是如下代码中子窗体2的句柄,而子窗体3的句柄则为0,但是如果把WinExec(filePath, SW_MAXIMIZE);启动外部程序的代码注释掉,手动打开外部exe程序,在获取窗口的句柄,又发现能够全部获得他们的句柄,不理解啊,求指导?
string WinClassName = "Itasca2Manager";
IntPtr myIntPtr = FindWindow(WinClassName, null);
Console.WriteLine("主窗体的句柄为:" + myIntPtr.ToInt32());
string subClass = "Itasca2Client";
IntPtr EdithWnd = new IntPtr(0);
IntPtr ParenthWnd_sub = FindWindowEx(myIntPtr, EdithWnd, subClass, null);
Console.WriteLine("子窗体1的句柄为:" + ParenthWnd_sub.ToInt32());
string subClass1 = "FLAC3D";
IntPtr EdithWnd1 = new IntPtr(0);
IntPtr ParenthWnd_sub1 = FindWindowEx(ParenthWnd_sub, EdithWnd, subClass1, null);
Console.WriteLine("子窗体2的句柄为:" + ParenthWnd_sub1.ToInt32());
string subClass2 = "FLAC3D";
IntPtr EdithWnd2 = new IntPtr(0);
IntPtr ParenthWnd_sub2 = FindWindowEx(ParenthWnd_sub1, EdithWnd, subClass2, null);
Console.WriteLine("子窗体3的句柄为:" + ParenthWnd_sub2.ToInt32());
API 同类名 C# API 同类名子窗口 --------------------编程问答-------------------- http://msdn.microsoft.com/zh-cn/library/system.windows.forms.control.ishandlecreated(v=vs.110).aspx
补充:.NET技术 , C#