Click to See Complete Forum and Search --> : Own API calls
takko
Nov 16th, 2000, 01:40 PM
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++.
gsc1ugs
Nov 23rd, 2000, 06:32 AM
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
gsc1ugs
Nov 23rd, 2000, 06:54 AM
Does anyone know how to alter code for a c++ dll to make it viewable to VB?
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
Use the Declare Function statement.
Declare Function MyFunc Lib "MyLib" (ByVal MyParam As Long) As Long
gsc1ugs
Nov 24th, 2000, 06:51 AM
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
gsc1ugs
Nov 24th, 2000, 07:01 AM
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
gsc1ugs
Nov 24th, 2000, 09:27 AM
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.
#include "windows.h"
extern "C" __declspec(dllexport) int _stdcall CppFunc(int num)
{
return num;
}
Code for VB.
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
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.
gsc1ugs
Nov 27th, 2000, 04:57 AM
Now then.. what about this long VB 4 is 32 bit why cant i send a long to c++ and return it back?
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.