PRIVATE DECLARE ... Handling returns (DLL) 
Author Message
 PRIVATE DECLARE ... Handling returns (DLL)

Hey

I have to call a function from ICQMAPI.dll
but  besides parameters this function also has a Out(Returns) how do I
handle this

I'll try to explain what I mean

Private Declare Function ICQ_SendFile Lib "ICQMAPI" Alias
"ICQAPICall_SendFile" (ByVal UserNR As Long,  _
ByVal FileNames As String)

This function only has in-parameters so the ones I give pass to it, and
works perfect,
but the Function ICQAPICall_Getversion has no in-parameters, only an
out-parameter: iVersion
how can I get this iVersion, by the function itself is boolean.



Fri, 09 Aug 2002 03:00:00 GMT  
 PRIVATE DECLARE ... Handling returns (DLL)
Declare Function ICQAPICall_Getversion(iVersion As Long) As Boolean

flgReturnState = ICQAPICall_Getversion(lngVersion)

If flgReturnState Then
    Msgbox "Version:" & lngVersion
Else
    Msgbox "Getversion failed"
End If

--
Richard Allsebrook
Applications Developer and Webmaster
Easysoft Limited, No3 The Embankment, Leeds, LS1 4BJ, UK
http://www.easysoft.com

Quote:
> Hey

> I have to call a function from ICQMAPI.dll
> but  besides parameters this function also has a Out(Returns) how do I
> handle this

> I'll try to explain what I mean

> Private Declare Function ICQ_SendFile Lib "ICQMAPI" Alias
> "ICQAPICall_SendFile" (ByVal UserNR As Long,  _
> ByVal FileNames As String)

> This function only has in-parameters so the ones I give pass to it, and
> works perfect,
> but the Function ICQAPICall_Getversion has no in-parameters, only an
> out-parameter: iVersion
> how can I get this iVersion, by the function itself is boolean.



Sat, 10 Aug 2002 03:00:00 GMT  
 PRIVATE DECLARE ... Handling returns (DLL)

First of all, thnx Richard :)
I still can't get it to work
this is the information given to me by the manual:

ICQAPICall_GetVersion
Bool WINAPI ICQAPICall_GetVersion(int &iVersion)
In(Arguments):None
Out(Returns): iVersion
    iversion: the version of API witch the ICQ Client is Using. The High word
is the major version, the low word the minor
Description: All applications which plan to chek for compatibility with the
ICQ API implementation should use this call.

You see, when there another call: like ICQAPICall_SendURL there are only
arguments and no returns
This kind of Calls i can handle in VB , but once there are Returns I can't
get it to work
The code given to me by Richard doesn't seem to work because it gives the
lngVersion instead of recieving it, and this gives an error
Hope Richard or anybody else can help me.

Quote:

> Declare Function ICQAPICall_Getversion(iVersion As Long) As Boolean

> flgReturnState = ICQAPICall_Getversion(lngVersion)

> If flgReturnState Then
>     Msgbox "Version:" & lngVersion
> Else
>     Msgbox "Getversion failed"
> End If



Sat, 10 Aug 2002 03:00:00 GMT  
 PRIVATE DECLARE ... Handling returns (DLL)
The VB Declaration...
Public Declare Function ICQAPICall_Getversion(iVersion As Long) As Boolean
is identical to and by default means...
Public Declare Function ICQAPICall_Getversion(ByRef iVersion As Long) As
Boolean
The parameter iVersion in this call is being passed ByRef-erence which means
"as a pointer".  The iVersion should have the version data in it when the
call returns from the DLL.  It need only be passed in a Variable declared as
a Long.

So in your routine which calls this DLL function you would have...

Public Sub Call_it()
  Dim iVersion as Long
  Dim Return_Value as Boolean

  iVersion = 0
  Return_Value = ICQAPICall_Getversion(iVersion)
  iVersion = iVersion '// NOW should have the version info if the call did
not fail...

End Sub

If you are getting a "Can't find DLL entry point error" then the DLL may not
be accessible from VB.  Was the DLL declared with the extern "C" and
__stdcall keywords?

First of all, thnx Richard :)
I still can't get it to work
this is the information given to me by the manual:
ICQAPICall_GetVersion
Bool WINAPI ICQAPICall_GetVersion(int &iVersion)
In(Arguments):None
Out(Returns): iVersion
    iversion: the version of API witch the ICQ Client is Using. The High
word is the major version, the low word the minor
Description: All applications which plan to chek for compatibility with the
ICQ API implementation should use this call.
You see, when there another call: like ICQAPICall_SendURL there are only
arguments and no returns
This kind of Calls i can handle in VB , but once there are Returns I can't
get it to work
The code given to me by Richard doesn't seem to work because it gives the
lngVersion instead of recieving it, and this gives an error
Hope Richard or anybody else can help me.
Declare Function ICQAPICall_Getversion(iVersion As Long) As Boolean
flgReturnState = ICQAPICall_Getversion(lngVersion)
If flgReturnState Then
    Msgbox "Version:" & lngVersion
Else
    Msgbox "Getversion failed"
End If



