Click here to Skip to main content
15,895,740 members
Articles / Desktop Programming / MFC

Making DLLs easy to build and use

Rate me:
Please Sign up or sign in to vote.
4.63/5 (13 votes)
8 Mar 20048 min read 164K   42  
How to quickly build a DLL file from an existing class and how to easily use it.
<!--------------------------------------------------------------------------->  
<!--                           INTRODUCTION                                

 The Code Project article submission template (HTML version)

Using this template will help us post your article sooner. To use, just 
follow the 3 easy steps below:
 
     1. Fill in the article description details
     2. Add links to your images and downloads
     3. Include the main article text

That's all there is to it! All formatting will be done by our submission
scripts and style sheets. 

-->  
<!--------------------------------------------------------------------------->  
<!--                        IGNORE THIS SECTION                            -->
<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=ProgId content=Word.Document>
<meta name=Generator content="Microsoft Word 9">
<meta name=Originator content="Microsoft Word 9">
<link rel=File-List href="./DLLBuild_files/filelist.xml">
<title>The Code Project</title>
<!--[if gte mso 9]><xml>
 <o:DocumentProperties>
  <o:Author>T</o:Author>
  <o:LastAuthor>T</o:LastAuthor>
  <o:Revision>20</o:Revision>
  <o:TotalTime>158</o:TotalTime>
  <o:Created>2004-03-09T13:17:00Z</o:Created>
  <o:LastSaved>2004-03-09T15:25:00Z</o:LastSaved>
  <o:Pages>4</o:Pages>
  <o:Words>1689</o:Words>
  <o:Characters>9632</o:Characters>
  <o:Company> </o:Company>
  <o:Lines>80</o:Lines>
  <o:Paragraphs>19</o:Paragraphs>
  <o:CharactersWithSpaces>11828</o:CharactersWithSpaces>
  <o:Version>9.2720</o:Version>
 </o:DocumentProperties>
</xml><![endif]-->
<link rel=Stylesheet type="text/css" media=all
href="http://www.codeproject.com/styles/global.css">
<style>
<!--
 /* Font Definitions */
@font-face
	{font-family:Wingdings;
	panose-1:5 0 0 0 0 0 0 0 0 0;
	mso-font-charset:2;
	mso-generic-font-family:auto;
	mso-font-pitch:variable;
	mso-font-signature:0 268435456 0 0 -2147483648 0;}
@font-face
	{font-family:Tahoma;
	panose-1:2 11 6 4 3 5 4 4 2 4;
	mso-font-charset:0;
	mso-generic-font-family:swiss;
	mso-font-pitch:variable;
	mso-font-signature:1627421319 -2147483648 8 0 66047 0;}
