That's C# and not C! Ok, it's of course no coincidence that the language was named C#, but it actually is different
.
As far as I can see it will not be very hard to translate this. I have not tested this, but it should be something like:
code:
var DllPath = "libvlc.dll"; // the full path to your dll
function VLC_Create() {
return Interop.Call(DllPath, "VLC_Create"); // Interop expects an int
}
function VLC_TimeSet(/*int*/ iVLC, /*int*/ Seconds, /*bool*/ Relative) {
return Interop.Call(DllPath, "VLC_TimeSet", iVLC, Seconds, (Relative?1:0));
}
// [...]
This way you should be able to create wrapper functions for all functions in the dll. Some points to notice:
ints (or Numbers in JScript) can be passed directly through interop.call
ref ints can be passed by assigning a 4 bytes databloc, use WriteDWORD to write the number on position 0 and then pass the datablocs pointer. After the function returns, you can read the int again.
bool's should be casted to 0 (=false) or 1 (=true)
strings can be passed directly, plus automatically passes the pointer
I'm not sure about the string array, maybe you can pass it directly, else you will have to use a databloc of size (total characters in the array strings) + (number of strings * 2).
Error, Mode and Pos can be seen as an int, just use the values described in their enums.
The
structure will be the only hard part, use a databloc for that. Add the sizes and write the types to the right part of the bloc. I don't know the sizes of the types by heart, so can't give you those now, maybe I can help with that later, or maybe (I hope so) you can figure it out yourself. Int32 means 32 bits = 4 bytes, so Int64 = 8 bytes, not sure about the rest
Anybody correct me if I am wrong here, this is it in a nuttshell, I am doing this all right out of my head (I am not sure if that is correct english, but at least the dutchies will get what I say there
) so there might be some mistakes. It should at least point you in the right direction!