Sometimes it will be great if I could use some other programs dll and customize them. For example there is a device called usb uirt where I can send ir signals from a computer. The software that is used to send the signals sucks and the drivers from the device come with a lot of dll’s. As a result, I tried importing them to visual studio but I could not create a reference. That was probably because maybe they were written in a different language I think. But someone managed to get a wrapper for those libraries and when I imported those dll it worked and I was able to control the device from c# which is great.
Anyways I was just curious about this and I want to learn more about it… How can I tell when can I use those dll’s? On what language they where created? I have tried googling that and I find stuff like:
[DllImport("my.dll")]
static extern void methodA(UInt32[] data);
what do the [] mean? Sometimes they use pointers… From my experience I have never had to use pointers. I can always pass a variable in c# by reference or by value plus with the help of delegates I don’t find the need for pointers but maybe I am wrong… I am interested in learning about all this. What phrase should I Google to learn about this?
What you are looking for is P/Invoke.
This is the way you add attributes to function calls. This is the
DllImportAttribute.Alternatively, if you meant the set of brackets in
UInt32[], then this signifies that this is an array of UInt32’s.It is possible to create pointers in C#
unsafecode, but for use with P/Invoke there is a better system called marshalling. Marshalling allows types to be converted between your managed C# code and the unmanaged code in the DLL. There is for instance aIntPtrclass for representing pointers to integers that you can use in the method declaration, but you would normally just pass in a regular integer and the marshalling code will automatically convert it for you.I’m unsure how to tell whether a given DLL is managed or not, but in regards to what language a given DLL was written in is irrelevant, and very difficult to determine after it has been compiled.