georgeob
Thanks Mike, here is the code:
VB declaration:
Private Declare Function summer Lib "C:\Program Files\Microsoft Visual Studio\MyProjects\geob\Debug\geob.dll" (ByVal num1&, ByVal num2&) As Long
Cpp file:
// geob.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
#include "stdio.h"
#include "geob.h"
BOOL APIENTRY _stdcall DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
// This is an example of an exported variable
GEOB_API int nGeob=0;
GEOB_API long sum;
GEOB_API long num1;
GEOB_API long num2;
// This is an example of an exported function.
GEOB_API int fnGeob(void)
{
return 42;
}
// This is the constructor of a class that has been exported.
// see geob.h for the class definition
CGeob::CGeob()
{
return;
}
long _stdcall CGeob::summer(long num1, long num2)
{
long sum;
printf("got there");
sum = num1 + num2;
return sum;
}
.h file:
// The following ifdef block is the standard way of creating macros which make exporting
// from a DLL simpler. All files within this DLL are compiled with the GEOB_EXPORTS
// symbol defined on the command line. this symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see
// GEOB_API functions as being imported from a DLL, wheras this DLL sees symbols
// defined with this macro as being exported.
#ifdef GEOB_EXPORTS
#define GEOB_API __declspec(dllexport)
#else
#define GEOB_API __declspec(dllimport)
#endif
// This class is exported from the geob.dll
class GEOB_API CGeob {
public:
CGeob(void);
long sum;
long num1;
long num2;
//CGeob(void);
long _stdcall summer(long num1, long num2);
// TODO: add your methods here.
};
extern GEOB_API int nGeob;
extern GEOB_API long sum;
extern GEOB_API long num1;
extern GEOB_API long num2;
GEOB_API int fnGeob(void);
GEOB_API long _stdcall summer(long, long);