开发一个密码查看器

2016-02-19 12:37 2 1 收藏

有一种朋友不在生活里,却在生命力;有一种陪伴不在身边,却在心间。图老师即在大家的生活中又在身边。这么贴心的服务你感受到了吗?话不多说下面就和大家分享开发一个密码查看器吧。

【 tulaoshi.com - 编程语言 】

  现在有很多软件都有密码输入对话框。上面显示的是*标识符。如果想查看其字符串并不难。下面我们就用delphi使用API函数来开发一个查看其密码字符的程序吧。

  功能:当鼠标移动到密码处就会在程序的指定地方显示其字符串。

  问题一:当鼠标移动到密码对话框处时查找出此处的控件句柄。这样才可以对这个对象进行操作.具体实现如下:

  function gethwnd(): thandle;
  var
    hwnd: thandle;
    wndpoint: tpoint;
  begin
  
  try
      GetCursorPos(wndpoint); //获取鼠标指针
      hwnd:=WindowFromPoint(wndpoint);
      Result:=wndpoint
    except
      Result:=0;
    end;
  end;

  问题二: 根据获取的句柄得到此对象的密码字符。具体实现如下:

  function getpass(var hwnd: thandle): string;
  var
    passbuf: integer;
    passlong: longint;
    passText: PChar;
  begin
  
  passlong:=SendMessage(hwnd,WM_GETTEXTLENGTH,0,0)+1; //获取此对象的长度
  
  GetMem(passText,passlong); //开辟一个内存区。存放数据长度为passlong
  
  passbuf:=LongInt(passtext); //获取此数据区的首地址
    SendMessage(hwnd,WM_GETTEXT,passlong,passbuf); //发送消息让此对象将密码数据存入首地址为passbuf的数据区。存入长度为passlong
  
  result:=passtext;
  end;

  这样主要问题都解决了。还可以使用GetClassName,GetWindowText等API函数将此对象的类、标题等都读出来。以下是源代码,在delphi6.0+winXP测试通过,仅供参考。

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/bianchengyuyan/)

  
  {-----------------------------pas内容--------------------------------------}
  unit getwnd;

  interface

  uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs, StdCtrls, ExtCtrls, Menus;

  type
    TForm1 = class(TForm)
      Label1: TLabel;
      Label2: TLabel;
      Label3: TLabel;
      Label4: TLabel;
      Timer1: TTimer;
      Label5: TLabel;
      Label6: TLabel;
      PopupMenu1: TPopupMenu;
      N1: TMenuItem;
      Shape1: TShape;
      Shape2: TShape;
      Shape3: TShape;
      Shape4: TShape;
      N2: TMenuItem;
      procedure Timer1Timer(Sender: TObject);
      procedure N1Click(Sender: TObject);
      procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
        Shift: TShiftState; X, Y: Integer);
      procedure FormMouseUp(Sender: TObject; Button: TMouseButton;
        Shift: TShiftState; X, Y: Integer);
      procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
        Y: Integer);
      procedure FormCreate(Sender: TObject);
      procedure N2Click(Sender: TObject);
    private
      { Private declarations }
    public
       procedure Createparams(Var Params:TCreateParams);override;
      { Public declarations }
    end;

  var
    Form1: TForm1;
    hwnd,htemp:THandle;
    point,mouse:TPoint;
    wndcaption:array[0..255] of char;
    wndclass:array[0..255] of char;
    fmove: boolean;

  implementation

  {$R *.dfm}

  procedure TForm1.Timer1Timer(Sender: TObject);
  var
    buf: integer;
    ret: longint;
    mText:PChar;
  begin
     GetCursorPos(point);
     htemp:=WindowFromPoint(point);
     if hwndhtemp then
     begin
        hwnd:=htemp;
        GetClassName(hwnd,wndclass,256);
        GetWindowText(hwnd,wndcaption,256);
        if wndcaption='' then
        begin
           Ret:=SendMessage(hwnd,WM_GETTEXTLENGTH,0,0)+1;
           GetMem(mText,Ret);
           buf:=LongInt(mtext);
           SendMessage(hwnd,WM_GETTEXT,ret,buf);
           label4.Caption:=mText;
        end else
           label4.Caption:=wndcaption;
        label3.Caption:=inttostr(hwnd);
        label6.Caption:=wndclass;
     end;

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/bianchengyuyan/)

  end;

  procedure TForm1.N1Click(Sender: TObject);
  begin
    close;
  end;

  procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
    Shift: TShiftState; X, Y: Integer);
  begin
    fmove:=true;
    mouse.X:=x;
    mouse.Y:=y;
  end;

  procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
    Shift: TShiftState; X, Y: Integer);
  begin
    fmove:=false;
  end;

  procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
    Y: Integer);
  begin
     if fmove then
     begin
        top:=top+y-mouse.Y;
        left:=left+x-mouse.X;
     end;
  end;

  procedure TForm1.FormCreate(Sender: TObject);
  begin
     left:=screen.Width-width-3;
     top :=screen.Height-height-34;
  end;

  procedure TForm1.Createparams(var Params: TCreateParams);
  var
    wndParnet: THandle;
  begin
    Inherited CreateParams(Params);
    With Params do
    begin
     EXStyle:=ExStyle or WS_EX_TOPMOST OR WS_EX_ACCEPTFILES;
     wndParnet:=GetDesktopWindow;
    end;
  end;

  procedure TForm1.N2Click(Sender: TObject);
  begin
     timer1.Enabled:=not timer1.Enabled;
     if timer1.Enabled then
        n2.Caption:='暂停'
     else
        n2.Caption:='开始';
  end;

  end.
  {-------------------------------------------------------------------------}

  
  {----------------------------dfm内容--------------------------------------}
  object Form1: TForm1
    Left = 308
    Top = 302
    BorderStyle = bsNone
    Caption = 'xiewh_open'
    ClientHeight = 59
    ClientWidth = 179
    Color = clBtnFace
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -11
    Font.Name = 'MS Sans Serif'
    Font.Style = []
    OldCreateOrder = False
    PopupMenu = PopupMenu1
    OnCreate = FormCreate
    OnMouseDown = FormMouseDown
    OnMouseMove = FormMouseMove
    OnMouseUp = FormMouseUp
    PixelsPerInch = 96
    TextHeight = 13
    object Shape1: TShape
      Left = 0
      Top = 0
      Width = 179
      Height = 2
      Align = alTop
      Pen.Color = clBlue
      OnMouseDown = FormMouseDown
      OnMouseMove = FormMouseMove
      OnMouseUp = FormMouseUp
    end
    object Label1: TLabel
      Left = 8
      Top = 11
      Width = 57
      Height = 13
      AutoSize = False
      Caption = #21477#26564#21495#65306
      Transparent = True
    end
    object Label2: TLabel
      Left = 8
      Top = 26
      Width = 64
      Height = 13
      AutoSize = False
      Caption = #26631#39064#21517#65306
      Transparent = True
    end
    object Label3: TLabel
      Left = 56
      Top = 12
      Width = 117
      Height = 13
      AutoSize = False
      Transparent = True
    end
    object Label4: TLabel
      Left = 56
      Top = 25
      Width = 117
      Height = 13
      AutoSize = False
      Transparent = True
    end
    object Label5: TLabel
      Left = 8
      Top = 40
      Width = 56
      Height = 13
      Caption = #31867#12288#21517#65306
      Transparent = True
    end
    object Label6: TLabel
      Left = 56
      Top = 39
      Width = 117
      Height = 13
      AutoSize = False
      Transparent = True
    end
    object Shape2: TShape
      Left = 0
      Top = 0
      Width = 2
      Height = 73
      Pen.Color = clActiveCaption
      Pen.Width = 2
    end
    object Shape3: TShape
      Left = 0
      Top = 57
      Width = 179
      Height = 2
      Align = alBottom
      Pen.Color = clBlue
      Pen.Width = 2
    end
    object Shape4: TShape
      Left = 177
      Top = -1
      Width = 2
      Height = 71
      Pen.Color = clBlue
      Pen.Width = 2
    end
    object Timer1: TTimer
      Interval = 100
      OnTimer = Timer1Timer
      Left = 120
      Top = 32
    end
    object PopupMenu1: TPopupMenu
      Left = 88
      Top = 32
      object N2: TMenuItem
        Caption = #26242#20572
        OnClick = N2Click
      end
      object N1: TMenuItem
        Caption = #36864#20986
        OnClick = N1Click
      end
    end
  end

  {--------------------------------------------------------------------------}

   

   

   

   

   

   

