xdesktop.pas

来自「关于c++ builder编程的很好的资料」· PAS 代码 · 共 59 行

PAS
59
字号
unit xDesktop;

interface

uses Windows, Messages, SysUtils, Forms, Controls, Graphics, ShellAPI, Registry;

function GetDesktopDefView: HWND;
function GetDesktopListView: HWND;
function GetActiveDesktopWindow: HWND;

procedure RebuildIconCache;


implementation

uses xStrings, xFiles;

function GetDesktopDefView: HWND;
begin
  Result := GetWindow(FindWindow(PChar('ProgMan'), nil), GW_CHILD);
end;

function GetDesktopListView: HWND;
begin
  Result := GetWindow(GetWindow(FindWindow(PChar('ProgMan'), nil), GW_CHILD), GW_CHILD);
end;

function GetActiveDesktopWindow: HWND;
var
  Buf: array[0..255] of Char;
begin
  Result := GetDesktopListView;
  repeat
    Result := GetWindow(Result, GW_HWNDNEXT);
    if Result = 0 then Exit;
    GetClassName(Result, Buf, 256);
  until StrIComp(Buf, 'Internet Explorer_Server') = 0;
end;

procedure RebuildIconCache;
var
  IconW: Integer;
begin
  IconW := GetSystemMetrics(SM_CXICON);
  with TRegIniFile.Create('Control Panel\Desktop') do
    try
      WriteString('WindowMetrics', 'Shell Icon Size', IntToStr(IconW - 1));
      SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0, 0);
      WriteString('WindowMetrics', 'Shell Icon Size', IntToStr(IconW));
      SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0, 0);
    finally
      Free;
    end;
end;


end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?