<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://wiki.jackslab.org/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-cn">
		<id>http://wiki.jackslab.org/index.php?action=history&amp;feed=atom&amp;title=Win32_%E4%B8%8B%E5%8A%A8%E6%80%81%E9%93%BE%E6%8E%A5%E5%BA%93_%28DLL%29_%E6%9C%BA%E5%88%B6%E7%AC%94%E8%AE%B0</id>
		<title>Win32 下动态链接库 (DLL) 机制笔记 - 版本历史</title>
		<link rel="self" type="application/atom+xml" href="http://wiki.jackslab.org/index.php?action=history&amp;feed=atom&amp;title=Win32_%E4%B8%8B%E5%8A%A8%E6%80%81%E9%93%BE%E6%8E%A5%E5%BA%93_%28DLL%29_%E6%9C%BA%E5%88%B6%E7%AC%94%E8%AE%B0"/>
		<link rel="alternate" type="text/html" href="http://wiki.jackslab.org/index.php?title=Win32_%E4%B8%8B%E5%8A%A8%E6%80%81%E9%93%BE%E6%8E%A5%E5%BA%93_(DLL)_%E6%9C%BA%E5%88%B6%E7%AC%94%E8%AE%B0&amp;action=history"/>
		<updated>2026-10-15T06:32:34Z</updated>
		<subtitle>本wiki的该页面的版本历史</subtitle>
		<generator>MediaWiki 1.19.2</generator>

	<entry>
		<id>http://wiki.jackslab.org/index.php?title=Win32_%E4%B8%8B%E5%8A%A8%E6%80%81%E9%93%BE%E6%8E%A5%E5%BA%93_(DLL)_%E6%9C%BA%E5%88%B6%E7%AC%94%E8%AE%B0&amp;diff=1090&amp;oldid=prev</id>
		<title>2013年9月24日 (二) 09:19 Comcat</title>
		<link rel="alternate" type="text/html" href="http://wiki.jackslab.org/index.php?title=Win32_%E4%B8%8B%E5%8A%A8%E6%80%81%E9%93%BE%E6%8E%A5%E5%BA%93_(DLL)_%E6%9C%BA%E5%88%B6%E7%AC%94%E8%AE%B0&amp;diff=1090&amp;oldid=prev"/>
				<updated>2013-09-24T09:19:45Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
			&lt;tr valign='top'&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←上一版本&lt;/td&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;2013年9月24日 (二) 09:19的版本&lt;/td&gt;
			&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第41行：&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第41行：&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;完了会生成 simple.dll simple.lib&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;完了会生成 simple.dll simple.lib&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;&amp;#160; &lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;=== 加载时动态链接测试 ===&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;=== 加载时动态链接测试 ===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第200行：&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第202行：&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Comcat</name></author>	</entry>

	<entry>
		<id>http://wiki.jackslab.org/index.php?title=Win32_%E4%B8%8B%E5%8A%A8%E6%80%81%E9%93%BE%E6%8E%A5%E5%BA%93_(DLL)_%E6%9C%BA%E5%88%B6%E7%AC%94%E8%AE%B0&amp;diff=1089&amp;oldid=prev</id>
		<title>2013年9月24日 (二) 09:19 Comcat</title>
		<link rel="alternate" type="text/html" href="http://wiki.jackslab.org/index.php?title=Win32_%E4%B8%8B%E5%8A%A8%E6%80%81%E9%93%BE%E6%8E%A5%E5%BA%93_(DLL)_%E6%9C%BA%E5%88%B6%E7%AC%94%E8%AE%B0&amp;diff=1089&amp;oldid=prev"/>
				<updated>2013-09-24T09:19:04Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
			&lt;tr valign='top'&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←上一版本&lt;/td&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;2013年9月24日 (二) 09:19的版本&lt;/td&gt;
			&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第42行：&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第42行：&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;完了会生成 simple.dll simple.lib&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;完了会生成 simple.dll simple.lib&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;== 加载时动态链接测试 ==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;=&lt;/ins&gt;== 加载时动态链接测试 &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;=&lt;/ins&gt;==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第67行：&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第67行：&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;== 运行时动态加载测试 ==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;=&lt;/ins&gt;== 运行时动态加载测试 &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;=&lt;/ins&gt;==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第178行：&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;第178行：&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;== 加载时动态链接测试 ==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;=&lt;/ins&gt;== 加载时动态链接测试 &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;=&lt;/ins&gt;==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Comcat</name></author>	</entry>

	<entry>
		<id>http://wiki.jackslab.org/index.php?title=Win32_%E4%B8%8B%E5%8A%A8%E6%80%81%E9%93%BE%E6%8E%A5%E5%BA%93_(DLL)_%E6%9C%BA%E5%88%B6%E7%AC%94%E8%AE%B0&amp;diff=1088&amp;oldid=prev</id>
		<title>Comcat：以“== 准备 ==  使用 VC++ 带的命令行编译器 cl 前，需用 &quot;C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat&quot; 设置环境变量:  &lt;pre&gt; C:\&gt; cd w...”为内容创建页面</title>
		<link rel="alternate" type="text/html" href="http://wiki.jackslab.org/index.php?title=Win32_%E4%B8%8B%E5%8A%A8%E6%80%81%E9%93%BE%E6%8E%A5%E5%BA%93_(DLL)_%E6%9C%BA%E5%88%B6%E7%AC%94%E8%AE%B0&amp;diff=1088&amp;oldid=prev"/>
				<updated>2013-09-24T09:18:25Z</updated>
		
		<summary type="html">&lt;p&gt;以“== 准备 ==  使用 VC++ 带的命令行编译器 cl 前，需用 &amp;quot;C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat&amp;quot; 设置环境变量:  &amp;lt;pre&amp;gt; C:\&amp;gt; cd w...”为内容创建页面&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== 准备 ==&lt;br /&gt;
