|

楼主 |
发表于 2008-4-25 20:30:13
|
显示全部楼层
从http://74.220.217.145/bbs/viewthread.php?tid=819找的菜新大哥的帖子
注册表定位 菜新 
版主
  
万剑归宗
| 1楼 大 中 小 发表于 2007-10-31 18:01 只看该作者
  注册表定位
The code:以文本方式查看复制代码打印关于程序
- unit Unit1;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls;
-
- type
- TForm1 = class(TForm)
- Button1: TButton;
- procedure Button1Click(Sender: TObject);
- procedure JumpToKey(Key: string);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.dfm}
-
- uses
- ShellApi;
-
- procedure TForm1.JumpToKey(Key: string);
- var
- i, n: Integer;
- hWin: HWND;
- ExecInfo: ShellExecuteInfoA;
- begin
- hWin := FindWindowA(PChar('RegEdit_RegEdit'), nil);
- if hWin = 0 then
- {if Regedit doesn't run then we launch it}
- begin
- FillChar(ExecInfo, 60, #0);
- with ExecInfo do
- begin
- cbSize := 60;
- fMask := SEE_MASK_NOCLOSEPROCESS;
- lpVerb := PChar('open');
- lpFile := PChar('regedit.exe');
- nShow := 1;
- end;
- ShellExecuteExA(@ExecInfo);
- WaitForInputIdle(ExecInfo.hProcess, 200);
- hWin := FindWindowA(PChar('RegEdit_RegEdit'), nil);
- end;
- ShowWindow(hWin, SW_SHOWNORMAL);
- hWin := FindWindowExA(hWin, 0, PChar('SysTreeView32'), nil);
- SetForegroundWindow(hWin);
- i := 30;
- repeat
- SendMessageA(hWin, WM_KEYDOWN, VK_LEFT, 0);
- Dec(i);
- until i = 0;
- SendMessageA(hWin, WM_KEYDOWN, VK_RIGHT, 0);
- i := 1;
- n := Length(Key);
- repeat
- if Key = '\' then
- begin
- SendMessageA(hWin, WM_KEYDOWN, VK_RIGHT, 0);
- end
- else
- SendMessageA(hWin, WM_CHAR, Integer(Key), 0);
- i := i + 1;
- until i = n;
- end;
-
- procedure TForm1.Button1Click(Sender: TObject);
- begin
- JumpToKey('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer');
- end;
-
- end.
|
[ 本帖最后由 icecept 于 2008-4-25 20:32 编辑 ] |
|