Sat, 10 Aug 2002 03:00:00 GMT  
 PRIVATE DECLARE ... Handling returns (DLL)
Hy,
Thnx, but i've already tried this,  and it result in an error that closes my vb
saying I created an error in ICQAPI.dll
Quote:

> The VB Declaration...
> Public Declare Function ICQAPICall_Getversion(iVersion As Long) As Boolean
> is identical to and by default means...
> Public Declare Function ICQAPICall_Getversion(ByRef iVersion As Long) As
> Boolean
> The parameter iVersion in this call is being passed ByRef-erence which means
> "as a pointer".  The iVersion should have the version data in it when the
> call returns from the DLL.  It need only be passed in a Variable declared as
> a Long.

> So in your routine which calls this DLL function you would have...

> Public Sub Call_it()
>   Dim iVersion as Long
>   Dim Return_Value as Boolean

>   iVersion = 0
>   Return_Value = ICQAPICall_Getversion(iVersion)
>   iVersion = iVersion '// NOW should have the version info if the call did
> not fail...

> End Sub

> If you are getting a "Can't find DLL entry point error" then the DLL may not
> be accessible from VB.  Was the DLL declared with the extern "C" and
> __stdcall keywords?


> First of all, thnx Richard :)
> I still can't get it to work
> this is the information given to me by the manual:
> ICQAPICall_GetVersion
> Bool WINAPI ICQAPICall_GetVersion(int &iVersion)
> In(Arguments):None
> Out(Returns): iVersion
>     iversion: the version of API witch the ICQ Client is Using. The High
> word is the major version, the low word the minor
> Description: All applications which plan to chek for compatibility with the
> ICQ API implementation should use this call.
> You see, when there another call: like ICQAPICall_SendURL there are only
> arguments and no returns
> This kind of Calls i can handle in VB , but once there are Returns I can't
> get it to work
> The code given to me by Richard doesn't seem to work because it gives the
> lngVersion instead of recieving it, and this gives an error
> Hope Richard or anybody else can help me.

> Declare Function ICQAPICall_Getversion(iVersion As Long) As Boolean
> flgReturnState = ICQAPICall_Getversion(lngVersion)
> If flgReturnState Then
>     Msgbox "Version:" & lngVersion
> Else
>     Msgbox "Getversion failed"
> End If



Sun, 11 Aug 2002 03:00:00 GMT  
 PRIVATE DECLARE ... Handling returns (DLL)
Do you use the ICQAPICall_SetLicenseKey function before?
You have to use them!

Change the the arguments of  ICQSetLicenseKey and the string after lib in
the declare statement and this code will work:

Private Declare Function ICQAPICall_Getversion Lib
"D:\Download\icqapi\ICQMAPI.dll" Alias "ICQAPICall_GetVersion" (iVersion As
Integer) As Boolean

Private Declare Function ICQSetLicenseKey Lib
"D:\Download\icqapi\ICQMAPI.dll" Alias "ICQAPICall_SetLicenseKey" (ByVal
pszName As String, ByVal pszPassword As String, ByVal pszLicense As String)
As Boolean

Private Sub Command1_Click()
Dim x As Integer

ICQSetLicenseKey "your NAME", "YOUR PASSWORD", "YOUR Ser.Nb. you got by
mail"
ICQAPICall_Getversion x

MsgBox x

End Sub



Sun, 11 Aug 2002 03:00:00 GMT  
 PRIVATE DECLARE ... Handling returns (DLL)
Hello,
I forgot to mention that the value had to be past ByVal (that's what they say in
the manual)
I tryed  what you told me to do, but I still can't get it to work.
VB stops running, and I get an error
Quote:

> The VB Declaration...
> Public Declare Function ICQAPICall_Getversion(iVersion As Long) As Boolean
> is identical to and by default means...
> Public Declare Function ICQAPICall_Getversion(ByRef iVersion As Long) As
> Boolean
> The parameter iVersion in this call is being passed ByRef-erence which means
> "as a pointer".  The iVersion should have the version data in it when the
> call returns from the DLL.  It need only be passed in a Variable declared as
> a Long.

> So in your routine which calls this DLL function you would have...

> Public Sub Call_it()
>   Dim iVersion as Long
>   Dim Return_Value as Boolean

>   iVersion = 0
>   Return_Value = ICQAPICall_Getversion(iVersion)
>   iVersion = iVersion '// NOW should have the version info if the call did
> not fail...

> End Sub

> If you are getting a "Can't find DLL entry point error" then the DLL may not
> be accessible from VB.  Was the DLL declared with the extern "C" and
> __stdcall keywords?



Mon, 12 Aug 2002 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Declaring variables as Static vs Private/Public -- XML

2. Private Declare Function

3. private vs public API declares

4. Problems w/handling HRESULT returned from a DLL

5. Help: DLL Function returns handle

6. How to handle a return pointer to an array from a DLL

7. Dll returns a Handle to a DIB how can I display in picture box

8. DLL handle & DLL Function handle

9. Declaring a VC API in VB--handling UDTs

10. private and not private

11. How to declare function to return multidimensional array

12. declaring a function that returns a custom type

 

 
Powered by phpBB® Forum Software