{"id":827,"date":"2012-09-13T11:42:14","date_gmt":"2012-09-13T11:42:14","guid":{"rendered":"https:\/\/ibex.tech\/visualcpp\/?p=827"},"modified":"2022-02-17T06:24:03","modified_gmt":"2022-02-17T06:24:03","slug":"dllimport-general","status":"publish","type":"post","link":"https:\/\/ibex.tech\/visualcpp\/dllimport\/dllimport-general","title":{"rendered":"DLLImport General"},"content":{"rendered":"<pre>\r\n<code>\r\n\t[System::Runtime::InteropServices::DllImport(L&quot;user32.dll&quot;)]\r\n\r\n\/\/or\r\nusing namespace System::Runtime::InteropServices;\r\n\r\n\t[DllImport(&quot;C:\\\\Program Files (x86)\\\\VideoLAN\\\\VLC\\\\libvlc.dll&quot;)]\r\n<\/code><\/pre>\n<p>\nNote the string is a constant defined at compile time.<br \/>\nThe default search order will start looking in the directory from which your application was loaded. If you place a DLL there during the install, it will be found.<br \/>\nThe locations specified in the system PATH variable will also be checked.<br \/>\nYou can use the SetDllDirectory function to specify a single location for dllimport to check, or you need to add locations to the system PATH variable for multiple locations.\n<\/p>\n<h4>\nDLLImport<br \/>\n<\/h4>\n<pre>\r\n<code>\r\n\tpublic ref class MyClass\r\n\t{\r\n\tpublic:\r\n\t\t\/\/DLLImport\r\n\t\t[DllImport(\"kernel32.dll\", CharSet = CharSet::Auto, SetLastError = true)]\r\n\t\tstatic bool SetDllDirectory(String ^lpPathName);\r\n<\/code><\/pre>\n<pre>\r\n<code>\r\n\tMyClass::SetDllDirectory(Environment::GetFolderPath(Environment::SpecialFolder::ProgramFiles) + &quot;\\\\VideoLAN\\\\VLC\\\\&quot;);\r\n<\/code><\/pre>\n<h4>\nAdd dll File As A&nbsp;Reference To Your Project Instead<br \/>\n<\/h4>\n<p>\nAdd the dll file to the main project directory.\n<\/p>\n<p>\nRight Click Project &gt; Common Properties &gt; Framework and References &gt; Add new reference &gt; Browse &gt; [select your dll file]\n<\/p>\n<p>\nNow you can use it without importing:\n<\/p>\n<pre>\r\n<code>\r\nusing namespace MyDllName;\r\n<\/code><\/pre>\n<p>\n&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>[System::Runtime::InteropServices::DllImport(L&quot;user32.dll&quot;)] \/\/or using namespace System::Runtime::InteropServices; [DllImport(&quot;C:\\\\Program Files (x86)\\\\VideoLAN\\\\VLC\\\\libvlc.dll&quot;)] Note the string is a constant defined at compile time. The default search order will start looking in the directory from which your application was loaded. If you place a DLL there during the install, it will be found. The locations specified in the system PATH variable [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[85],"tags":[],"class_list":["post-827","post","type-post","status-publish","format-standard","hentry","category-dllimport"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts\/827","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/comments?post=827"}],"version-history":[{"count":8,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts\/827\/revisions"}],"predecessor-version":[{"id":1182,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts\/827\/revisions\/1182"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/media?parent=827"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/categories?post=827"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/tags?post=827"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}