@font-face
	{font-family:Verdana;
	panose-1:2 11 6 4 3 5 4 4 2 4;
	mso-font-charset:0;
	mso-generic-font-family:swiss;
	mso-font-pitch:variable;
	mso-font-signature:536871559 0 0 0 415 0;}
 /* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-parent:"";
	margin:0in;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";
	color:windowtext;}
h1
	{margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	mso-outline-level:1;
	font-size:16.0pt;
	font-family:Verdana;
	color:black;
	mso-font-kerning:18.0pt;
	font-weight:bold;}
h2
	{margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	mso-outline-level:2;
	font-size:13.0pt;
	font-family:Verdana;
	color:#FF9900;
	font-weight:bold;}
h3
	{margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	mso-outline-level:3;
	font-size:11.0pt;
	font-family:Arial;
	color:#FF9900;
	font-weight:bold;}
h4
	{margin-right:0in;
	mso-margin-top-alt:auto;
	margin-bottom:1.5pt;
	margin-left:0in;
	mso-pagination:widow-orphan;
	mso-outline-level:4;
	font-size:10.0pt;
	font-family:Verdana;
	color:black;
	font-weight:bold;}
h5
	{margin-right:0in;
	mso-margin-top-alt:auto;
	margin-bottom:1.5pt;
	margin-left:0in;
	mso-pagination:widow-orphan;
	mso-outline-level:5;
	font-size:9.0pt;
	font-family:Verdana;
	color:#FF9900;
	font-weight:bold;}
h6
	{margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	mso-outline-level:6;
	font-size:8.0pt;
	font-family:Verdana;
	color:#626262;
	font-weight:normal;}
a:link, span.MsoHyperlink
	{color:blue;
	mso-text-animation:none;
	text-decoration:none;
	text-underline:none;
	text-decoration:none;
	text-line-through:none;}
a:visited, span.MsoHyperlinkFollowed
	{color:blue;
	mso-text-animation:none;
	text-decoration:none;
	text-underline:none;
	text-decoration:none;
	text-line-through:none;}
p
	{margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:Verdana;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	color:black;}
code
	{mso-ascii-font-family:"Courier New";
	mso-fareast-font-family:"Courier New";
	mso-hansi-font-family:"Courier New";
	mso-bidi-font-family:"Courier New";
	color:#990000;}
pre
	{margin:0in;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
	background:#FBEDBB;
	font-size:9.0pt;
	font-family:"Courier New";
	mso-fareast-font-family:"Courier New";
	color:windowtext;}
tt
	{mso-ascii-font-family:"Courier New";
	mso-fareast-font-family:"Courier New";
	mso-hansi-font-family:"Courier New";
	mso-bidi-font-family:"Courier New";}
p.menugroup, li.menugroup, div.menugroup
	{mso-style-name:menugroup;
	margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	background:#FFCC99;
	font-size:10.0pt;
	font-family:Tahoma;
	mso-fareast-font-family:"Times New Roman";
	color:black;}
p.mi, li.mi, div.mi
	{mso-style-name:mi;
	margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:3.0pt;
	mso-pagination:widow-orphan;
	background:#FFCC99;
	font-size:8.0pt;
	font-family:Verdana;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	color:black;}
p.mis, li.mis, div.mis
	{mso-style-name:mis;
	margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:3.0pt;
	mso-pagination:widow-orphan;
	background:#FFCC99;
	font-size:8.0pt;
	font-family:Verdana;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	color:black;}
p.min, li.min, div.min
	{mso-style-name:min;
	margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:1.5pt;
	mso-pagination:widow-orphan;
	background:#FFCC99;
	border:none;
	mso-border-alt:solid #FFCC99 1.0pt;
	padding:0in;
	mso-padding-alt:0in 0in 0in 0in;
	font-size:8.0pt;
	font-family:Verdana;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	color:black;}
p.misn, li.misn, div.misn
	{mso-style-name:misn;
	margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:1.5pt;
	mso-pagination:widow-orphan;
	background:#FFCC99;
	font-size:8.0pt;
	font-family:Verdana;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	color:black;}
p.sidebar, li.sidebar, div.sidebar
	{mso-style-name:sidebar;
	margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	font-size:9.0pt;
	font-family:Verdana;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	color:white;
	font-weight:bold;}
p.navbar, li.navbar, div.navbar
	{mso-style-name:navbar;
	margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	font-size:8.0pt;
	font-family:Verdana;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	color:white;
	font-weight:bold;}
p.infobar, li.infobar, div.infobar
	{mso-style-name:infobar;
	margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	font-size:8.0pt;
	font-family:Verdana;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	color:black;}
p.infobarlist, li.infobarlist, div.infobarlist
	{mso-style-name:infobarlist;
	margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:.25in;
	text-indent:-.25in;
	mso-pagination:widow-orphan;
	font-size:8.0pt;
	font-family:Verdana;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	color:black;}
p.infobarheader, li.infobarheader, div.infobarheader
	{mso-style-name:infobarheader;
	margin-right:0in;
	mso-margin-top-alt:auto;
	margin-bottom:0in;
	margin-left:0in;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:9.0pt;
	font-family:Verdana;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	color:#AB2600;
	font-weight:bold;}
p.hoverlink, li.hoverlink, div.hoverlink
	{mso-style-name:hoverlink;
	margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	background:#FBEDBB;
	border:none;
	mso-border-alt:solid #FBEDBB .75pt;
	padding:0in;
	mso-padding-alt:1.0pt 2.0pt 1.0pt 2.0pt;
	font-size:8.0pt;
	font-family:Verdana;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	color:black;}
p.mainheader, li.mainheader, div.mainheader
	{mso-style-name:mainheader;
	margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	font-size:18.5pt;
	font-family:Tahoma;
	mso-fareast-font-family:"Times New Roman";
	color:black;
	font-weight:bold;}
p.formbutton, li.formbutton, div.formbutton
	{mso-style-name:formbutton;
	margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	background:#E08900;
	font-size:11.0pt;
	font-family:Verdana;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	color:white;
	font-weight:bold;}
p.sitenewsheading, li.sitenewsheading, div.sitenewsheading
	{mso-style-name:sitenewsheading;
	margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	font-size:8.0pt;
	font-family:Verdana;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	color:black;
	font-weight:bold;}
p.devnewsheading, li.devnewsheading, div.devnewsheading
	{mso-style-name:devnewsheading;
	margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	font-size:10.5pt;
	font-family:Verdana;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	color:black;
	font-weight:bold;}
p.links, li.links, div.links
	{mso-style-name:links;
	margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	font-size:8.0pt;
	font-family:Verdana;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	color:black;}
p.messagetitle, li.messagetitle, div.messagetitle
	{mso-style-name:messagetitle;
	margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	font-size:8.0pt;
	font-family:Verdana;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	color:black;}
p.sitenews, li.sitenews, div.sitenews
	{mso-style-name:sitenews;
	margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	font-size:8.0pt;
	font-family:Verdana;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	color:black;}
p.smalltext, li.smalltext, div.smalltext
	{mso-style-name:smalltext;
	margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	font-size:8.0pt;
	font-family:Verdana;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	color:black;}
p.newsflash, li.newsflash, div.newsflash
	{mso-style-name:newsflash;
	margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	font-size:9.0pt;
	font-family:Verdana;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	color:black;}
p.devnewscontent, li.devnewscontent, div.devnewscontent
	{mso-style-name:devnewscontent;
	margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	font-size:9.0pt;
	font-family:Verdana;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	color:black;}
p.messagecontent, li.messagecontent, div.messagecontent
	{mso-style-name:messagecontent;
	margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	font-size:9.5pt;
	font-family:Verdana;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	color:black;}
p.default, li.default, div.default
	{mso-style-name:default;
	margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:Verdana;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	color:black;}
p.forumhilite, li.forumhilite, div.forumhilite
	{mso-style-name:forum_hilite;
	margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	background:yellow;
	font-size:10.0pt;
	font-family:Verdana;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	color:black;}
p.cpp-comment, li.cpp-comment, div.cpp-comment
	{mso-style-name:cpp-comment;
	margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:Verdana;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	color:green;
	font-style:italic;}
p.cs-comment, li.cs-comment, div.cs-comment
	{mso-style-name:cs-comment;
	margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:Verdana;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	color:green;
	font-style:italic;}
p.vb-comment, li.vb-comment, div.vb-comment
	{mso-style-name:vb-comment;
	margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:Verdana;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	color:green;
	font-style:italic;}
p.cpp-keyword, li.cpp-keyword, div.cpp-keyword
	{mso-style-name:cpp-keyword;
	margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:Verdana;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	color:blue;}
p.cs-keyword, li.cs-keyword, div.cs-keyword
	{mso-style-name:cs-keyword;
	margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:Verdana;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	color:blue;}
p.vb-function, li.vb-function, div.vb-function
	{mso-style-name:vb-function;
	margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:Verdana;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	color:blue;}
p.cpp-preprocessor, li.cpp-preprocessor, div.cpp-preprocessor
	{mso-style-name:cpp-preprocessor;
	margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:Verdana;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	color:navy;}
p.cs-preprocessor, li.cs-preprocessor, div.cs-preprocessor
	{mso-style-name:cs-preprocessor;
	margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:Verdana;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	color:navy;}
p.cpp-string, li.cpp-string, div.cpp-string
	{mso-style-name:cpp-string;
	margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:Verdana;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	color:purple;}
p.cs-string, li.cs-string, div.cs-string
	{mso-style-name:cs-string;
	margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:Verdana;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	color:purple;}
p.vb-string, li.vb-string, div.vb-string
	{mso-style-name:vb-string;
	margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:Verdana;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	color:purple;}
p.cpp-literal, li.cpp-literal, div.cpp-literal
	{mso-style-name:cpp-literal;
	margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:Verdana;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	color:midnightblue;}
p.cs-literal, li.cs-literal, div.cs-literal
	{mso-style-name:cs-literal;
	margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:Verdana;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	color:midnightblue;}
p.vb-literal, li.vb-literal, div.vb-literal
	{mso-style-name:vb-literal;
	margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:Verdana;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	color:midnightblue;}
p.vb-keyword, li.vb-keyword, div.vb-keyword
	{mso-style-name:vb-keyword;
	margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:Verdana;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	color:blue;}
p.vb-statement, li.vb-statement, div.vb-statement
	{mso-style-name:vb-statement;
	margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:Verdana;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	color:blue;}
p.clsbutton, li.clsbutton, div.clsbutton
	{mso-style-name:clsbutton;
	margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	background:#FF9900;
	border:none;
	mso-border-alt:solid #FF9900 .75pt;
	padding:0in;
	mso-padding-alt:0in 0in 0in 0in;
	font-size:8.0pt;
	font-family:Verdana;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	color:#333300;
	font-weight:bold;}
p.clsbuttonlnk, li.clsbuttonlnk, div.clsbuttonlnk
	{mso-style-name:clsbuttonlnk;
	margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	font-size:8.0pt;
	font-family:Verdana;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	color:#333300;
	font-weight:bold;}
p.featurebox, li.featurebox, div.featurebox
	{mso-style-name:featurebox;
	margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	background:#A5C9EF;
	border:none;
	mso-border-alt:solid #6699CC .75pt;
	padding:0in;
	mso-padding-alt:2.0pt 2.0pt 2.0pt 2.0pt;
	font-size:10.0pt;
	font-family:Verdana;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	color:black;}
p.featureboxheader, li.featureboxheader, div.featureboxheader
	{mso-style-name:featureboxheader;
	margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	font-size:13.0pt;
	font-family:Verdana;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	color:#993300;
	font-weight:bold;}
p.featureboxheaderarrow, li.featureboxheaderarrow, div.featureboxheaderarrow
	{mso-style-name:featureboxheaderarrow;
	margin-right:0in;
	mso-margin-top-alt:auto;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	mso-pagination:widow-orphan;
	background:#6699CC;
	font-size:10.0pt;
	font-family:Verdana;
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	color:black;}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.25in 1.0in 1.25in;
	mso-header-margin:.5in;
	mso-footer-margin:.5in;
	mso-paper-source:0;}
div.Section1
	{page:Section1;}
 /* List Definitions */
@list l0
	{mso-list-id:1702583875;
	mso-list-type:hybrid;
	mso-list-template-ids:-717487944 145645256 -1688723074 1659269736 -2089900338 -1477422470 -1473108218 1658882320 -890624864 1343914158;}
@list l0:level1
	{mso-level-number-format:bullet;
	mso-level-text:\F0B7;
	mso-level-tab-stop:.5in;
	mso-level-number-position:left;
	text-indent:-.25in;
	mso-ansi-font-size:10.0pt;
	font-family:Symbol;}
@list l1
	{mso-list-id:2048984184;
	mso-list-type:hybrid;
	mso-list-template-ids:-2138392848 67698705 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l1:level1
	{mso-level-text:"%1\)";
	mso-level-tab-stop:.5in;
	mso-level-number-position:left;
	text-indent:-.25in;}
ol
	{margin-bottom:0in;}
ul
	{margin-bottom:0in;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1027"/>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1"/>
 </o:shapelayout></xml><![endif]-->
</head>

<body bgcolor=white lang=EN-US link=blue vlink=blue style='tab-interval:.5in'
color="#000000">
<!---------------------------------------------------------------------------><!-------------------------------     STEP 1      ---------------------------><!--  Fill in the details (CodeProject will reformat this section for you) -->

<div class=Section1><pre><span style='color:black'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></pre><pre><span
style='color:black'>Title:<span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Making DLL files simple to use and build.<o:p></o:p></span></pre><pre><span
style='color:black'>Author:<span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Alexander <o:p></o:p></span></pre><pre><span
style='color:black'>Email:<span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>boutpost@msn.com<o:p></o:p></span></pre><pre><span
style='color:black'>Environment: VC++ 5.0-6.0, NT 4.0, Win95/98, Win 2000, Win XP<o:p></o:p></span></pre><pre><span
style='color:black'>Keywords:<span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </span>MFC, DLL, Shared Library, Simple<o:p></o:p></span></pre><pre><span
style='color:black'>Level:<span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Intermediate<o:p></o:p></span></pre><pre><span
style='color:black'>Description: Making DLL files simple to use and build.<o:p></o:p></span></pre><pre><span
style='color:black'>Section<span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </span><span style="mso-spacerun: yes">&nbsp;&nbsp;</span>DLLs<o:p></o:p></span></pre><pre><span
style='color:black'>SubSection<span style="mso-spacerun: yes">&nbsp;&nbsp; </span>General<o:p></o:p></span></pre>

<ul type=disc>
 <li class=MsoNormal style='color:black;mso-margin-top-alt:auto;mso-margin-bottom-alt:
     auto;mso-list:l0 level1 lfo1;tab-stops:list .5in'><span style='font-size:
     10.0pt;font-family:Verdana'><a href="Article_demo.zip"><!-------------------------------     STEP 2      ---------------------------><!--  Include download and sample image information.                       -->n/a</a><span
     style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp; </span><o:p></o:p></span></li>
 <li class=MsoNormal style='color:black;mso-margin-top-alt:auto;mso-margin-bottom-alt:
     auto;mso-list:l0 level1 lfo1;tab-stops:list .5in'><span style='font-size:
     10.0pt;font-family:Verdana'><a href="Article_src.zip">n/a</a><o:p></o:p></span></li>
</ul>

<h2>Introduction</h2>

<p>Trying to find out how to build DLLs for a beginner or even experienced
programmer can be complicated to configure and use.<span style="mso-spacerun:
yes">&nbsp; </span>This article is to post a simple method of building a DLL
and then using that DLL in a project with no effort other than needing to
include the header file.<span style="mso-spacerun: yes">&nbsp; </span>All you
will need is the class already designed and ready to become a DLL file. <span
style="mso-spacerun: yes">&nbsp;</span>Even though this is probably some novice
stuff, it is believed some experience in working with the MSVS projects are
needed.<span style="mso-spacerun: yes">&nbsp; </span>In addition, the advanced person
might find some finer points here that could be useful.</p>

<h2>Background </h2>

<p>Some people might find it hard to research on the Internet useful ways of
building DLLs the very simple way.<span style="mso-spacerun: yes">&nbsp;
</span>The information in this document is actually a collection of information
found on this site and other sites on building DLLs so it is nothing new (only
pulling together their efforts).<span style="mso-spacerun: yes">&nbsp; </span>A
few articles relate in detail on how to build DLLs and highlights the finer
points of what a DLL actually is and how to use it.<span style="mso-spacerun:
yes">&nbsp; </span>I suggest reading them first to find broader definitions.<span
style="mso-spacerun: yes">&nbsp; </span>However, it seems that a lot of effort to
the novice &#8220;DLL builder&#8221; is lacking or too complicated to understand thereof.<span
style="mso-spacerun: yes">&nbsp; </span>You may have heard from someone it is
easy to build DLLs but trying to figure out how it all pulls together can be an
effort in its own.<span style="mso-spacerun: yes">&nbsp; </span>Some articles
do not seem to also highlight the importance of directory locations.<span
style="mso-spacerun: yes">&nbsp; </span>A DLL, its library and header file(s)
must all be in a findable directory that can either be a Windows directory or
somewhere where the compiler can find them.<span style="mso-spacerun:
yes">&nbsp; </span>Otherwise you may encounter frustrating compiler problems if
one or all of the DLLs files are not found, which usually results in an
unusable circumstance.</p>

<h2>Using the code</h2>

<p>There are no code attachments other than comment areas.<span
style="mso-spacerun: yes">&nbsp; </span>This should be simple enough to figure
out by working alongside in your MSVS environment.<span style="mso-spacerun:
yes">&nbsp; </span>What you will need to do is:</p>

<p style='margin-left:.5in;text-indent:-.25in;mso-list:l1 level1 lfo2;
tab-stops:list .5in'><![if !supportLists]>1)<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;
</span><![endif]>Have a class already prepared that needs to be a DLL file.</p>

<p style='margin-left:.5in;text-indent:-.25in;mso-list:l1 level1 lfo2;
tab-stops:list .5in'><![if !supportLists]>2)<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;
</span><![endif]>Start a new DLL project</p>

<p style='margin-left:.5in;text-indent:-.25in;mso-list:l1 level1 lfo2;
tab-stops:list .5in'><![if !supportLists]>3)<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;
</span><![endif]>Insert MACRO definitions in your &#8220;StdAfx.h&#8221; file.</p>

<p style='margin-left:.5in;text-indent:-.25in;mso-list:l1 level1 lfo2;
tab-stops:list .5in'><![if !supportLists]>4)<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;
</span><![endif]>Add easy including of the DLL libraries in the main &#8220;foo.h&#8221;
file.</p>

<p style='margin-left:.5in;text-indent:-.25in;mso-list:l1 level1 lfo2;
tab-stops:list .5in'><![if !supportLists]>5)<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;
</span><![endif]>Add some project preprocessor MACROs.</p>

<p style='margin-left:.5in;text-indent:-.25in;mso-list:l1 level1 lfo2;
tab-stops:list .5in'><![if !supportLists]>6)<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;
</span><![endif]>Make batch files for the &#8220;Post Builds&#8221; - to appropriately copy
library, header and DLL files to findable directory(s).</p>

<p>1) It is assumed that you already created your class, so this step is
bypassed.</p>

<p>2) First is the easy part.<span style="mso-spacerun: yes">&nbsp;
</span>Start up &#8220;Microsoft Visual Studio Visual C++&#8221;.<span style="mso-spacerun:
yes">&nbsp; </span>Select &#8220;File-&gt;New&#8221; to pull up the creation dialog.<span
style="mso-spacerun: yes">&nbsp; </span>Under the &#8220;Projects&#8221; tab button, select
&#8220;MFC AppWizard (DLL)&#8221;.<span style="mso-spacerun: yes">&nbsp; </span>Enter the project
name and directory to be used then click &#8220;OK&#8221;.<span style="mso-spacerun:
yes">&nbsp; </span>The rest of the options are not necessary, so select what
you want to do in the rest of the Wizard and click &#8220;Finish&#8221;.</p>

<p>What typically happens after you started the new project is that a source
code and header file has been created for you.<span style="mso-spacerun:
yes">&nbsp; </span>These are not really needed if you already have the code you
are going to build.<span style="mso-spacerun: yes">&nbsp; </span>Only the preset
definitions for the project are needed from this step.<span
style="mso-spacerun: yes">&nbsp; </span>It is suggested that you just empty the
files created by highlighting and deleting the source and header files created
by the Wizard.<span style="mso-spacerun: yes">&nbsp; </span>Do not edit the &#8220;StdAfx&#8221;
files yet as these are needed.<span style="mso-spacerun: yes">&nbsp; </span></p>

<p>The point in this step is to simply copy and paste your class (&#8220;foo&#8221;) into
the header and source files created.<span style="mso-spacerun: yes">&nbsp;
</span>It should be a simple concept to grasp, but if you are skeptical you can
alternatively just add your &#8220;foo&#8221; source file and header file into the project
so that it is built.</p>

<p>You will next begin the editing part.<span style="mso-spacerun: yes">&nbsp;
</span>You must be able to make the build compile as a DLL file correctly for
usage.<span style="mso-spacerun: yes">&nbsp; </span>DLL files use a combination
of Exporting and Importing.<span style="mso-spacerun: yes">&nbsp; </span>When
this is the build project you will need to &#8220;Export&#8221;.<span style="mso-spacerun:
yes">&nbsp; </span>When it is being included in another project that does not
use the source code, you will need to &#8220;Import&#8221;.<span style="mso-spacerun:
yes">&nbsp; </span>This is probably the harder part of understanding the DLL as
it is not necessarily implemented for you and requires a little effort before
understanding.<span style="mso-spacerun: yes">&nbsp; </span>As a side note, the
&#8220;resource.h&#8221; is only required by DLLs that have dialogs in them.<span
style="mso-spacerun: yes">&nbsp; </span>In this case, you will have to remember
that you may have several &#8220;resource.h&#8221; files then and will have to include a
full path statement to each &#8220;resource.h&#8221; file.<span style="mso-spacerun:
yes">&nbsp; </span>This article will show in the following example what is probably
the best method (keeping in mind that if a project needs this resource file it
must manually be added to the project including the full path to it).</p>

<p>3) Edit the &#8220;StdAfx.h&#8221; file and include the following MACROS and header file
&#8220;resource.h&#8221;.</p>

<pre><span style='color:black'>StdAfx.h<o:p></o:p></span></pre><pre><span
style='color:black'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></pre><pre><span
style='color:black'>//<o:p></o:p></span></pre><pre><span style='color:black'>// MSVS included headers, definitions, etc.<o:p></o:p></span></pre><pre><span
style='color:black'>//<o:p></o:p></span></pre><pre><span style='color:black'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></pre><pre><span
style='color:black'>// Somewhere near the bottom<o:p></o:p></span></pre><pre><span
style='color:black'>#ifdef DLL_EXPORTS //This is the project macro preprocessor definition you will be adding shortly. <span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="mso-spacerun: yes">&nbsp;&nbsp;</span><o:p></o:p></span></pre><pre><span
style='color:black'>#define DLL_BUILD_MACRO __declspec(dllexport) //This is to be used for the class header file.<o:p></o:p></span></pre><pre><span
style='color:black'>#else<o:p></o:p></span></pre><pre><span style='color:black'>#define DLL_BUILD_MACRO __declspec(dllimport) <o:p></o:p></span></pre><pre><span
style='color:black'>#endif<o:p></o:p></span></pre><pre><span style='color:black'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></pre><pre><span
style='color:black'>#ifndef _DLL_BUILD_ //Why do this?<span style="mso-spacerun: yes">&nbsp; </span>Is it necessary?<span style="mso-spacerun: yes">&nbsp; </span>Yes.<o:p></o:p></span></pre><pre><span
style='color:black'>#define _DLL_BUILD_ DLL_BUILD_MACRO<o:p></o:p></span></pre><pre><span
style='color:black'>#endif<o:p></o:p></span></pre><pre><span style='color:black'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></pre><pre><span
style='color:black'>#include &#8220;resource.h&#8221; //make sure resources are included here, if desired, to prevent ambiguous callings to different resource.h files.<o:p></o:p></span></pre><pre><span
style='color:black'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></pre><pre><span
style='color:black'>//<o:p></o:p></span></pre><pre><span style='color:black'>// Rest of file<o:p></o:p></span></pre><pre><span
style='color:black'>//<o:p></o:p></span></pre><pre><span style='color:black'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></pre>

<p>4a) Next we go ahead and edit the main header file of your DLL code.<span
style="mso-spacerun: yes">&nbsp; </span>Only a few simple lines need be added
to support accurate DLL building and usage:</p>

<pre><u><span style='color:black'>foo.h<o:p></o:p></span></u></pre><pre><span
style='color:black'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></pre><pre><span
style='color:black'>#ifndef _FOO_H_<o:p></o:p></span></pre><pre><span
style='color:black'>#define _FOO_H_<o:p></o:p></span></pre><pre><span
style='color:black'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></pre><pre><span
style='color:black'>//<o:p></o:p></span></pre><pre><span style='color:black'>// Miscellanous here<o:p></o:p></span></pre><pre><span
style='color:black'>//<o:p></o:p></span></pre><pre><span style='color:black'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></pre><pre><span
style='color:black'>/*<o:p></o:p></span></pre><pre><span style='color:black'>This part automatically includes any libraries when called.<span style="mso-spacerun: yes">&nbsp; </span>When this file is built within the DLL project, it will not be called because of our preprocessor macro definition &#8220;_FOO_DLL_&#8221;.<span style="mso-spacerun: yes">&nbsp; </span>However, when this file is called from another project, not part of this build, it appropriately chooses the correct library and includes them for you. WHAT this means is that you will not have to add the library to the project link settings for a project that requires this DLL.<span style="mso-spacerun: yes">&nbsp; </span>This helps to avoid the tedious task of linking to several custom DLLs.<o:p></o:p></span></pre><pre><span
style='color:black'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></pre><pre><span
style='color:black'>Note there are two different libraries here and probably not necessary but give you an idea of how to separate debug versions from release versions.<o:p></o:p></span></pre><pre><span
style='color:black'>*/<o:p></o:p></span></pre><pre><span style='color:black'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></pre><pre><span
style='color:black'>#ifndef _FOO_DLL_<o:p></o:p></span></pre><pre><span
style='color:black'>#ifdef _DEBUG<o:p></o:p></span></pre><pre><span
style='color:black'>#pragma comment( lib, &#8220;food.lib&#8221; ) //You will be building a debug program that uses this file, so in this case we want the debug library.<o:p></o:p></span></pre><pre><span
style='color:black'>#else<o:p></o:p></span></pre><pre><span style='color:black'>#pragma comment( lib, &#8220;foo.lib&#8221; ) //You will be building a release program that uses this file, so in this case we want the release library.<o:p></o:p></span></pre><pre><span
style='color:black'>#endif<o:p></o:p></span></pre><pre><span style='color:black'>#endif<o:p></o:p></span></pre><pre><span
style='color:black'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></pre><pre><span
style='color:black'>#ifndef _DLL_BUILD_<o:p></o:p></span></pre><pre><span
style='color:black'>#define _DLL_BUILD_ //Makes sure there are no compiler errors.<o:p></o:p></span></pre><pre><span
style='color:black'>#endif<o:p></o:p></span></pre><pre><span style='color:black'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></pre><pre><span
style='color:black'>class _DLL_BUILD_ foo<o:p></o:p></span></pre><pre><span
style='color:black'>{<o:p></o:p></span></pre><pre><span style='color:black'>private:<o:p></o:p></span></pre><pre><span
style='color:black'>//<o:p></o:p></span></pre><pre><span style='color:black'>// Your members<o:p></o:p></span></pre><pre><span
style='color:black'>//<o:p></o:p></span></pre><pre><span style='color:black'>public:<o:p></o:p></span></pre><pre><span
style='color:black'>//<o:p></o:p></span></pre><pre><span style='color:black'>// Your functions<o:p></o:p></span></pre><pre><span
style='color:black'>//<o:p></o:p></span></pre><pre><span style='color:black'>};<o:p></o:p></span></pre><pre><span
style='color:black'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></pre><pre><span
style='color:black'>#endif<o:p></o:p></span></pre>

<p>4b) To continue, edit the &#8220;foo.cpp&#8221; file and make sure you include the appropriate
headers.</p>

<pre><u><span style='color:black'>foo.cpp<o:p></o:p></span></u></pre><pre><span
style='color:black'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></pre><pre><span
style='color:black'>#include &#8220;stdafx.h&#8221; //place first<o:p></o:p></span></pre><pre><span
style='color:black'>#include &#8220;foo.h&#8221;<o:p></o:p></span></pre><pre><span
style='color:black'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></pre><pre><span
style='color:black'>//<o:p></o:p></span></pre><pre><span style='color:black'>//Your code<o:p></o:p></span></pre><pre><span
style='color:black'>//<o:p></o:p></span></pre>

<p>5a) This next step requires that you actually add the MACROS into the
project settings.<span style="mso-spacerun: yes">&nbsp; </span>In the menu tool
bar, go to &#8220;Project-&gt;Settings&#8230;&#8221; or press Alt+F7 alternatively.<span
style="mso-spacerun: yes">&nbsp; </span>Click the &#8220;C/C++&#8221; tab.<span
style="mso-spacerun: yes">&nbsp; </span>Under &#8220;Preprocessor definitions:&#8221; add
the macro definitions &#8220;_FOO_DLL_&#8221; and &#8220;DLL_EXPORTS&#8221; at the end of the list of other
macro definitions.<span style="mso-spacerun: yes">&nbsp; </span>Be sure to separate
each new MACRO with a coma (&#8220;,&#8221;).<span style="mso-spacerun: yes">&nbsp; </span>Make
sure to do this for the release version too, as you will have to redo these
next steps for each type of build.</p>

<p>Make sure to build with any &#8220;debug info&#8221; and/or &#8220;browse info&#8221; if this is a
debug version and if you want to debug the DLL later using the MSVS debugger.<span
style="mso-spacerun: yes">&nbsp; </span></p>

<p>5b) Next you will want to prepare for the last step.<span
style="mso-spacerun: yes">&nbsp; </span>Go to the &#8220;Post-build step&#8221; tab under
the same dialog.<span style="mso-spacerun: yes">&nbsp; </span>Under &#8220;Post-buid
command(s):&#8221; click an empty space and enter &#8220;Debug.bat&#8221;.<span
style="mso-spacerun: yes">&nbsp; </span>For the release version go to in the
left pane and in the combo box &#8220;Settings For:&#8221; select &#8220;Win32 Release&#8221;.<span
style="mso-spacerun: yes">&nbsp; </span>Enter like you did before in &#8220;Post-Build
command(s)&#8221; but not &#8220;Debug.bat&#8221; and instead &#8220;Release.bat&#8221;.<span
style="mso-spacerun: yes">&nbsp; </span>This is it for all the project
settings.</p>

<p>6) Now to build the batch files.<span style="mso-spacerun: yes">&nbsp;
</span>Create a blank file.<span style="mso-spacerun: yes">&nbsp; </span>You will
be adding command line codes that will copy your files to a findable
directory.<span style="mso-spacerun: yes">&nbsp; </span>The point here is that
if you may have a ton of DLLs and it will be easier to have all the needed
components in one directory.<span style="mso-spacerun: yes">&nbsp; </span>This
is easier versus linking to several directories.<span style="mso-spacerun:
yes">&nbsp; </span>Below are the suggestions used in this article that maybe
you will want to consider for adding other options:</p>

