您现在的位置:首页 >> API >> API >> 内容

Delphi通过FindWindowEx来获取当前运行着的QQ号码列表

时间:2011/9/3 14:53:24 点击:

  核心提示:以下为封好的 Delphi 类type TGetQQNumber = classqqlist: TStrings; privateprocedure GetList(ClassName:String)...
以下为封好的 Delphi 类
type
    TGetQQNumber = class
qqlist: TStrings;
    private
procedure GetList(ClassName:String);
    public
constructor Create();
destructor Destroy(); override;
end;

constructor TGetQQNumber.Create;
begin
    qqlist := TStringList.Create;
//    Afx:61790000:2 为窗口类名
    GetList('Afx:61790000:2');//QQ2006 STD
    GetList('Afx:61800000:2');//QQ2007 Beta3
    GetList('Afx:61810000:2');//按规律随意添加的,不知道对不对
    GetList('Afx:61820000:2');//按规律随意添加的,不知道对不对
    GetList('Afx:61830000:2');//按规律随意添加的,不知道对不对
    GetList('Afx:61840000:2');//QQ2007 Beta4
end;

destructor TGetQQNumber.Destroy;
begin
    qqlist.Free;
end;

procedure TGetQQNumber.GetList(ClassName: String);
var
    Wnd: DWord;
    Buf: array[0..255] of char;
    i: integer;
begin
    Wnd := 0;
    repeat
Wnd := FindWindowEx(0, Wnd, pchar(ClassName), nil);
GetWindowText(Wnd, Buf, 255);
if buf <> '' then
begin
    for i := 0 to 255 do
    begin
        if Buf[i] = '_' then
        begin
       Buf[i] := #0;
       break;
        end;
    end;
    qqlist.Add(buf);
end;
    until (Wnd = 0);
end;
编译完成的EXE在附件.测试QQ2006STD 2007B3 2007B4能正确获取.其他版本的支持需要找出对应的窗口类名.

作者:网络 来源:转载
共有评论 0相关评论
发表我的评论
  • 大名:
  • 内容:
本类推荐
  • 没有
本类固顶
  • 没有
  • 盒子文章(www.2ccc.com) © 2024 版权所有 All Rights Reserved.
  • 沪ICP备05001939号