|
楼主 |
发表于 2018-7-28 23:24:02
|
显示全部楼层
江西省南昌市
或者求翻译到易语言:
- TFindWindowThread = class(TThread)
- private
- FDesktop:THandle;
- FWindowHandle:THandle;
- protected
- procedure Execute();override;
- public
- constructor Create(ACreateSuspended:Boolean;const ADesktop:THandle);reintroduce;
- property WindowHandle:THandle read FWindowHandle;
- end;
-
-
- { TFindWindowThread }
-
- procedure TFindWindowThread.Execute();
- var
- I:Integer;
- begin
- //make the current thread find window on the new desktop!
- if not SetThreadDesktop(FDesktop) then begin
- exit;
- end;
- for I:=0 to 60 do begin //wait 30 seconds for open the main window
- FWindowHandle:=FindWindow(nil,PChar('WindowCaption'));
- if FWindowHandle<>0 then begin
- break;
- end;
- Sleep(500);
- end;
- end;
-
- constructor TFindWindowThread.Create(ACreateSuspended:Boolean;const ADesktop:THandle);
- begin
- inherited Create(ACreateSuspended);
- FDesktop:=ADesktop;
- end;
复制代码
- FindWindowThread:=TFindWindowThread.Create(false,FDesktop);
- try
- FindWindowThread.WaitFor;
- FMainWindowHandle:=FindWindowThread.WindowHandle;
- finally
- FindWindowThread.Free;
- end;
- if FMainWindowHandle=0 then begin
- MessageBox(Application.Handle,'Error when init voice (6).',PChar(Application.Title),MB_ICONWARNING);
- exit;
- end;
复制代码 |
|