&lt;br /&gt;
使用 VC++ 带的命令行编译器 cl 前，需用 &amp;quot;C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat&amp;quot; 设置环境变量:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
C:\&amp;gt; cd workspace\dll&lt;br /&gt;
C:\workspace\dll&amp;gt; &amp;quot;C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== DLL 导出简单 C 函数 ==&lt;br /&gt;
&lt;br /&gt;
simple.cc:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#ifdef __cplusplus    // If used by C++ code, &lt;br /&gt;
extern &amp;quot;C&amp;quot; {          // we need to export the C interface&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
__declspec(dllexport) int myPuts(char *lpszMsg)&lt;br /&gt;
{&lt;br /&gt;
    printf(&amp;quot;%s\n&amp;quot;, lpszMsg);&lt;br /&gt;
    return 1;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#ifdef __cplusplus&lt;br /&gt;
}&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
编译生成 DLL:&lt;br /&gt;
&lt;br /&gt;
  cl /LD /Fesimple.dll simple.cc&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
选项 /LD 告诉编译器创建 DLL&lt;br /&gt;
&lt;br /&gt;
完了会生成 simple.dll simple.lib&lt;br /&gt;
  &lt;br /&gt;
== 加载时动态链接测试 ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;lt;windows.h&amp;gt;&lt;br /&gt;
int myPuts(char *str);   // a function from a DLL&lt;br /&gt;
int main(VOID) &lt;br /&gt;
{ &lt;br /&gt;
    int Ret = 1;&lt;br /&gt;
    Ret = myPuts(&amp;quot;Using the DLL function, HaHaHaHa, Tutututu\n&amp;quot;); &lt;br /&gt;
    return Ret;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
以上保存为 load.time.link.c&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
编译之：&lt;br /&gt;
&lt;br /&gt;
  cl /Feload.time.link.exe load.time.link.c simple.lib&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
simple.lib 为 simple.dll 对应的 import library，链接时为链接器 link.exe 所需要&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 运行时动态加载测试 ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt; &lt;br /&gt;
#include &amp;lt;windows.h&amp;gt; &lt;br /&gt;
&lt;br /&gt;
typedef int (*MYFUNC)(char *); &lt;br /&gt;
&lt;br /&gt;
VOID main(VOID) &lt;br /&gt;
{ &lt;br /&gt;
    HINSTANCE hinstLib; &lt;br /&gt;
    MYFUNC ProcAdd; &lt;br /&gt;
    BOOL fFreeResult, fRunTimeLinkSuccess = FALSE; &lt;br /&gt;
&lt;br /&gt;
    //用 LoadLibrary() 加载 simple.dll&lt;br /&gt;
    hinstLib = LoadLibrary(TEXT(&amp;quot;simple&amp;quot;));    &lt;br /&gt;
&lt;br /&gt;
    // If the handle is valid, try to get the function address.&lt;br /&gt;
    if (hinstLib != NULL) &lt;br /&gt;
    { &lt;br /&gt;
        //用 GetProcAddress() 获取 DLL 中函数地址&lt;br /&gt;
        ProcAdd = (MYPROC) GetProcAddress(hinstLib, TEXT(&amp;quot;myPuts&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
        // If the function address is valid, call the function.&lt;br /&gt;
        if (NULL != ProcAdd) &lt;br /&gt;
        {&lt;br /&gt;
            fRunTimeLinkSuccess = TRUE;&lt;br /&gt;
            (ProcAdd) (TEXT(&amp;quot;Message via DLL function, HaHaHa, TUTUTUTUTU\n&amp;quot;)); &lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        // Free the DLL module.&lt;br /&gt;
        fFreeResult = FreeLibrary(hinstLib); &lt;br /&gt;
    } &lt;br /&gt;
&lt;br /&gt;
    if (! fRunTimeLinkSuccess) &lt;br /&gt;
        printf(&amp;quot;Load DLL failed\n&amp;quot;); &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
存为 run.time.link.c，如下命令编译之：&lt;br /&gt;
&lt;br /&gt;
  cl /Ferun.time.link.exe run.time.link.c&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
== DLL 中导出C++ 类 ==&lt;br /&gt;
&lt;br /&gt;
与导出 C 风格的函数类似，在定义类时用 __declspec(dllexport):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class __declspec(dllexport) MyCppClass&lt;br /&gt;
{&lt;br /&gt;
    ......&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
编译时，依然用:&lt;br /&gt;
&lt;br /&gt;
  cl /Fesimple.dll /LD smiple.cc&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
加载时动态链接，则要在使用前加 __declspec(dllimport) 声明之：&lt;br /&gt;
&lt;br /&gt;
  class __declspec(dllimport) MyCppClass;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
如下所示列：&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
----------&lt;br /&gt;
comcat.h:&lt;br /&gt;
----------&lt;br /&gt;
#ifndef _MY_CMATH_H_&lt;br /&gt;
#define _MY_CMATH_H_&lt;br /&gt;
#ifdef _CLASS_INDLL_&lt;br /&gt;
#define _CLASS_DECL_ __declspec(dllexport)&lt;br /&gt;
#else &lt;br /&gt;
#define _CLASS_DECL_ __declspec(dllimport)&lt;br /&gt;
#endif&lt;br /&gt;
class _CLASS_DECL_ CMath &lt;br /&gt;
{ &lt;br /&gt;
public: &lt;br /&gt;
    int Add(int a,int b); &lt;br /&gt;
    CMath(); &lt;br /&gt;
    ~CMath(){}; &lt;br /&gt;
};&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
comcat.cc:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;quot;comcat.h&amp;quot;&lt;br /&gt;
CMath::CMath()&lt;br /&gt;
{&lt;br /&gt;
};&lt;br /&gt;
int CMath::Add(int a, int b)&lt;br /&gt;
{&lt;br /&gt;
    return a + b;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
如下命令生成 DLL:&lt;br /&gt;
&lt;br /&gt;
  cl /LD /Fecomcat.dll /D_CLASS_INDLL_ comcat.cc&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 加载时动态链接测试 ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class.load.test.cc&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;quot;comcat.h&amp;quot;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    CMath *cm = new CMath;&lt;br /&gt;
    std::cout &amp;lt;&amp;lt; &amp;quot;cmath's result:&amp;quot; &amp;lt;&amp;lt; cm-&amp;gt;Add(5, 8) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
如下命令编译之：&lt;br /&gt;
&lt;br /&gt;
  cl /Feclass.load.test.exe class.load.test.cc comcat.lib&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Comcat</name></author>	</entry>

	</feed>