Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Beginner MFC - How to use functions from a .dll file in program?

Posted on 2004-03-29
Medium Priority
Last Modified: 2013-11-20
Started to try and learn C++ and MFC. I'm a total beginer. I have the following code that creates a simple 200x200 window and shows it. I retyped it so it may have a syntax error somewhere. This code is all in one file MFC.cpp

#include <afxwin.h>

class COurApp: public CWinApp
      virtual BOOL InitInstance();

class COurWnd: public CFrameWnd
            CRect rect(0, 0, 200, 200);
            ASSERT(rect.Width() == 200);
            ASSERT(rect.Height() == 200);


BOOL COurApp::InitInstance(void)
      m_pMainWnd = new COurWnd;
      return TRUE;

COurApp AnApplication;

How do I call functions in a .dll file to use in this progam? I assume I must use a #include<header.h> file. Where would I put the function call in the above MFC program if I want to call it right after the progarm starts.

The function I'm interested in is TWAIN_AcquireNative(0,0) from the EZTW32.dll. I have the EZTWAIN.h file but don't know if I need some other files as well. Wan't to take the acquired image and draw it in this window.

Thanks for any help

Question by:cshorey
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 48

Expert Comment

ID: 10703304
Include EZTWAIN.h to the file from which you want to call Dll functions. Add EZTWAIN.lib file to project linker list (Project - Settings - Link - Additional libraries). After this you can call functions from this Dll.

Author Comment

ID: 10703351
O.K., can I do something like this in the InitInstance(void).....
BOOL COurApp::InitInstance(void)
HANDLE myhandle;
myhandle = TWAIN_AcquireNative(0,0);

     m_pMainWnd = new COurWnd;
     return TRUE;

EZTWAIN claims it returns a handle to a windows dib. TWAIN_FreeNative lets it go when all through.

LVL 48

Accepted Solution

AlexFM earned 2000 total points
ID: 10703606
Sure you can do this.

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question