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


本文整理自网络,侵删。

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

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

 

 

两种查看方式的对比

program Project1;

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

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.

来源:https://www.cnblogs.com/sun_catboy/archive/2009/04/03/1429131.html

相关阅读 >>

Delphi调用外部程序并等待其运行结束

Delphi md5加密字符串

Delphi 查找并删除过期的日志目录

Delphi 判断目录是否存在,不存在则创建目录并打开,存在则直接打开

Delphi中httpencode使用注意事项

Delphi 10 seattle中的画布上绘制字符

Delphi自动检测u盘插入、拔出及获取u盘盘符

Delphi xe 安卓开发黑屏的另一种解决办法

Delphi 熊猫烧香核心源码

Delphi 在ie上增添一个按钮

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



打赏

取消

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

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

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

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

评论

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