Home > Archive > Visual Basic Syntax > March 2005 > DLL Callbacks
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Johnny McKeon 2005-03-01, 4:02 pm |
| Hello all,
I am a C++ developer who wrote a DLL that some VBers are now tryin to use.
Since they are having problems I am tryin to write a VB bas file for them
that declares all the functions and (many) callbacks.
So my question is: how to access the pointer variables in the DLL to assign
them a function pointer from the BAS unit?
HELP basically only refers to calling functions that require a function
pointer in the argument list. Can addressof only be used in this manner?
I guess what I'm asking is, is there a DECLARE equivalent for variables
exposed by a DLL??
Appreciated any help you can give me.
Thanks
John
| |
| Tony Proctor 2005-03-01, 4:02 pm |
| The declare statement can only declare external procedures (Sub/Function)
John. Obviously, you can provide a pair of procedures to get/set the value
of a arbitrary variable, but VB can't access them directly. It would be
tidier from the VB point of view if your DLL could expose a class that could
instantiated in order to configure these variables.
I'm not sure exactly what the question was regarding AddressOf. It is a
slightly odd operator as it's only valid in argument lists. However, there's
a common workaround to using it in plain assignment statements:
Private Function GetAddressOf(lAddr As Long) As Long
GetAddressOf = lAddr
End Function
Dim lpCallback As Long
lpCallback = GetAddress (AddressOf MyCallback)
Tony Proctor
"Johnny McKeon" <p3anoman@nospam.earthlink.net> wrote in message
news:Xns960C551F16419p3anomanearthlinkne
t@216.196.97.131...
> Hello all,
>
> I am a C++ developer who wrote a DLL that some VBers are now tryin to use.
> Since they are having problems I am tryin to write a VB bas file for them
> that declares all the functions and (many) callbacks.
>
> So my question is: how to access the pointer variables in the DLL to
assign
> them a function pointer from the BAS unit?
>
> HELP basically only refers to calling functions that require a function
> pointer in the argument list. Can addressof only be used in this manner?
>
> I guess what I'm asking is, is there a DECLARE equivalent for variables
> exposed by a DLL??
>
> Appreciated any help you can give me.
>
> Thanks
> John
| |
| Johnny McKeon 2005-03-01, 4:02 pm |
| Thanks Tony for your prompt reply.
"Tony Proctor" <tony_proctor@aimtechnology_NoMoreSPAM_.com> wrote in
news:OKmtFlmHFHA.2552@TK2MSFTNGP10.phx.gbl:
> The declare statement can only declare external procedures
> (Sub/Function) John. Obviously, you can provide a pair of procedures
> to get/set the value of a arbitrary variable, but VB can't access them
> directly. It would be tidier from the VB point of view if your DLL
> could expose a class that could instantiated in order to configure
> these variables.
I really didnt want to write another function to allow the population of
allthese callbacks but it looks like thats the way we'll have to go...
Thanks again
>
> I'm not sure exactly what the question was regarding AddressOf. It is
> a slightly odd operator as it's only valid in argument lists. However,
> there's a common workaround to using it in plain assignment
> statements:
>
> Private Function GetAddressOf(lAddr As Long) As Long
> GetAddressOf = lAddr
> End Function
>
> Dim lpCallback As Long
> lpCallback = GetAddress (AddressOf MyCallback)
>
>
> Tony Proctor
>
| |
| Karl E. Peterson 2005-03-01, 9:00 pm |
| Hi John --
You might find this useful, as well:
http://vb.mvps.org/tips/vb5dll.asp
Later... Karl
--
[Microsoft Basic: 1976-2001, RIP]
Johnny McKeon wrote:
> Hello all,
>
> I am a C++ developer who wrote a DLL that some VBers are now tryin to
> use. Since they are having problems I am tryin to write a VB bas file
> for them that declares all the functions and (many) callbacks.
>
> So my question is: how to access the pointer variables in the DLL to
> assign them a function pointer from the BAS unit?
>
> HELP basically only refers to calling functions that require a
> function pointer in the argument list. Can addressof only be used in
> this manner?
>
> I guess what I'm asking is, is there a DECLARE equivalent for
> variables exposed by a DLL??
>
> Appreciated any help you can give me.
>
> Thanks
> John
|
|
|
|
|