I have a third party DLL (including a Visual C++ Express project with source code) that is, I think, unmanaged. I Want to write a Managed C++ wrapper DLL so I can use the DLL from VB.
I have not touched C for about 15 years - most of my 'playing' has been in VB.
I have C++ and VB 2010 express.
I have created a new C++ Class Library and added some code to the header file (see below).
The code compiles. From VB I can see my property, but the two functions (WrapiguanaClose and WrapiguaneCode) are not visible. There will be several more properties and functions added once I can get the basics working.
It is probably a silly mistake - showing how out of date I am with C++.
Could anyone please tell me where I have gone wrong ?
#pragma once
#include "Stdafx.h"
#include "iguanaIR.h"
#include "resource.h"
using namespace System;
using namespace System::Reflection;
using namespace System::Windows::Forms;
namespace iguanaIRDLLWrapper {
public ref class igWrap
{
public:
property int Version
{
int get()
{
return 1;
}
}
public : void WrapiguanaClose(PIPE_PTR connection)
{
typedef int (__cdecl *igClosePROC)(HANDLE);
HINSTANCE hinstLib;
igClosePROC ProcAdd;
BOOL fFreeResult, fRunTimeLinkSuccess = FALSE;
hinstLib = LoadLibrary(TEXT("iguanaIR.dll"));
if (hinstLib != NULL)
{
ProcAdd = (igClosePROC) GetProcAddress(hinstLib, "iguanaClose");
if (NULL != ProcAdd)
{
fRunTimeLinkSuccess = TRUE;
(ProcAdd) (connection);
}
fFreeResult = FreeLibrary(hinstLib);
}
}
public : void WrapiguanaCode(const iguanaPacket pkt)
{
typedef int (__cdecl *igCodePROC)(iguanaPacket);
HINSTANCE hinstLib;
igCodePROC ProcAdd;
BOOL fFreeResult, fRunTimeLinkSuccess = FALSE;
hinstLib = LoadLibrary(TEXT("iguanaIR.dll"));
if (hinstLib != NULL)
{
ProcAdd = (igCodePROC) GetProcAddress(hinstLib, "iguanaClose");
if (NULL != ProcAdd)
{
fRunTimeLinkSuccess = TRUE;
(ProcAdd) (pkt);
}
}
}
};
}
Thanks in advance for any help.
John Hadley