⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.pas

📁 在delphi中实现windows核心编程.原书光盘代码核心编程.原书光盘代码
💻 PAS
字号:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, shellapi,registry;

type
  TForm1 = class(TForm)
    ListBox1: TListBox;
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure ListBox1DblClick(Sender: TObject);
  private
    { Private declarations }
    IEXPLORE:string;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

function EnumChildWindowsProc(hwnd: Integer; lparam: Longint): Boolean; stdcall;
var
  buffer: array[0..255] of char;
begin
  Result := True;
  GetClassName(hwnd, buffer, 256);
  if StrPas(Buffer) = 'Edit' then
  begin
    SendMessage(hwnd, WM_GETTEXT, 256, lparam);
    Result := False;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
const
  maxx = 30;
var
  hCurrentWindow: HWnd;
  szText: array[0..255] of char;
  buffer: array[0..255] of char;
  i: integer;
begin
  listbox1.clear;
  hCurrentWindow := GetWindow(Handle, GW_HWNDFIRST);
  while hCurrentWindow <> 0 do
  begin
    GetClassName(hCurrentWindow, @szText, 255);

    if Strpas(@szText) = 'IEFrame' then
    begin
      GetWindowText(hCurrentWindow, @szText, 255);
       EnumChildWindows(hCurrentWindow,@EnumChildWindowsProc,Integer(@buffer[0]));
       listbox1.items.add(StrPas(buffer));
    end;
    hCurrentWindow:=GetWindow(hCurrentWindow,GW_HWNDNEXT);
  end;
  hCurrentWindow:=GetWindow(Handle,GW_HWNDFIRST);
  While hCurrentWindow<>0 Do
  Begin
    GetClassName(hCurrentWindow,@szText,255);
    if Strpas(@szText)='CabinetWClass' then
    begin
       GetWindowText(hCurrentWindow,@szText,255);
       EnumChildWindows(hCurrentWindow,@EnumChildWindowsProc,Integer(@buffer[0]));
       listbox1.items.add(StrPas(buffer));
    end;
    hCurrentWindow:=GetWindow(hCurrentWindow,GW_HWNDNEXT);
  end;
  deletefile(extractfilepath(paramstr(0))+'Address.d'+inttostr(maxx));
  for i:=maxx-1 downto 0 do
    renamefile(extractfilepath(paramstr(0))+'Address.d'+format('%.2d',[i]),'Address.d'+format('%.2d',[i+1]));
  listbox1.items.savetofile(extractfilepath(paramstr(0))+'Address.d00');
end;

procedure TForm1.FormShow(Sender: TObject);
var
   s:string;
   reg:TRegistry;
begin
  s:=extractfilepath(paramstr(0))+'Address.d00';
  if fileexists(s) then
     listbox1.items.loadfromfile(s);
  reg:=TRegistry.create;
  reg.rootkey:=HKEY_LOCAL_MACHINE;
  reg.openkey('Software\Microsoft\Windows\CurrentVersion\App Paths\IEXPLORE.EXE',true);
  IEXPLORE:=reg.ReadString('');
  reg.closekey;
  reg.free;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
   i:integer;
begin
   for i:=0 to listbox1.items.count-1 do
   begin
     WinExec(PChar(IEXPLORE+' "'+listbox1.items[i]+'"'),SW_NORMAL);
   end;
end;

procedure TForm1.ListBox1DblClick(Sender: TObject);
begin
  WinExec(PChar(IEXPLORE+' "'+listbox1.items[listbox1.itemindex]+'"'),SW_NORMAL);
end;

end.

⌨️ 快捷键说明

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