QQ訊息發送器

來源:互聯網
上載者:User

閑來無聊之作品,願與大家探討交流,共同進步!

//取QQ版本資訊函數

function ReadQQRegInf: boolean;
Var
  regRegistry : TRegistry;
begin
  result := True;
  regRegistry := TRegistry.Create;
  try
    try
      regRegistry.RootKey := HKEY_LOCAL_MACHINE;
      if regregistry.OpenKey('/SOFTWARE/Tencent/QQ',true) then
      begin
        gsQQInstall := regregistry.ReadString('Install');
        gsQQVersion := regregistry.ReadString('version');
      end;
      regregistry.CloseKey;
    except
      result := False;
    end;
  finally
    regregistry.Free;
  end;
end;

//發送事件處理

procedure TFrmMain.btnSendClick(Sender: TObject);
var
  h, h2, hChild, hChild2, hBtn: THandle;
  Buf: array[0..1024] of Char;
  i: integer;
  s, sPwd: string;
begin

  s := memosendMeg.Text;
  h := FindWindow(nil, pchar('與 '+cbFName.text+' 聊天中'));
  RichEdit1.Lines.Add(IntToHex(h, 8));

  if h=0 then
  begin
    Application.MessageBox('請確認與好友的聊天介面已開啟,並進入【訊息模式】!',
                           '錯誤', MB_OK+MB_ICONWARNING);
    exit;
  end;

  hChild := FindWindowEx(h, 0, nil, '');
  RichEdit1.Lines.Add(IntToHex(hChild, 8));

  hChild := FindWindowEx(h, hChild, nil, '');
  RichEdit1.Lines.Add(IntToHex(hChild, 8));

  hChild := FindWindowEx(h, hChild, nil, '');
  RichEdit1.Lines.Add(IntToHex(hChild, 8));

  hChild := FindWindowEx(h, hChild, nil, '');
  RichEdit1.Lines.Add(IntToHex(hChild, 8));

  h := hChild;

  hChild2 := FindWindowEx(h, 0, nil, '');
  RichEdit1.Lines.Add(IntToHex(hChild2, 8));

  hChild2 := FindWindowEx(h, hChild2, nil, '');
  RichEdit1.Lines.Add(IntToHex(hChild2, 8));

  //QQ2006官方正式版V06.0.200.370以下版本處理
  if StrtoFloat(gsQQVersion)<1595.370 then
  begin
    hChild2 := FindWindowEx(h, hChild2, nil, '');
    RichEdit1.Lines.Add(IntToHex(hChild2, 8));
  end;

  //如果是珊瑚蟲版可以取到ip地址資訊
  h2 := hChild2;

  hChild2:=GetWindow(h2,gw_hwndfirst);
  RichEdit1.Lines.Add(IntToHex(hChild2, 8));

  SendMessage(hChild2, WM_GETTEXT, 1024, Integer(@Buf));
  RichEdit1.Lines.Add(Buf);

  //取QQ號碼資訊
  hChild2 := FindWindowEx(h, h2, nil, Buf);
  //QQ2007Beta1 V07.0.101.162以上版本處理
  if StrtoFloat(gsQQVersion)>=1631.160 then
  begin
    hChild2 := FindWindowEx(h, h2, nil, '');
    hChild2 := FindWindowEx(h, h2, nil, '');
  end;
  h2 := GetWindow(hChild2, GW_CHILD);
  hChild2:=GetWindow(h2,gw_hwndfirst);
  RichEdit1.Lines.Add(IntToHex(hChild2, 8));

  SendMessage(hChild2, WM_GETTEXT, 1024, Integer(@Buf));
  RichEdit1.Lines.Add(Buf);

  if pos('(XXXXXXX)', Buf) > 0 then
  begin
    //這裡對想要屏蔽的QQ號處理

    exit;
  end;

  //"發送"按鈕控制代碼
  hBtn := FindWindowEx(h, 0, 'Button', '發送(S)');
  RichEdit1.Lines.Add(IntToHex(hBtn, 8));

  hChild := FindWindowEx(h, hBtn, 'AfxWnd42', '');
  RichEdit1.Lines.Add(IntToHex(hChild, 8));

  h := hChild;
  //QQ2006官方正式版V06.0.200.370以上版本處理
  if StrtoFloat(gsQQVersion)>=1595.370 then
    hChild := FindWindowEx(h, 0, 'RichEdit20A', '')
  else
    hChild := FindWindowEx(h, 0, 'RICHEDIT', '');  //預設處理

  RichEdit1.Lines.Add(IntToHex(hChild, 8));

   //向輸入框中加入尾巴
   SendMessage(hChild, EM_REPLACESEL, 1, integer(pchar(s)));
   SendMessage(hBtn, WM_LBUTTONDOWN, 0, 0);
   SendMessage(hBtn, WM_LBUTTONUP, 0, 0);
end; 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.