Using VB functions in C dlls?
If a VB app imports functions from a c dll, can the functions in a C dll call functions from the VB app? If so, is there anything special that must be done or declared on either side of the app to get this to work?
"Victims...aren't we all?" -Brandon Lee, the Crow
Can anyone please help me?
"Victims...aren't we all?" -Brandon Lee, the Crow
February 21, 2001 09:15 AM
If the functions are somehow exported from VB, either as a regular WIN32 DLL or a COM DLL, then yes, you can access them from C.
Check out LoadLibrary and GetProcAddress API functions to help you on your way.
If the functions are method of a COM object in your VB DLL, then you can access them via normal COM methods.
-Z
The VB part of this is a running application that has imported functions from a DLL written under VC++. I wanted to know if one of the imported C functions could call a function in the running VB app. I thought that this might be posible since the C function has been imported and is now part of the VB app, and may have access to those other functions within the VB app. Anyone understand me?
"Victims...aren't we all?" -Brandon Lee, the Crow
I believe all VB COM dlls are Automation, at least in VB4.
If you have VB5 or later, pass the addresses of the functions you want C to call using the AddressOf function:
'' VB code
CFoo intBeautiful, intUgly, AddressOf VBFoo
'' End VB code
''VB declaration
Public Sub VBFoo (ByVal x As Integer, ByVal y As Integer)
End Sub
''End VB declaration
/*C code*/
typedef void (__stdcall *INT_SUB) (int, int);
void CFoo (int i1, int i2, INT_SUB pfnVBFoo)
{
/* Processing */
pfnVBFoo (i1, i2);
/* More processing */
}
/*End C Code*/
If you have VB5 or later, pass the addresses of the functions you want C to call using the AddressOf function:
'' VB code
CFoo intBeautiful, intUgly, AddressOf VBFoo
'' End VB code
''VB declaration
Public Sub VBFoo (ByVal x As Integer, ByVal y As Integer)
End Sub
''End VB declaration
/*C code*/
typedef void (__stdcall *INT_SUB) (int, int);
void CFoo (int i1, int i2, INT_SUB pfnVBFoo)
{
/* Processing */
pfnVBFoo (i1, i2);
/* More processing */
}
/*End C Code*/
VK
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement