Solved

ICQ API

Posted on 1998-12-26
20
308 Views
Last Modified: 2013-12-03
Is anybody out there familiar with the ICQ API, and if so can I ask you some questions???
0
Comment
Question by:frogland
20 Comments
 

Author Comment

by:frogland
ID: 1417713
I am having trouble interpreting the meaning of this ICQ API call ?????

// header
typedef struct
{
int m_iUIN;
HWND m_hFloatWindow;
int m_iIP;
char m_szNickname[20];
char m_szFirstName[20];
char m_szLastName[20];
char m_szEmail[100];
char m_szCity[100];
char m_szState[100];
int m_iCountry;
char m_szCountryName[100];
char m_szHomePage[100];
int m_iAge;
char m_szPhone[20];
BYTE m_bGender;
int m_iHomeZip;
} BSICQAPI_User;

typedef BSICQAPI_User *BPSICQAPI_User;

// ICQAPICall_GetOnlineListDetails
BOOL WINAPI ICQAPICall_GetOnlineListDetails(int &iCount, BPSICQAPI_User **ppUsers);
// In (Arguments): None
// Out (Returns): iCount, ppUsers
// iCount - the number of Users to follow
// ppUsers - a pointer to the users’ array.
// Description: The data returned is in the order of the online list, top to bottom. The users array is initialized with the user’s ICQ# (m_iUIN field) and the Window Handle (m_hFloatWindow) if the user is “floating”. The users array should be freed by calling ICQAPIUtil_FreeUsers to free each user structure and the array itself.

int iCount;
BSICQAPI_User      *ppusers;

// When I call the above func it returns a list of user struct pointers in the following manner ...

ppusers->m_iUIN is a pointer to a user struct 0
ppusers->m_hFloatWindow is a pointer to a user struct1
ppusers->m_iIP is a pointer to a user struct 2
and so on down the list of struct members.

Whats going on here??????

0
 

Author Comment

by:frogland
ID: 1417714
OK if you look at the ICQ prototype you will know it is C++
and passes values by reference.
Now I am using C ( that dinosaur language) and passing by value.

But don't let that cloud the issue I have examined the generated asm by using both and it is identical.
Anyway no matter whether I write it in C or C++, I get the same result !!!

There is something really simple that I am not seeing here !!
SO can anybody see what I'm NOT ?????

This is the C version of my attempt.
 
// header snippet
// you already have struct details above in the intro to the question

typedef BOOL (WINAPI *LPGETLSTDET) (int *iCount, BSICQAPI_User **pUsers);

LPGETLSTDET lpGetLstDet; // disregard the ppusers above (same deal)

BSICQAPI_User      *pOwnerData;
BSICQAPI_User      *pListDetails;
int iCount;
UINT uReturnVal;

// the DLL has already been loaded sucessfully!
lpGetLstDet = (LPGETLSTDET) GetProcAddress(hDLL, "ICQAPICall_GetOnlineListDetails");
uReturnVal = lpGetLstDet (&iCount, &pListDetails);
// success
// Now assuming iCount is returned as =3

// Now what I find is
// pListDetails->m_iUIN is the address of the 1st pOwnerData struct
//pListDetails->m_hFloatWindow is the address of the 2nd OwnerData struct
//pListDetails->m_iIP is the address of the 3rd pOwnerData struct

so whats the guts here ??


0
 
LVL 1

Expert Comment

by:mrgentry
ID: 1417715
The function is passing you back an array of structs.
pListDetails[0]->m_iUIN should give the first member of the struct for the first user
pListDetails[1]->m_UIN should give the first member of the struct for the second user
. and so on.

0
 

Author Comment

by:frogland
ID: 1417716
mrgentry
this is the result of your suggestion

ICQDLLtest.c
C:\Program Files\DevStudio\MyProjects\ICQDLLtest\ICQDLLtest.c
(79) : error C2232: '->m_iUIN' : left operand has 'struct' type, use '.'
Error executing cl.exe.

ICQDLLtest.exe - 1 error(s), 0 warning(s)

