How can I add 开发者_如何学Ca C++ DLL file in my .NET application?
You would use an "extern" function, marked with the DllImport attribute.
[DllImport(@“C:\mylib.dll”)]
public static extern int myFunc(int param);
Depending on the nature of the DLL, you can
Add a reference to a registered COM DLL,
Call Win32 DLLs with P/Invoke, or
Write a wrapper in C++/CLI.
Assuming you use Visual Studio, in your Solution right click "references" and choose "Add Reference". Select your dll file.
In the classes that will use the dll, add : using MyLibrarysName;
then you can call the functions in that DLL using Mylibraryname.myfunction
If it's registered in COM, you can simply add a COM reference in Visual Studio and Visual Studio will do all the Interop creation for you.
精彩评论