Solved

icq api

Posted on 2000-04-04
11
961 Views
Last Modified: 2008-03-17
i got a copy of the icq api off the icq website. But how do you use it, source examples would be appreciated - for how to send messages etc and how to put user info into fields of a program
0
Comment
Question by:frangers99
11 Comments
 
LVL 1

Accepted Solution

by:
X_Kalibur earned 50 total points
Comment Utility
Hi frangers99,


I've recently also d/l the ICQ api, and have studied it...

I can give you an outline of how it works, and give you source code on how to send messages, but i will have to look a bit into the user fields thing...


Basically, in order to use the ICQ api, you must initiate it...When you registered to download the ICQ API, Mirabilis would have sent back to you an authorisation key. You need to enter this key in order to gain access to the ICQ API...
Once you have initiated the ICQ API successfully, then all you need to do is to call the functions you have imported from the DLL unit...


Pasted below is a test program which i have created to automatically open a Send Message window, and then send the message..


unit icqAPI;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Registry;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    procedure FormActivate(Sender: TObject);
  private
    function GetICQWindow : Boolean;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  MoreButtonHandle : HWND;
  OnlineOfflineHandle : HWND;
  RichEditHandle : HWND;
  SendButtonHandle : HWND;
  SendMessageWindowHandle : HWND;

const
  Your_Text_Message = 'Testing Anti-marcus Auto insulter...If you get this, plz reply so';
  Receiver_UIN = 3181456;
  Owner_UIN = '1189145';
  pwd = 'Your Password to access the API';

implementation

{$R *.DFM}

function ICQAPICall_SetLicenseKey(Name, Password, License : PChar) : Boolean; stdcall; external 'ICQMAPI.dll' name 'ICQAPICall_SetLicenseKey';

function ICQAPICall_SendMessage(UIN : LongInt; YourMessage : PChar) : Boolean; stdcall; external 'ICQMAPI.dll' name 'ICQAPICall_SendMessage';

procedure TForm1.Button1Click(Sender: TObject);
var
  WindowName : array[0..65] of char;
  Counter : Integer;
begin
  Counter := 0;
  while Counter <> SizeOf(WindowName) do
    begin
      WindowName[Counter] := #0;
      inc(Counter);
    end;

  ICQAPICall_SendMessage(Receiver_UIN, PChar(Your_Text_Message));
  SendMessageWindowHandle := FindWindow(nil, 'Send Message Later');
  if SendMessageWindowHandle = 0 then
    begin
      SendMessageWindowHandle := FindWindow(nil, 'Send Offline Message');
      if SendMessageWindowHandle = 0 then
        begin
          SendMessageWindowHandle := FindWindow(nil, 'Send Online Message');
          if SendMessageWindowHandle = 0 then
            begin
              Showmessage('Could not establish a messaging connection with ICQ' + #13 + #13 + 'Terminating process');
              exit;
            end;
        end;
    end;

  RichEditHandle := FindWindowEx(SendMessageWindowHandle, 0, 'RICHEDIT', nil);
  SendButtonHandle := FindWindowEx(SendMessageWindowHandle, 0, 'Button', '&Send');
  MoreButtonHandle := FindWindowEx(SendMessageWindowHandle, 0, 'Button', '');
  OnlineOfflineHandle := FindWindowEx(SendMessageWindowHandle, 0, 'Button', 'Send &later,when recipient(s):');

  GetWindowText(SendMessageWindowHandle, WindowName, 65);
  if ((Windowname = 'Send Offline Message') OR (WindowName = 'Send Online Message')) then
    begin
      SendMessage(MoreButtonHandle, BM_CLICK, 0, 0);
      SendMessage(OnlineOfflineHandle, BM_CLICK, 0, 0);
    end;

  SendMessage(SendButtonHandle, BM_CLICK, 0, 0);
end;

procedure TForm1.FormActivate(Sender: TObject);
begin
  if ((NOT(ICQAPICall_SetLicenseKey(<YOUR NAME>', pwd, '<YOUR ACCESS KEY')) OR (NOT(GetICQWindow)){ OR (GetNetStatus <> 1)})) then
    begin
      showmessage('Could not connect to ICQ...Is it running?? Are you connected to the net?');
      close;
    end;
end;

function TForm1.GetICQWindow : Boolean;
var
  Temp : HWND;
begin
  Temp := FindWindow(nil, Owner_UIN);

  if Temp = 0 then
    Result := false
  else
    Result := True;
end;

end.



Basically, when you call the the ICQ API SendMessage function, it opens up a message window with the text you want placed inside  as the body of the message...
Unfortunately, it does not automatically send the message...

I have the procedure to find the window, and send the message, into the Button1.Click event...
It basically looks around for the Message Window, captures that window's handle. It then toggles the "Send Message when user is Offline/Online", and then searches for the "Send" button...It then tells the send button to press, and PRESTO! the message is sent! The reason it toggles the send message when either online or offline, is so that the message is sent regardless of whether the reciepient is disconnected or not...
For example, if the message window pops up, but i get cut off ICQ, and try to send it, then ICQ will pop up another messagem saying it cannot connect to the ICQ server...In order to make the automatic sending of mesages smooth, you *Must* toggle this option

(Actually, this code is not complete...When you send a message, the caption of the message window depends upon the state the user is in...For example...if i am in N/A mode, then the caption of the message window is "Send Message Later [User is in N/A Mode]"...
But if my status is is online, then the mesage window caption is "Send Message Later"....So in oredr to get it fully working, you need to actually scan through and look for all sorts of window captions (N/A mode, Away mode, Offline, Online, Busy etc...)


I havent got too much time today to help you...But if you have problems, i'll be back tomorrow or whenever...

if you dont understand anything, then i'll be happy to explain it to you :)


hth,

x
0
 

Author Comment

by:frangers99
Comment Utility
that looks pretty cool, i know how to press external buttons so that is fine, any other cool functions that i should know about?

Or do i just give you the points now?
0
 
LVL 3

Expert Comment

by:bryan7
Comment Utility
listenning
0
 
LVL 1

Expert Comment

by:X_Kalibur
Comment Utility
frangers,


You can get a list of all the functions from the ICQ API documentation...Then, you can simply port the C Type library headers into delphi, and use the functions directly, as if they were methods and procedures within Delphi!

If you have any more questions about this, i'd be happy to answer them too (provided i know the answers ;)

hth,

x


ps...If your not familiar with the porting of C Headers to Delphi, i have seen a program floating somewhere on the Internet which can autmatically do this for you...this will be a very handy tool to use for this sort of thing, cause you may also need to import different type structures depending on what you want to do...

0
 

Author Comment

by:frangers99
Comment Utility
what do i look for to find this porting program?
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 1

Expert Comment

by:new_x
Comment Utility
Listening
0
 
LVL 1

Expert Comment

by:X_Kalibur
Comment Utility
Frangers,


You will just have to lookk around....Sorry..I cant remember where to get it from..


So if that settles your problems re ICQ, whats the arrangement with the points?

thx

-x
0
 

Author Comment

by:frangers99
Comment Utility
you're a keen been for points? nah, thanks for your help, I'll have a look for myself, thanks!
0
 

Author Comment

by:frangers99
Comment Utility
thanks for your help
0
 
LVL 1

Expert Comment

by:X_Kalibur
Comment Utility
frangers,


i dont mind still helping you :)


-x
0
 
LVL 1

Expert Comment

by:X_Kalibur
Comment Utility
howdy Fangers,

i'd been going through the project-jedi website, and ran across header translations for the ICQ api..

ftp://delphi-jedi.org/api/icq.zip

hth!

-x

0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now