<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Why LoadLibrary is much slower than GetModuleHandle for dll that is already loaded?</title><link>http://blogs.msdn.com/b/junfeng/archive/2005/03/18/398970.aspx</link><description>This question is asked in our internal discussion list. One of the kernel developer answered the question below: &amp;lt;quote&amp;gt; LoadLibrary(AlreadyLoadedModule) has to increment the reference count of AlreadyLoadedModule, plus all of that module's dependencies</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: Why LoadLibrary is much slower than GetModuleHandle for dll that is already loaded?</title><link>http://blogs.msdn.com/b/junfeng/archive/2005/03/18/398970.aspx#418565</link><pubDate>Tue, 17 May 2005 12:56:28 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:418565</guid><dc:creator>Qflash</dc:creator><description>RePost:&lt;br&gt;&lt;a rel="nofollow" target="_new" href="http://www.yeyan.cn/Programming/LoadLibraryGetModuleHandle.aspx"&gt;http://www.yeyan.cn/Programming/LoadLibraryGetModuleHandle.aspx&lt;/a&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=418565" width="1" height="1"&gt;</description></item><item><title>re: Why LoadLibrary is much slower than GetModuleHandle for dll that is already loaded?</title><link>http://blogs.msdn.com/b/junfeng/archive/2005/03/18/398970.aspx#400036</link><pubDate>Mon, 21 Mar 2005 21:35:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:400036</guid><dc:creator>Dean Harding</dc:creator><description>Right, like I said, I couldn't speak for the context of this discussion.  But I was just warning people that this is not a general solution for a faster version of LoadLibrary.&lt;br&gt;&lt;br&gt;You'd need to add extra code to make sure the libraries are never unloaded until all your GetModuleHandle callers have finished with it (for example, you'd call LoadLibrary the first time, then use GetModuleHandle subsequent times, then when you're all done you can do a FreeLibrary).&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=400036" width="1" height="1"&gt;</description></item><item><title>re: Why LoadLibrary is much slower than GetModuleHandle for dll that is already loaded?</title><link>http://blogs.msdn.com/b/junfeng/archive/2005/03/18/398970.aspx#399578</link><pubDate>Mon, 21 Mar 2005 06:08:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:399578</guid><dc:creator>Junfeng Zhang</dc:creator><description>Everything has to be discussed in a context. &lt;br&gt;&lt;br&gt;The context here is about performance, not about reliability. &lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=399578" width="1" height="1"&gt;</description></item><item><title>re: Why LoadLibrary is much slower than GetModuleHandle for dll that is already loaded?</title><link>http://blogs.msdn.com/b/junfeng/archive/2005/03/18/398970.aspx#399575</link><pubDate>Mon, 21 Mar 2005 06:02:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:399575</guid><dc:creator>Dean Harding</dc:creator><description>I wouldn't say GetModuleHandle was a better alternative at all.  At least not in general (I can't say for the context this discussion was in).  There's a pretty major race condition where you might call GetModuleHandle but before you actually try to use the returned handle, the module is unloaded by another thread.  That's not a problem with LoadLibrary because it increments the ref count for you.&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=399575" width="1" height="1"&gt;</description></item><item><title>Interesting finds this week</title><link>http://blogs.msdn.com/b/junfeng/archive/2005/03/18/398970.aspx#399066</link><pubDate>Sat, 19 Mar 2005 14:46:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:399066</guid><dc:creator>Jason Haley</dc:creator><description>Interesting finds this week&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=399066" width="1" height="1"&gt;</description></item><item><title>re: Why LoadLibrary is much slower than GetModluleHandle for dll that is already loaded?</title><link>http://blogs.msdn.com/b/junfeng/archive/2005/03/18/398970.aspx#399009</link><pubDate>Sat, 19 Mar 2005 07:48:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:399009</guid><dc:creator>RealOne</dc:creator><description>GetModuleHandle is a better alternative. &lt;br&gt;&lt;br&gt;？？？？？？？？？？？？？？&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=399009" width="1" height="1"&gt;</description></item></channel></rss>