Hi!
Is it possible to make own API call liberys in VB? So i can make a function, compile it into a dll and then call it from another program with the declare function statement?
Printable View
Hi!
Is it possible to make own API call liberys in VB? So i can make a function, compile it into a dll and then call it from another program with the declare function statement?
No. VB can only create ActiveX DLL's. In order to use a function in that respect, you need to use a Standard DLL. To make a standard DLL, use C++.
Is it possible to pass a variable into a MFC c++ dll.. if so could someone give an example of how to declare the dll and how to pass variable to it assuming it as only one parameter of type long
Many thanks
Does anyone know how to alter code for a c++ dll to make it viewable to VB?
Use the Declare Function statement.Quote:
Originally posted by gsc1ugs
Is it possible to pass a variable into a MFC c++ dll.. if so could someone give an example of how to declare the dll and how to pass variable to it assuming it as only one parameter of type long
Many thanks
Code:Declare Function MyFunc Lib "MyLib" (ByVal MyParam As Long) As Long
Thanks but didn't work.. but master it in the end here's the solution.
VB: Alias is the key calling the mangled function and byte size
Declare Function CheckDongle Lib "D:\DEVELOP\ALL16_32\SetReg\Debug\SetReg.dll" Alias "_CheckDongle@4" (ByVal nDays As Integer) As Integer
C++
#ifdef __cplusplus
extern "C" {
#endif
int __declspec(dllexport) CALLBACK CheckDongle(int lDays)
{
CDongle CInstDongle;
return CInstDongle.OnSetRegistryEntries(lDays); //EXTENDS INTO CLASS DEFINITION
}
#ifdef __cplusplus
}
#endif
I would like to pass a long value thru this function but VB as a fit.. anyone tell me a work around? int are fine
This is a problem for the Guru's com'on..! forever greatful.. i need a long... ooh eer!
1st off, the answer to your question.
Code for C++ DLL.
Code for VB.Code:#include "windows.h"
extern "C" __declspec(dllexport) int _stdcall CppFunc(int num)
{
return num;
}
Secondly, when you ask a question give people time to answer it. You posted twice within 4 hours. Sometimes it takes days to get a response.Code:Private Declare Function CppFunction Lib "C:\MyPath\CppDll.dll" Alias "_CppFunc@4" (ByVal num As Integer) As Integer
Private Sub Command1_Click()
Print CppFunction(34)
'returns 34 (or whatever you pass through)
End Sub
Now then.. what about this long VB 4 is 32 bit why cant i send a long to c++ and return it back?