I have a DLL, that I can only interface with, using C++. Problem is the majority of the program is already written in VB, and I know very little of the C/C++ language.
I need some help in creating an EXE or DLL in C++ that VB can make calls to. Speed is important but not that important, so if it is easier to make and EXE rather than a DLL with less than 50% impact on speed then that is fine.
Here is an example of the Code given for C. Now what I need to know is how do I pass in a buffer of data and recieve back a buffer of data from this function.
[tt]
#include <windows.h>
#include <iostream>
using namespace std;
typedef int (*init)();
typedef void (*exec)(char *sendbuffer, char *recvbuffer);
int main(int argc, char *argv[])
{
char buffer[2048];
// Load MyCDLL.DLL
HINSTANCE hDll = LoadLibrary("MyCDLL.dll"
;
// Setup a pointer to the 'initializeDefaults' function in MyCDLL.DLL
init initializeDefaults = (init)GetProcAddress(hDll,"initializeDefaults"
;
// Setup a pointer to the 'execute' function in MyCDLL.DLL
exec execute = (exec)GetProcAddress(hDll,"execute"
;
// Initialize the Defaults in MyCDLL.DLL - Should Only Be Called Once
initializeDefaults();
// Send an MyCDLL command to the DLL
execute("[AOECHO;AGTEST;]", buffer);
// Display the result of the command
cout << buffer << endl;
execute("[AOECHO;AGTEST;]", buffer);
cout << buffer << endl;
execute("[AOECHO;AGTEST;]", buffer);
cout << buffer << endl;
return 0;
}
[/tt]
Thanks, Craig, mailto:sander@cogeco.ca
Remember not to name the Lambs...
It only makes the chops harder to swallow
I need some help in creating an EXE or DLL in C++ that VB can make calls to. Speed is important but not that important, so if it is easier to make and EXE rather than a DLL with less than 50% impact on speed then that is fine.
Here is an example of the Code given for C. Now what I need to know is how do I pass in a buffer of data and recieve back a buffer of data from this function.
[tt]
#include <windows.h>
#include <iostream>
using namespace std;
typedef int (*init)();
typedef void (*exec)(char *sendbuffer, char *recvbuffer);
int main(int argc, char *argv[])
{
char buffer[2048];
// Load MyCDLL.DLL
HINSTANCE hDll = LoadLibrary("MyCDLL.dll"
// Setup a pointer to the 'initializeDefaults' function in MyCDLL.DLL
init initializeDefaults = (init)GetProcAddress(hDll,"initializeDefaults"
// Setup a pointer to the 'execute' function in MyCDLL.DLL
exec execute = (exec)GetProcAddress(hDll,"execute"
// Initialize the Defaults in MyCDLL.DLL - Should Only Be Called Once
initializeDefaults();
// Send an MyCDLL command to the DLL
execute("[AOECHO;AGTEST;]", buffer);
// Display the result of the command
cout << buffer << endl;
execute("[AOECHO;AGTEST;]", buffer);
cout << buffer << endl;
execute("[AOECHO;AGTEST;]", buffer);
cout << buffer << endl;
return 0;
}
[/tt]
Thanks, Craig, mailto:sander@cogeco.ca
Remember not to name the Lambs...
It only makes the chops harder to swallow