How to load unmanaged library with P/Invoke?
So i have one old unmanaged library dll/tlb. I want to use it in .net 4.0 program. I have basicly no idea how to do this, so if u can provide me with some tutorial or even better example would be great. i was looking at this: pInvoke, .net 4 vs 3.5 but i can't figure anything out. I also checked this out but i don't know what should i be using so it would be working. http://codenition.blogspot.com/2010/05/pinvokestackimbalance-in-net-40i-beg.html
Thank u all for the help...
You add a reference to your library by right clicking the references folder in the solution explorer.
After that in the dialog box that appears you select the COM tab and the Browse, and find your DLL.
The if you want to acces different methods take a look at this example:
[DllImport("User32.dll")] public static extern int MessageBox(int h, string m, string c, int type);
Where the dll between the square braces is your DLL and the extern keyword allows you to specify you are using the method from an external library.
For more reference please read: http://msdn.microsoft.com/en-us/library/e59b22c5%28v=vs.80%29.aspx