Dll's and CallBacks 
Author Message
 Dll's and CallBacks

I am a Visual C++ guy trying to help out a VB guy.
Here is my problem.

In RasApi32.dll, the func RasDial, can be passed a callback func*(
atleast in VC++ ).

In his app, RasDial has been declared as:

Public Declare Function RasDial Lib"RasApi32.dll" Alias "RasDialA"
(ByVal lpRasDialExtensions As Any,
ByVal lpszPhonebook As String,
lprasdialparams As Any,
ByVal dwNotifierType As Long,
ByVal lpvNotifier As Long,
lphRasConn As Long) As Long

I am calling RasDial with notifier type '0'
and am passing a pointer to my "RasDialFunc"
using the 'AddressOf' operator.

My RasDialFunc is defined as
RasDialFunc( lMsg as long,
            rasConnState as long,
            lError as long )

The callback is being called _once_ and then VB acc vio's and goes away
(as VB does).

Can someone please help me out with this?  The documentation I read
stated that if params are not correctly specifed with ByVal or ByRef(
or neither ), that my behavior could be exhibited.  I have an ATL
object that does all this ras stuff, but the guy wanted to use vb to do
it all, instead of using the object.

Any help would be appreciated.

Thanks

Donnie

Sent via Deja.com http://www.*-*-*.com/
Share what you know. Learn what you don't.



Tue, 29 Jan 2002 03:00:00 GMT  
 Dll's and CallBacks
I have no direct knowledge of your problem/solution but would like to offer
these comments -- they may help as they have helped me.

1)  VB does not always like the 'Any' type.
You can manually re-declare the declaration to replace 'Any' with
String/Long or any VB intrinsic type (no object or variant).
2) When passing long values use the , 0&,  (this casts the Zero to a long).
3) Ensure that the 'AddressOf()' is obtaining the callback
function(-pointer) from a BAS-module.  It won't work coming from a Form.
4) Ensure that the 'callback' function has it's parameters arrange and typed
correctly and that it's return value is assigned a proper value and typed
correctly.
5) If you are sending in empty strings, pass in vbNullString not "".

Good luck...hope this helps...John
PS) Read the VB BOOKS-ONLINE  with the same subject as your initial
newsgroup query.

Quote:

>I am a Visual C++ guy trying to help out a VB guy.
>Here is my problem.

>In RasApi32.dll, the func RasDial, can be passed a callback func*(
>atleast in VC++ ).

>In his app, RasDial has been declared as:

>Public Declare Function RasDial Lib"RasApi32.dll" Alias "RasDialA"
>(ByVal lpRasDialExtensions As Any,
>ByVal lpszPhonebook As String,
>lprasdialparams As Any,
>ByVal dwNotifierType As Long,
>ByVal lpvNotifier As Long,
>lphRasConn As Long) As Long

>I am calling RasDial with notifier type '0'
>and am passing a pointer to my "RasDialFunc"
>using the 'AddressOf' operator.

>My RasDialFunc is defined as
>RasDialFunc( lMsg as long,
>            rasConnState as long,
>            lError as long )

>The callback is being called _once_ and then VB acc vio's and goes away
>(as VB does).

>Can someone please help me out with this?  The documentation I read
>stated that if params are not correctly specifed with ByVal or ByRef(
>or neither ), that my behavior could be exhibited.  I have an ATL
>object that does all this ras stuff, but the guy wanted to use vb to do
>it all, instead of using the object.

>Any help would be appreciated.

>Thanks

>Donnie

>Sent via Deja.com http://www.deja.com/
>Share what you know. Learn what you don't.



Tue, 29 Jan 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. creating a callback function in c++ dll to callback a VB function in an exe

2. CallBacks And Dll's

3. Can't pass string from C DLL to VB Callback fcn

4. OLE Callback vs Implemented Interface Callback

5. OLE Callback vs Implemented Interface Callback

6. What's wrong with this callback routine

7. What's wrong with this callback routine?

8. What's the differance between a ActiveX.dll and regular dll's

9. Taking apart DLL's/Smaller DLL's

10. How to handle CALLBACK's in VB

11. VC++ COM Callback doesn't work in VB ActiveX

12. Problems with callback reference to a COM object - which isn't a source of events

 

 
Powered by phpBB® Forum Software