Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
I have a abc.cpp file and abc.h file.
In abc.cpp file declare functions which are defined in myDLL.dll.

abc.h file is..
C++
#ifndef _DERMALOGFINGERCODE3_H_
#define _DERMALOGFINGERCODE3_H_

#include "ABCSDK_Definitions.h"
#include "ErrorCodes.h"
#include "BitmapInfoHeader.hpp"

#ifdef __cplusplus
extern "C" {
#endif // __cplusplus

/*! \brief type definition for the FC3 handle */
typedef void* FC3_t;
/*! \brief type definition for the template handle */
typedef FC3_t FC3Template_t;
/*! \brief type definition for the encode handle */
typedef FC3_t FC3Encode_t;
/*! \brief type definition for the match handle */
typedef FC3_t FC3Match_t;

DrmErrorCode_t DRMAPI FC3Initialize(const char* szReserved);

#ifdef __cplusplus
}
#endif // __cplusplus

#endif // _DERMALOGFINGERCODE3_H_
//! \endgroup
ErrorCodes.h file is
C++
#ifndef _ERRORCODES_H_
#define _ERRORCODES_H_

#include <stddef.h>
typedef long DrmErrorCode_t;//DrmErrorCode_t is in ErrorCodes.h defined
#endif /* _ERRORCODES_H_*/

ABCSDK_Definitions.h file is
C++
#ifndef _DERMALOGSDK_DEFINITIONS_H_
#define _DERMALOGSDK_DEFINITIONS_H_

/*! \define DRMAPI 
\brief a define for the calling convention for MS Windows.
*/
#ifndef DRMAPI
#if defined(WIN32) || defined(_WIN32)
#define DRMAPI __stdcall
#else
#define DRMAPI
#endif
#endif

//! property type enumeration
typedef enum { eLong, eDouble, eString } enumType_t;
//! property access enumeration
typedef enum { eNone, eIn, eOut,eInOut } enumAccess_t;
#endif // _DERMALOGSDK_DEFINITIONS_H_

BitmapInfoHeader.hppfile is
C++
#ifndef _BITMAPINFOHEADER_HPP_
#define _BITMAPINFOHEADER_HPP_

#ifdef WINCE
#define BI_RLE8       (1L)
#endif

#if !defined(WIN32) || defined(__CYGWIN__)
#define WINAPI
/* constants for the biCompression field */
#define BI_RGB        (0u)
#define BI_RLE8       (1u)
#define BI_RLE4       (2u)
#define BI_BITFIELDS  (3u)
#define BI_JPEG       (4u)
#define BI_PNG        (5u)

/* LONG must be defined as a 32 signed int.*/
#include <inttypes.h>
#ifndef DWORD
	typedef uint32_t DWORD;
#endif
#ifndef WORD
	typedef uint16_t WORD;
#endif
#ifndef BYTE
	typedef uint8_t BYTE;
#endif
#ifndef LONG
	typedef int32_t LONG;
#endif
#ifndef BOOL
	typedef int32_t BOOL;
#endif
#ifndef HMODULE
	typedef void* HMODULE;
#endif

typedef struct tagBITMAPINFOHEADER{
	DWORD        biSize;
	LONG         biWidth;
	LONG         biHeight;
	WORD         biPlanes;
	WORD         biBitCount;
	DWORD        biCompression;
	DWORD        biSizeImage;
	LONG         biXPelsPerMeter;
	LONG         biYPelsPerMeter;
	DWORD        biClrUsed;
	DWORD        biClrImportant;
} BITMAPINFOHEADER;

#endif /* WIN32 / CYGWIN */
#endif /* _BITMAPINFOHEADER_HPP_ */

Now abc.cpp file is
C++
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <memory>
#if defined(WIN32)
#include <Windows.h>
#endif 
#include "TutException.hpp"
#include "TutFile.hpp"
#include "TutBitmap.hpp"
#include "TutLoadLibrary.hpp"
#include "TutParams.hpp"

/* defines for system independence */
#if defined(WIN32)
	#define DERMALOG_LIBNAME "myDLL.dll" /* load the .dll file when using windows*/

#endif

#include "abc.h"

/* global handle for the dynamic library */
HMODULE g_hLib = NULL;
const char* (DRMAPI *GetErrorDescription)(DrmErrorCode_t nRetCode);
/* SDK init and deinit handling */

    class SDK
        {
      public:
	SDK() : fpInitialize(NULL), fpUninitialize(NULL)
	{
		GetFunction(g_hLib, "FC3Initialize", fpInitialize);
		GetFunction(g_hLib, "FC3Uninitialize", fpUninitialize);
		DrmErrorCode_t nRetCode = fpInitialize(NULL);
		if (nRetCode!=FPC_SUCCESS)
			throw Exception("Error (%d) while setting encoder callback: %s", (int)nRetCode, GetErrorDescription(nRetCode));
	}
	//SDK();
	virtual ~SDK() 
	{
		DrmErrorCode_t nRetCode = fpUninitialize();
		if (nRetCode!=FPC_SUCCESS)
			throw Exception("Error (%d) while setting encoder callback: %s", (int)nRetCode, GetErrorDescription(nRetCode));
	}
public:
	DrmErrorCode_t (DRMAPI *fpInitialize)(const char* szReserved);
	DrmErrorCode_t (DRMAPI *fpUninitialize)(void);
};

Now I want to call FC3Initialize function in my maincpp.cpp file(how ?)
Posted
Comments
[no name] 13-Jul-12 9:49am    
It appears this is a repost. Mind telling us all why when the question has previously been fully answered?

Did you use google? Cannot create a more comprehensive answer than this.

Step by Step: Calling C++ DLLs from VC++ and VB - Part 1[^]

Step by Step: Calling C++ DLLs from VC++ and VB - Part 4[^]

4 parts in all.
 
Share this answer
 
v2
I already explained what you need to do here[^]. Why not make an attempt to try what has been suggested and respond accordingly, rather than reposting the same question.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900