来源:https://www.tulaoshi.com/n/20160219/1601323.html

延伸阅读
标签: Delphi
  先行知识:Delphi/COM/OLEAutomation/SQLServer 难度:★★☆☆☆ 在前几篇文章中我们已经讨论过关于VCL和OLE的知识。在这篇文章中我们将完成一个比较有实际意义的OLEAutomation服务器程序,最后我们把他们封装为Delphi中使用的VCL组件。 首先我们来做一个实际的程序,在它没有变为服务器之前,这是个用来管理客户购...
自己编写的进程查看/管理软件,除实现W2K的进程管理器功能外,还可查看各进程所调用的文件、结束任务并删除文件、复制模块文件等功能。 除NT4外,其它操作系统包括98、ME、2K、XP等均可正常使用。 下载地址 :http://www.freewebs.com/kacarton/software/kktproview.rar (235K) (国外免费空间,速度有点问题,请耐心等待或换时间...
一、概述 文本编辑器是一种最常用的应用程序,下面我们利用Jbuilder 9集成开发环境,用Java语言实现一个简单的文本编辑器。该文本编辑器具有读出、写入、编辑文本文件,可以设定文字颜色、字形和编辑区域背景颜色等基本功能。 我们首先通过Jbuilder 9项目向导和应用向导创建项目,然后应用可视化设计工具,修改UI设计,连接事件,编辑...
TM聊天记录查看器如何使用   TM聊天记录查看器(提示:注册1套,可以在3台电脑上使用)本软件可以不用密码查看TM聊天记录。 使用方法,直接运行,然后选者要读取的TM号码,然后点击要查看号码就可以查看聊天记录了。本软件可以看到安装本软件以前的聊天记录。 注意:本软件必须安装到目标号码使用的电脑才有效,因为软件只能...
标签: windows10
win10事件查看器如何使用   事件查看器打开方法: 1、直接在Win10任务栏的搜索框种,搜索事件查看器,就可以快速找到了。 2、然后点击最顶部的时间查看器就可以进入了。 Win10事件查看器使用方法: 1、打开事件查看器后,使用方法非常简单,我们可以依次展开功能,比如需要查看系统日志,可以依次展开...

经验教程

269

收藏

20
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部