Click here to Skip to main content
15,879,535 members
Articles / Desktop Programming / MFC

Creating and consuming MFC DLLs for Beginners

Rate me:
Please Sign up or sign in to vote.
4.44/5 (89 votes)
18 Aug 2012CPOL4 min read 515.6K   15.3K   131  
The objective of this tutorial is to demonstrate in a step by step manner how to build and call methods present in a DLL using Visual C++ 6.0. We are going to develop a DLL that takes in a string as input parameter and returns the string prefixed with a "Hello".
// TestDLLDlg.h : header file
//

#if !defined(AFX_TESTDLLDLG_H__1FAFEE67_88D6_11D6_89D7_00010302158B__INCLUDED_)
#define AFX_TESTDLLDLG_H__1FAFEE67_88D6_11D6_89D7_00010302158B__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

/////////////////////////////////////////////////////////////////////////////
// CTestDLLDlg dialog


#include "..\MyDll\MyClass.h"

class CTestDLLDlg : public CDialog
{
// Construction
public:
	CTestDLLDlg(CWnd* pParent = NULL);	// standard constructor
	CMyClass objMyClass;

// Dialog Data
	//{{AFX_DATA(CTestDLLDlg)
	enum { IDD = IDD_TESTDLL_DIALOG };
	CString	m_edit;
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CTestDLLDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	HICON m_hIcon;

	// Generated message map functions
	//{{AFX_MSG(CTestDLLDlg)
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	virtual void OnOK();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_TESTDLLDLG_H__1FAFEE67_88D6_11D6_89D7_00010302158B__INCLUDED_)

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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Product Manager
India India
Imran is a software professional with 9 years of development experience and has worked on JAVA, VB6, VC6, C# & some JavaScript.

He is interested in Hi-Performance code, OO Methodology, OS API's, Optimizing Windows, Tweaking IE.

For the last few years Imran has specialized in developing robust, hi-performance applications & GUI's (Swing) for MNC's.

http://techspot121.blogspot.com/

Comments and Discussions