0
 
LVL 1

Accepted Solution

by:
mrgentry earned 220 total points
ID: 1417717
oops :)  my mistake, just like the compiler said, it should be as follows:

pListDetails[0].m_iUIN should give the first member of the struct for the first user
pListDetails[1].m_UIN should give the first member of the struct for the second user
and so on.
0
 

Author Comment

by:frogland
ID: 1417718
mrgentry

could I please ask 1 more question, how would I access each structure say in a for next loop?

lpGetLstDet = (LPGETLSTDET) GetProcAddress hDLL,"ICQAPICall_GetOnlineListDetails");
uReturnVal = lpGetLstDet (&iCount, &pListDetails);

int j;

for(j=0;j<iCount;j++) {

// get pointers to user structs and do something ???????????

}
// Free array of structs
0
 
LVL 1

Expert Comment

by:mrgentry
ID: 1417719
lpGetLstDet = (LPGETLSTDET) GetProcAddress hDLL,"ICQAPICall_GetOnlineListDetails");
uReturnVal = lpGetLstDet (&iCount, &pListDetails);
int j;
for (j = 0; j < iCount; j++)
{
     // do whatever with the jth struct .. this would print out the nickname.
     printf("User %d has %s for a nickname and lives in %s.\n", j,  pListDetails[j].m_szNickname, pListDetails[j].m_szCity);
}

0
 

Author Comment

by:frogland
ID: 1417720
This does not work ??

for(j = 0; j < iCount; j++)
{
sprintf(szUsrIcqNo[j], "%x", pListDetails[j].m_iUIN);
}
0
 

Author Comment

by:frogland
ID: 1417721
Adjusted points to 220
0
 
LVL 1

Expert Comment

by:mrgentry
ID: 1417722
What do you have szUsrIcqNo declared as?

0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

by:frogland
ID: 1417723
char      szUsrIcqNo[20] [20];
0
 
LVL 1

Expert Comment

by:mrgentry
ID: 1417724
I don't see any reason why it wouldn't work (if you have less than 20 users).
What does it do?  I'm assuming that the lpGetLstDet call is returning a non-zero value.

0
 

Author Comment

by:frogland
ID: 1417725
I have 3 users online

This is the result of you proposed approach

pListDetails[0].m_iUIN      0x00d8000c // correct pointer
pListDetails[1].m_iUIN      0x00000000 // invalid pointer
pListDetails[2].m_iUIN      0x00000000 // invalid pointer

WHEREAS this is OK

pListDetails->m_iUIN          // correct pointer
pListDetails->m_hFloatWindow  // correct pointer
pListDetails->m_iIP           // correct pointer

And I could not use this approach in a real life program because what if I had more users on line than the amount of members in the BSICQAPI_User struct.

Something weird is going on ??
0
 
LVL 1

Expert Comment

by:mrgentry
ID: 1417726
I'm at a bit of a loss right now.  I'll have to come back to this later after I do some of my own work. :)
0
 

Author Comment

by:frogland
ID: 1417727
mrgentry
Thanks for your help so far

I accidentally awarded you the points, but still have not solved the problem
0
 

Author Comment

by:frogland
ID: 1417728
fine
0
 
LVL 1

Expert Comment

by:mrgentry
ID: 1417729
Out of curiosity, do you get same values for:
pListDetails->m_iUIN
ListDetails->m_hFloatWindow
pListDetails->m_iIP

as you do for:
pListDetails[0].m_iUIN
ListDetails[0].m_hFloatWindow
pListDetails[0].m_iIP

?
0
 

Author Comment

by:frogland
ID: 1417730
I will have a look at that and get back to you!

In the mean time, if you have time, could you please email me at mike@westglide.co.nz

I have a proposition that I would like to discuss in private.


0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1417731
Bought This Question.
0
 
LVL 2

Expert Comment

by:mahara
ID: 2727609
and i'm not happy 'cas i've bought this one!!! :)))
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

758 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

23 Experts available now in Live!

Get 1:1 Help Now