Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

icq api

Posted on 2000-04-04
11
982 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
ID: 2686401
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
ID: 2688246
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
ID: 2688493
listenning
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 1

Expert Comment

by:X_Kalibur
ID: 2688908
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
ID: 2692305
what do i look for to find this porting program?
0
 
LVL 1

Expert Comment

by:new_x
ID: 2697468
Listening
0
 
LVL 1

Expert Comment

by:X_Kalibur
ID: 2721726
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
ID: 2721948
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
ID: 2721951
thanks for your help
0
 
LVL 1

Expert Comment

by:X_Kalibur
ID: 2725873
frangers,


i dont mind still helping you :)


-x
0
 
LVL 1

Expert Comment

by:X_Kalibur
ID: 2763202
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

861 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