[System::Runtime::InteropServices::DllImport(L"user32.dll")]

//or
using namespace System::Runtime::InteropServices;

	[DllImport("C:\\Program Files (x86)\\VideoLAN\\VLC\\libvlc.dll")]

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 will also be checked.
You 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.

DLLImport


	public ref class MyClass
	{
	public:
		//DLLImport
		[DllImport("kernel32.dll", CharSet = CharSet::Auto, SetLastError = true)]
		static bool SetDllDirectory(String ^lpPathName);

	MyClass::SetDllDirectory(Environment::GetFolderPath(Environment::SpecialFolder::ProgramFiles) + "\\VideoLAN\\VLC\\");

Add dll File As A Reference To Your Project Instead

Add the dll file to the main project directory.

Right Click Project > Common Properties > Framework and References > Add new reference > Browse > [select your dll file]

Now you can use it without importing:


using namespace MyDllName;

 

Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published.