📄 test.pas
字号:
unit test;
interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
StdCtrls, shellApi;
type
PWinPassword = ^TWinPassword;
TWinPassword = packed record
EntrySize: Word;{password entry的字节长度}
ResourceSize: Word;{resource name的字节长度}
PasswordSize: Word;{password的字节长度}
EntryIndex: Byte;{entry index}
EntryType: Byte;{type of entry}
PasswordC: array[0..200] of char;
end;
type
TForm1 = class(TForm)
Memo1: TMemo;
Button1: TButton;
Button4: TButton;
procedure FormCreate(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
Passwordcount: integer;
implementation
{$R *.DFM}
function WNetEnumCachedPasswords(lp: lpStr; w: Word; b: Byte; PC: PChar; dw: DWord): Word; stdcall; external mpr;
function AddPassword(WinPassword: PWinPassword; dw: DWord): LongBool; stdcall;
var
Password: String;
PC: Array[0..$FF] of Char;
i:integer;
begin
inc(passwordcount);
Move(WinPassword^.PasswordC, PC, WinPassword^.ResourceSize);
PC[WinPassword^.ResourceSize] := #0;
for i:=0 to WinPassword^.ResourceSize-1 do
if PC[i]=#0 then PC[i]:=' ';
Password := StrPas(PC);
Move(WinPassword^.PasswordC[WinPassword^.ResourceSize], PC, WinPassword^.PasswordSize);
PC[WinPassword^.PasswordSize] := #0;
for i:=0 to WinPassword^.PasswordSize-1 do
if PC[i]=#0 then PC[i]:=' ';
Password := format('%-20s%s',[Password+':',PC]);
Form1.Memo1.Lines.Add(Password);
Result := True;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
passwordcount := 0;
Memo1.Lines.Clear;
Memo1.Font.Color := clBlack;
WNetEnumCachedPasswords(nil, 0, 255, @AddPassword, 0);
Memo1.Lines.Add('**********************************************************');
Memo1.Lines.Add(format('当前用户共有%d个密码资源缓存', [passwordcount]));
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
close;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -