新建一个项目,添加一个button
procedure TForm1.Button1Click(Sender: TObject);
var
hw,h1,h2,h3,h4,h5:HWND;
begin
hw:=0;
h1 :=0;
h2 :=0;
h3 :=0;
winExeC(PChar('control userpasswords2'),SW_SHOW );
hw :=findwindow(nil, '用户帐户');
if hw=0 then
exit;
h1 :=FindWindowEX(hw,0,'SysTabControl32',nil);
if h1=0 then
exit;
//sleep(1000);
SendMessage(h1,$1330, 1, 0);
h2 :=FindWindowEX(hw,0,'#32770','高级');
if h2=0 then
exit;
h3 :=FindWindowEX(h2,0,'Button','管理密码(&M)');
if h3=0 then
exit;
SendMessage(h3,BM_CLICK, 1, 0);
hw:=0;
h1 :=0;
h2 :=0;
h3 :=0;
hw :=findwindow(nil, '存储用户名和密码');
if hw=0 then
showmessage('error1');
h1 :=FindWindowEX(hw,0,'Button','添加(&A)');
if h1=0 then
showmessage('error2');
SendMessage(h1,BM_CLICK, 1, 0);
//sleep(100);
//hw :=0;
h2 :=FindWindowEX(hw,0,'#32770','登录信息属性');
//hw :=findwindow(nil, '登录信息属性');
if h2=0 then
showmessage('error3');
end;
procedure TForm1.Button1Click(Sender: TObject);
var
hw,h1,h2,h3,h4,h5:HWND;
begin
hw:=0;
h1 :=0;
h2 :=0;
h3 :=0;
winExeC(PChar('control userpasswords2'),SW_SHOW );
hw :=findwindow(nil, '用户帐户');
if hw=0 then
exit;
h1 :=FindWindowEX(hw,0,'SysTabControl32',nil);
if h1=0 then
exit;
//sleep(1000);
SendMessage(h1,$1330, 1, 0);
h2 :=FindWindowEX(hw,0,'#32770','高级');
if h2=0 then
exit;
h3 :=FindWindowEX(h2,0,'Button','管理密码(&M)');
if h3=0 then
exit;
SendMessage(h3,BM_CLICK, 1, 0);
hw:=0;
h1 :=0;
h2 :=0;
h3 :=0;
hw :=findwindow(nil, '存储用户名和密码');
if hw=0 then
showmessage('error1');
h1 :=FindWindowEX(hw,0,'Button','添加(&A)');
if h1=0 then
showmessage('error2');
SendMessage(h1,BM_CLICK, 1, 0);
//sleep(100);
//hw :=0;
h2 :=FindWindowEX(hw,0,'#32770','登录信息属性');
//hw :=findwindow(nil, '登录信息属性');
if h2=0 then
showmessage('error3');
end;
var
hw,h1,h2,h3,h4,h5:HWND;
begin
hw:=0;
hw :=findwindow(nil, '登录信息属性');
if hw=0 then
showmessage('error3');
end;
var
hw,h1,h2,h3,h4,h5:HWND;
begin
hw:=0;
h1 :=0;
h2 :=0;
h3 :=0;
winExeC(PChar('control userpasswords2'),SW_SHOW );
hw :=findwindow(nil, '用户帐户');
if hw=0 then
exit;
h1 :=FindWindowEX(hw,0,'SysTabControl32',nil);
if h1=0 then
exit;
SendMessage(h1,$1330, 1, 0);
h2 :=FindWindowEX(hw,0,'#32770','高级');
if h2=0 then
exit;
h3 :=FindWindowEX(h2,0,'Button','管理密码(&M)');
if h3=0 then
exit;
SendMessage(h3,BM_CLICK, 1, 0);
hw:=0;
h1 :=0;
h2 :=0;
h3 :=0;
hw :=findwindow(nil, '存储用户名和密码');
if hw=0 then
showmessage('error1');
h1 :=FindWindowEX(hw,0,'Button','添加(&A)');
if h1=0 then
showmessage('error2');
SendMessage(h1,BM_CLICK, 1, 0);
sleep(5000); //留5秒时间关掉sendmessage点开的对话框并自己手动点击打开新的对话框 hw :=0;
hw :=findwindow(nil, 'Form1');
if hw=0 then
showmessage('error3');
h2 :=findwindow(nil,'登录信息属性');
if h2=0 then
showmessage('error4')
else
showmessage(inttostr(h2));end;