有一个用.net做的客户端,我想获得其句柄,我以获得最外层父窗体句柄,但是无法获得子窗体句柄,我用spy++查看这个框架的窗体信息,标题为空,类名为:MicrosoftSilverlight。请问我怎么才能获得这个子窗体的句柄呢

解决方案 »

  1.   

    findwindowex(hwnd,'子窗体类型','text',0);//hwnd为父窗体句柄,要子窗体是父窗体的一级控件,如果不是的话用spy看看控件结构,一级一级查下去,或者直接用遍历控件函数,记得结贴啊!手机打字真累…
      

  2.   

     一、同意楼上的findwindow(nil,pChar(Edit1.Text)); 也可行的。 
     二、查看进程名来操作。代码如下:
     function TfrmMain.GetPID(_GetPName: String): String;
    var
     h:thandle;
     f:boolean;
     lppe:tprocessentry32;
     sTempExeFile : string;
    begin
     sTempExeFile := '';
     h := CreateToolhelp32Snapshot(TH32cs_SnapProcess, 0);
     lppe.dwSize := sizeof(lppe);
     f := Process32First(h, lppe);
     //lppe.szExeFile是进程的名字,自己挑选你要的
     //lppe.th32ProcessID就是你要的进程号
     while integer(f) <> 0 do
     begin
      //Memo1.Lines.Add(lppe.szExeFile);
      sTempExeFile := LowerCase(lppe.szExeFile);
      sTempExeFile := Trim(StringReplace(sTempExeFile,'.exe','',[rfreplaceall,rfignorecase]));
      //Memo1.Lines.Add(Trim(lowerCase(sTempExeFile)));
      if Trim(lowerCase(sTempExeFile)) = Trim(lowerCase(_GetPName)) then
       begin
       Result:=(inttostr(lppe.th32ProcessID));
       break;
       end;
      f := Process32Next(h,lppe);
     end;
     if integer(f) = 0 then
      Result := '0';
    end;