Click here to Skip to main content
15,886,689 members
Articles / Programming Languages / C++

A Copy Utility using TWAIN

Rate me:
Please Sign up or sign in to vote.
4.54/5 (10 votes)
14 Jul 20042 min read 99.8K   6.8K   47  
Example for a simple encapsulation of the TWAIN interface
///////////////////////////////////////////////////////////////////////////////
//
//		CDynDll
//		----------
//		wrapper base class for a dynamically loaded DLL
//
////Holger Kloos, 1999-2001////////////////////////////////////////////////////


#include "stdafx.h"
#include "DynDLL.h"


//  CDynDLL
//	-------


typedef int (*FGetVersion)(void);

//  CDynDll
//	-------

CDynDLL::CDynDLL()
{
	m_hInst = 0;	
}

CDynDLL::~CDynDLL()
{
	Free();
}

BOOL CDynDLL::Create(LPCTSTR pName)
{
	m_hInst = LoadLibrary(pName);

    if (!m_hInst)
        TRACE("!!! ERROR loading DLL %s!\n", pName);

	return m_hInst != NULL;
}

BOOL CDynDLL::Free()
{
	BOOL bRes = m_hInst && FreeLibrary(m_hInst);
	m_hInst = NULL;

	return bRes;
}

BOOL CDynDLL::GetAdress(LPVOID* fct, LPCTSTR name) const
{
	ASSERT(m_hInst);

	*fct = GetProcAddress(m_hInst, name);

	if (!*fct)
		TRACE("! Function not found in DLL: %s",name);

	return *fct != NULL;
}



By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions