{"id":40,"date":"2008-01-27T02:30:13","date_gmt":"2008-01-27T06:30:13","guid":{"rendered":"http:\/\/jianmingli.com\/wp\/?p=40"},"modified":"2008-01-28T00:29:42","modified_gmt":"2008-01-28T04:29:42","slug":"dll-basics","status":"publish","type":"post","link":"https:\/\/jianmingli.com\/wp\/?p=40","title":{"rendered":"DLL Basics"},"content":{"rendered":"<p>General\u00a0<\/p>\n<ul>\n<li>Bindings\n<ul>\n<li>Early binding\n<ul>\n<li>Loaded when program starts<\/li>\n<\/ul>\n<\/li>\n<li>Late binding\n<ul>\n<li>Loaded after program has started<\/li>\n<li>Calls LoadLibrary() to load dll<\/li>\n<li>Calls GetProcAddress() to get function address<\/li>\n<li>Calls FreeLibrary() to to unload dll<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>Contents<\/p>\n<ul>\n<li>Functionis<\/li>\n<li>Resources\n<ul>\n<li>Bitmaps<\/li>\n<li>Fonts<\/li>\n<\/ul>\n<\/li>\n<li>Static global variables<\/li>\n<li>DLL interface<\/li>\n<li>DllMain() function<\/li>\n<\/ul>\n<p>Varieties of DLL<\/p>\n<ul>\n<li>MFC extension DLL<\/li>\n<li>Regular DLL\n<ul>\n<li>Statically linked to MFC<\/li>\n<li>Dynamically linked to MFC<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>Create DLL<\/p>\n<ul>\n<li>Export class\n<ul>\n<li>Append AFX_EXT_CLASS to the class specifier\n<ul>\n<li>class AFX_EXT_CLASS CMyClass {&#8230;}<\/li>\n<\/ul>\n<\/li>\n<li>Or use the <strong>.def<\/strong> file\n<ul>\n<li>#define DLLEXPORT _declspec(dllexport)<\/li>\n<li>DLLEXPORT double avalue = 1.5;<\/li>\n<li>DLLEXPORT CString FinWinner(CString* Teams);<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>Add to StdAfx.h (StdAfx is acronym for standard application framework extenstion, later called MFC)\u00a0\n<ul>\n<li>#include &lt;afxtempl.h&gt;<\/li>\n<\/ul>\n<\/li>\n<li>Build artifacts\n<ul>\n<li>MyDll.dll\n<ul>\n<li>Contains executable code<\/li>\n<\/ul>\n<\/li>\n<li>MyDll.lib\n<ul>\n<li>Contains definitions of item that are exported from\u00a0DLL<\/li>\n<li>Must be avaible to client\u00a0application linker\u00a0<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>Files required to use DLL<\/p>\n<ul>\n<li>.h file\n<ul>\n<li>Defines items exported from dll<\/li>\n<li>Need to be included in the\u00a0host application\u00a0\n<ul>\n<li>#include &#8220;SimpleDll.h&#8221;<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>.lib file\n<ul>\n<li>Used by linker to link host application to dll<\/li>\n<li>Need to be included in the Project Link path\n<ul>\n<li>Project -&gt; Settings -&gt; Link<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>.dll file\n<ul>\n<li>Contains executable code for the dll<\/li>\n<li>Need to be in the system path with all its dependency dlls, e.g. Debug folder or System32 folder<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>General\u00a0 Bindings Early binding Loaded when program starts Late binding Loaded after program has started Calls LoadLibrary() to load dll Calls GetProcAddress() to get function address Calls FreeLibrary() to to unload dll Contents Functionis Resources Bitmaps Fonts Static global variables &hellip; <a href=\"https:\/\/jianmingli.com\/wp\/?p=40\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[11],"tags":[],"class_list":["post-40","post","type-post","status-publish","format-standard","hentry","category-cpp"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8cRUO-E","_links":{"self":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/40","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=40"}],"version-history":[{"count":0,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/40\/revisions"}],"wp:attachment":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=40"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=40"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=40"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}