So basically I want to know how to use the Win32API function... I've seen people doing things like
Win32API.new("x.dll", "method","","").call(things here)
So,
x.dll is the path to the class library right?
"method" is it the name of the function inside the class library?
I don't know what the next two parameters/arguments are for...
things here I think is the parameters/arguments taken by the function called, am I right?
x.dll is usually a windows provided DLL, or one you made yourself. It's just the file name(paths may work, I'm not sure). The next parameter is an array telling Ruby what the dll takes. The codes that I remember off the top of my head are:
P - String
I - integer
L - long
So if your method took a string then an integer, you'd use ['P', 'I']. I have been told you can also just do' PI', but I prefer the array way personally.
The next parameter is the return value. These are the same as above, except there can only by one, it is not an array. Additionally, you can use 'V' to specify void, it does not have a return value.
I see thanks!
btw, I'm having a problem...
I tried to make a dll in VB.net, but when I try using it, RM returns an error:
ProcAddress something something for the function that I'm calling...
the function was inside a class in the library so I did it like this:
Win32API.new('x.dll', 'Class.Function', 'V', 'P').call('')
Am I doing something wrong? or RM simply cannot use dlls made in VB.net?
btw, I placed the dll in the same folder as the project...
you need to export the methods to C. I'm not sure about VB(or if it even will work with VB or VB.NET), but in C++ it's extern "C" return_type name(params).
Oh... I see... Thanks!
if it won't work in VB then I guess I just need to learn how to do them in C++...
It seems to be doable in VB with quite a lot of work...
C++ can be difficult sometimes, it's very low-level (low-level means it's got very little sugarcoating. Ruby is very high-level. It's very easy to use and has a lot of built in functionality, but it's not a compiled language, it's run through an interpreter, and since a program is running ruby, it doesn't have as much access to hardware and other things like C++ does), which makes it very powerful, but also very difficult. It doesn't have a lot of functionality you'd find in Ruby, you need to make it yourself. Most of it is easy, yes, but some of it not so much. It's definitely doable, though.
I also don't believe that .NET DLL's (Maybe it was only C# and C#.NET) will work with Ruby, but I haven't confirmed this.
I'm currently on the process of exporting the dll functions, just having some errors recompiling with ilasm... anyway, if it will not work, then I'd just try to make it in C++... hopefully, I could make it work, if not then I'd study more about C++ maybe before retrying... 🙂
I managed to recompile the .dll which should now have the functions exported, but I cannot test yet... My lappy is at home, and in the office I only have the Lite version so no scripts...
but hey it's quite a lot of work... I might not do this again for the near future... it's not really that important, I just really wanted to find what I can do with dlls...
Thanks for replying!
I think this can be closed now... 🙂
Ohh... I see... thanks...
EDIT: got to test it, it doesn't do the error now, but it stops the game from working... maybe I did something wrong while editing the dll using the idlasm/ilasm technique... anyway, have more important things to do in the maker than this whole DLL thingy... I'll just try to fix it up sometime (maybe I'll try the inject .net dll to a c++ dll method)...
@Moderators: I think this should be closed now... Thanks!