How to use Win32API

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.
oh... so here (I saw it on the F12 fix http://forums.rpgmakerweb.com/index.php?/topic/8000-f12-reset-fix/)

Win32API.new('kernel32.dll', 'SetConsoleTitle', 'P', '').call('RGSS3 Console')
kernel32.dll is the name of the dll file

SetConsoleTitle is the function

'P' means that it takes a string

'' means it returns nothing?

'RGSS3 Console' is the string that  you pass to the function right?
Yep, that's right. You can also set a variable equal to a Win32API object and use it multiple times. That way you don't have to make a new one each time.

Code:
my_api = Win32API.new(my stuff here)my_api.call(other stuff here)
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... 🙂
If your work has .NET 4 installed, you can use gemini to edit the scripts. Lite doesn't have a different format to the scripts, it just won't let you edit them through it. but this is an external script editor, so it should work fine for you to test. Links are down the page a little.

http://www.gdunlimited.net/forums/topic/7724-gemini-script-editor/
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!

Original thread: https://forums.rpgmakerweb.com/threads/how-to-use-win32api.16212/