ICQ API

Is anybody out there familiar with the ICQ API, and if so can I ask you some questions???
froglandAsked:
Who is Participating?
 
mrgentryConnect With a Mentor Commented:
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
 
froglandAuthor Commented:
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
 
froglandAuthor Commented:
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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
mrgentryCommented:
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
 
froglandAuthor Commented:
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
 
froglandAuthor Commented:
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
 
mrgentryCommented:
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
 
froglandAuthor Commented:
This does not work ??

for(j = 0; j < iCount; j++)
{
sprintf(szUsrIcqNo[j], "%x", pListDetails[j].m_iUIN);
}
0
 
froglandAuthor Commented:
Adjusted points to 220
0
 
mrgentryCommented:
What do you have szUsrIcqNo declared as?

0
 
froglandAuthor Commented:
char      szUsrIcqNo[20] [20];
0
 
mrgentryCommented:
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
 
froglandAuthor Commented:
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
 
mrgentryCommented:
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
 
froglandAuthor Commented:
mrgentry
Thanks for your help so far

I accidentally awarded you the points, but still have not solved the problem
0
 
froglandAuthor Commented:
fine
0
 
mrgentryCommented:
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
 
froglandAuthor Commented:
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
 
MirkwoodCommented:
Bought This Question.
0
 
maharaCommented:
and i'm not happy 'cas i've bought this one!!! :)))
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.