Delphi开发桌面图标列表查看程序

桌面图标太多的时候总是显示不开,但是在Windows里面查看很多文件的时候可以列表形式查看,但是桌面不行了,所以我自己研究了一下,写了一个桌面图标列表查看的工具

这个工具运行第一次是列表查看,再运行就是正常查看,非常简单程序运行后便结束,不会占用内存,加载在启动里面这样每次进入桌面图标便会是列表方式查看了

 

 

两种查看方式的对比

program Project1;

//作者:孙占伟
//sun_catboy@sohu.com

uses
  Windows,
  SysUtils;

function GetDesktopHwnd(): HWND;
var
  hWin: HWND;
  bufClassName: 
array[0..255of 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.

转载于:https://www.cnblogs.com/sun_catboy/archive/2009/04/03/1429131.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值