|
目的是查找任务中的Excel进程然后将已启动的Excel嵌入到系统中来,在delphi下执行通过。但是在X3下面就没有达到想要的效果,跟了半天确认就是GetWindowText函数的问题。有什么办法解决?谢谢
===========================================
var
openDialog:TOpenDialog;
hCurrentWindow: HWnd;
// szText: array of char;
lcaption:String;
begin
openDialog:=TOpenDialog.Create(nil);
OpenDialog.Filter:= '*.XLS|*.xls';
try
// setlength(szText,255);
if OpenDialog.Execute then
begin
hCurrentWindow := GetWindow(Handle, GW_HWNDFIRST);
while hCurrentWindow <> 0 do
begin
if iswindowvisible(hCurrentWindow) then
begin
if GetWindowText(hCurrentWindow,lcaption, 255)>0 then
// 跟踪lcaption,到这里报错,没有获得值,这句报读取内存完成部分
begin
if StringUtils.Pos('Microsoft Excel -',SysUtils.StrPas(lcaption)) >0 then
begin
Borland.Delphi.Windows.SetParent(hCurrentWindow,Handle);
end;
end;
end;
hCurrentWindow:=GetWindow(hCurrentWindow, GW_HWNDNEXT);
end;
end;
finally
OpenDialog.Free;
end;
|
|