当前位置:   article > 正文

获得桌面图标所在窗口--兼容Win7_delphi workerw

delphi workerw

Win7父窗口类名是 WorkerW,但是WorkerW有多个


function Find_Window(XParent: HWND; XFromIndex: Integer; const XClassNames: array of string): HWND;

var

  LName: string;

  LChild: HWND;

begin

  Result := XParent;

  if (XFromIndex < Low(XClassNames)) or (XFromIndex > High(XClassNames)) then

  begin

    Exit;

  end;


  LName := XClassNames[XFromIndex];

  LChild := 0;

  while True do

  begin

    LChild := FindWindowEx(XParent, LChild, PChar(LName), nil);

    if LChild = 0 then

    begin

      Result := 0;

      Exit;

    end;

    Result := Find_Window(LChild, XFromIndex + 1, XClassNames);

    if Result <> 0 then

      Exit;

  end;

end;


function FindDesktopIconWindow(var RetParent, RetChild: HWND): Boolean;

var

  LDesktop: HWND;

begin

  LDesktop := GetDesktopWindow;

  RetChild := Find_Window(LDesktop, 0, ['Progman', 'SHELLDLL_DefView', 'SysListView32']);

  if RetChild = 0 then

  begin

    RetChild := Find_Window(LDesktop, 0, ['WorkerW', 'SHELLDLL_DefView', 'SysListView32']);

  end;


  if RetChild <> 0 then

  begin

    RetParent := GetParent(GetParent(RetChild));

  end;


  Result := (RetChild <> 0) and (RetParent <> 0) and (RetParent <> LDesktop); 

end;

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小舞很执着/article/detail/812547
推荐阅读
相关标签
  

闽ICP备14008679号