Delphi 如何获取桌面图标方法


本文整理自网络,侵删。

 program Project1;


uses
Windows,
SysUtils;

function GetDesktopHwnd(): HWND;
var
hWin: HWND;
bufClassName: array[0..255] of Char;
begin
//取得窗体的HWND
hWin := FindWindow('Progman', nil);
//取得窗体的下一个HWND
hWin := GetWindow(hWin, GW_CHILD);
GetClassName(hWin, bufClassName, 255);
while Trim(bufClassName) <> 'SHELLDLL_DefView' do
begin
if hWin <> 0 then
begin
hWin := GetNextWindow(hWin, GW_HWNDNEXT);
GetClassName(hWin, bufClassName, 255);
end
else
begin
Result := hWin;
Exit;
end;
end;
hWin := GetWindow(hWin, GW_CHILD);
GetClassName(hWin, bufClassName, 255);
while Trim(bufClassName) <> 'SysListView32' do
begin
if hWin <> 0 then
begin
hWin := GetNextWindow(hWin, GW_HWNDNEXT);
GetClassName(hWin, bufClassName, 255);
end
else
begin
Result := hWin;
Exit;
end;
end;
OutputDebugString(PChar(IntToStr(hWin)));
Result := hWin;
end;

procedure SetDesktopSmallIcon();
var
hWin: HWND;
WinStyle: Integer;
begin
hWin := GetDesktopHwnd;
if hWin <> 0 then
begin
WinStyle := GetWindowLong(hWin, GWL_STYLE);
SetWindowLong(hWin, GWL_STYLE, (WinStyle xor $0002));
end;
end;

begin
SetDesktopSmallIcon();
end

相关阅读 >>

Delphi 过滤网页代码 <script></script>

Delphi 杨辉三角

Delphi 十六进制字符串转化成字符串输出hextostr strtohex(Delphi版、c#版)

Delphi远程线程注入获取qq密码

Delphi2010 关于record类型rtti反射的用途和方法

Delphi 如何判断字符串是否是有效email地址

Delphi windows 编程[9] - wm_close 消息

Delphi2010获取鼠标指向窗口的位置及鼠标在窗口内的相对位置坐标

Delphi 实现软件版验证码

Delphi tform类有关属性简介

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...