{"id":4687,"date":"2014-03-30T14:44:36","date_gmt":"2014-03-30T14:44:36","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/plugin-dlls-that-depend-on-other-dlls-collection-of-common-programming-errors\/"},"modified":"2014-03-30T14:44:36","modified_gmt":"2014-03-30T14:44:36","slug":"plugin-dlls-that-depend-on-other-dlls-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/plugin-dlls-that-depend-on-other-dlls-collection-of-common-programming-errors\/","title":{"rendered":"Plugin DLLs that depend on other DLLs-Collection of common programming errors"},"content":{"rendered":"<p>I am writing a DLL to plug into another (3rd party) application. The DLL will need to depend on another set of DLLs (for license reasons I cannot link statically).<\/p>\n<p>I would like my DLL to be &#8220;xcopy-deployable&#8221; to any directory. I would also like not to require adding this directory to the path.<\/p>\n<p>If I just build the DLL the usual way, Windows will refuse to load the DLL, since it cannot find the DLLs next to the current process.<\/p>\n<p>Are there any good options for helping Windows locate the DLL?<\/p>\n<p>To answer some questions:<\/p>\n<ul>\n<li>The DLL is written in C++.<\/li>\n<li>The extra DLLs are QT-dlls.<\/li>\n<li>I would like to place the extra DLLs in the same folder as my plugin DLL. I can get the name of that folder from <code>GetModuleFileName<\/code>.<\/li>\n<li>The application is Firefox, the DLL is a PKCS#11 security module.<\/li>\n<li>The application loads the DLL using the full path to the DLL (the user supplies it when installing the plugin).<\/li>\n<li>Requiring that the DLLs be placed in System32 or next to the application would work, but it is a bit messy and could cause problems with uninstallers.<\/li>\n<li><code>LoadLibrary<\/code> and <code>GetProcAddress<\/code> would of course work, but is not really feasible in my case. I am using hundreds, if not thousands, of methods in the other DLLs. I really need to use the import-libraries.<\/li>\n<\/ul>\n<p>I had thought about using delay-loaded dlls combined with <code>SetDllDirectory<\/code> in DllMain. Have anyone tried anything like this?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I am writing a DLL to plug into another (3rd party) application. The DLL will need to depend on another set of DLLs (for license reasons I cannot link statically). I would like my DLL to be &#8220;xcopy-deployable&#8221; to any directory. I would also like not to require adding this directory to the path. If [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4687","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4687","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4687"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4687\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4687"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4687"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4687"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}