<pre><u><span style='color:black'>Debug.bat<o:p></o:p></span></u></pre><pre><span
style='color:black'>Copy &#8220;Debug\foo.lib&#8221; &#8220;c:\&lt;libraries dir&gt;\food.lib&#8221;<o:p></o:p></span></pre><pre><span
style='color:black'>REM copy the dll file to the windows system32 directory to make the DLL easily accessible.<span style="mso-spacerun: yes">&nbsp; </span>Note that you will have to install or include the <o:p></o:p></span></pre><pre><span
style='color:black'>REM dll file in your distribution package for the program that uses it.<o:p></o:p></span></pre><pre><span
style='color:black'>Copy &#8220;Debug\foo.dll&#8221; &#8220;c:\%system dir%\system32&#8221;<o:p></o:p></span></pre><pre><span
style='color:black'>Copy &#8220;foo.h&#8221; <span style="mso-spacerun: yes">&nbsp;</span>&#8220;c:\&lt;headers dir&gt;&#8221;<o:p></o:p></span></pre><pre><span
style='color:black'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></pre><pre><u><span
style='color:black'>Release.bat<o:p></o:p></span></u></pre><pre><span
style='color:black'>Copy &#8220;Release\foo.lib&#8221; &#8220;c:\&lt;libraries dir&gt;&#8221;<o:p></o:p></span></pre><pre><span
style='color:black'>REM copy the dll file to the windows system32 directory to make the DLL easily accessible.<span style="mso-spacerun: yes">&nbsp; </span>Note that you will have to install or include the <o:p></o:p></span></pre><pre><span
style='color:black'>REM dll file in your distribution package.<span style="mso-spacerun: yes">&nbsp; </span>Unfortanetly this will overwrite any other DLL files such as the Release/Debug version, so <o:p></o:p></span></pre><pre><span
style='color:black'>REM accurate update compilations are needed.<span style="mso-spacerun: yes">&nbsp; </span>You will have to note this yourself before distributing to the public.<o:p></o:p></span></pre><pre><span
style='color:black'>Copy &#8220;Release\foo.dll&#8221; &#8220;c:\%system dir%\system32&#8221;<o:p></o:p></span></pre><pre><span
style='color:black'>Copy &#8220;foo.h&#8221; <span style="mso-spacerun: yes">&nbsp;</span>&#8220;c:\&lt;headers dir&gt;&#8221;<o:p></o:p></span></pre><pre><span
style='color:black'><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></span></pre>

<p>You are completely finished.<span style="mso-spacerun: yes">&nbsp;
</span>Providing you have already pre-tested your class and considered where
your library, header and DLL files are being copied you <i>should receive no
problems</i> at all.<span style="mso-spacerun: yes">&nbsp; </span>Your class
should be a DLL file that can be easily used in future projects without much work.<span
style="mso-spacerun: yes">&nbsp; </span>All you have to do with this
information is to know that you only need to include the header file and
everything is done for you.<span style="mso-spacerun: yes">&nbsp;
</span>Everything is made as easy and simple as possible for you on in out.</p>

<p>NOTES:</p>

<p>Some reminders are that the DLL file must be accessible.<span
style="mso-spacerun: yes">&nbsp; </span>This article references using the &#8220;c:\windows\system32&#8221;
directory.<span style="mso-spacerun: yes">&nbsp; </span>This may be a bad idea
if you want to later retrieve that DLL file and must find it in the large
collection of DLLs probably existing already in that directory.<span
style="mso-spacerun: yes">&nbsp;&nbsp; </span>It can also be annoying if you
later decide to change the name of the project and build under the different
name.<span style="mso-spacerun: yes">&nbsp; </span>In that case you will have
to find the old DLL file and manually remove it or just leave it there.<span
style="mso-spacerun: yes">&nbsp; </span></p>

<p>Alternatively you can copy the DLL file(s), library file(s) and header file(s)
to the project directory that will be using it.<span style="mso-spacerun:
yes">&nbsp; </span>However, if you decide to use the same DLL in another
project you will have to go back and add a copy command line(s) in both the &#8220;Debug.bat&#8221;
and &#8220;Release.bat&#8221; files and then rebuild the project to have them copied.<span
style="mso-spacerun: yes">&nbsp; </span></p>

<p>Also note that in MSVS it is easy to add custom directories for new header
directories to search, but unfortunately not DLL directories.<span
style="mso-spacerun: yes">&nbsp; </span>Go under &#8220;Tools-&gt;Options&#8221; in the
menu bar and then under the &#8220;Directories&#8221; tab button.<span style="mso-spacerun:
yes">&nbsp; </span>Where &#8220;&lt;libraries dir&gt;&#8221; above in the batch file should
be included under &#8220;Library files&#8221; in the &#8220;Show directories for&#8221; combo box and &#8220;&lt;headers
dir&gt;&#8221; in the &#8220;Include files&#8221;.</p>

<p>Some MACROS may seem repetitive or not in use in this article.<span
style="mso-spacerun: yes">&nbsp; </span>However, the compiler, when building,
requires this type of style for both the DLL project and the project using that
DLL.<span style="mso-spacerun: yes">&nbsp; </span>If you find that some are not
needed you can remove them yourself.<span style="mso-spacerun: yes">&nbsp;
</span>This code is designed so that they are there and readably accessible. <span
style="mso-spacerun: yes">&nbsp;&nbsp;</span>Testing shows that for both the
DLL build and the project using that DLL build require these types of MACRO
setups for usage.<span style="mso-spacerun: yes">&nbsp; </span>Other
possibilities and locations exist.</p>

<h2>Points of Interest</h2>

<p>Figuring out Firewalls, UNIX and why mail programs show the contents automatically
in Windows. </p>

<h2>History</h2>

<p>N/A</p>

<p><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></p>

</div>

</body>

</html>

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 States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions