Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

RMXP/RGSS & dlls

I'd like to know, is it possible to use dll through rgss?
I mean, use them to make new things that we can't normally with rgss.
 
Well, I'm not satisfied with that answer... :P

I'd like to have someone doing an example of some easy stuff that's neither hard to understand nor hard to do, so people like Dargor or myself are able to take a look at it. Learning by doing is the next step. :D
 
@proc = Win32API.new('kernel32', 'GetCurrentProcess', [], 'i').call
@pri = Win32API.new('kernel32', 'SetPriorityClass', ['p', 'i'], 'i')
@pri.call(@proc, 0x00000080)​

that'll set the rmxp process to high priority, using the kernel32 dll
 
Explaining it better... Lack of information is a big problem... Even more for someone who´s in doubt on (or wants to learn) something...

("dllname","functionFromDll","[parameters]","returntype")

"dllname" is a string and holds the name of the DLL you want to use. Note that the DLL must be inside your Game folder or Windows/System folder, or else you must declare a complete path to access it.

"functionfromdll" is a string and holds the name of the function from that DLL that you´ll call when you execute the Win32API object. Note that each Win32API object can handle only one function from one DLL.

[parameters] is an array and holds all the parameters needed to call that function. Note that you must respect all the function´s parameters and elements´ values types. This array contains ONLY strings, and each string holds only ONE letter. There´s no limits for the array´s size, this limit is given by the function. Ther´re sets of letters to be used, and each one represents one type of object that must be passed when calling the function. Some letters taht i remember now...
'n' = Numeric
'i' = Integer
'l' = String
'p' = Pointer (memory address, i don´t know exactly how to use it though ^^)
The letters sets are case-insensitive, so that way l = L, i = I, and so on...
Just this... Check the Ruby documentation to see more letters
For example, ['i', 'l'] defines that "functionfromdll" has two arguments that must be passed, being the first an integer and the second a string.

"returntype" is a string and defines the type of the return value by the function call. It uses exactly the same letters used in [parameters]. An empty string can suggest that the return value can be anything (or nothing).
For example, 'i' denotes the fact that the "functionfromdll" will return an integer when called.

Now, take the example given by Prexus...
Prexus":2y4n5psr said:
@proc = Win32API.new('kernel32', 'GetCurrentProcess', [], 'i').call
@pri = Win32API.new('kernel32', 'SetPriorityClass', ['p', 'i'], 'i')
@pri.call(@proc, 0x00000080)

The first line is a call to the function GetCurrentProcess from the kernel32.dll (that is inside the Windows/System folder). It has no arguments and returns an integer. The second line is the creation of a new Win32API object, that when called will execute the function SetPriorityClass from the kernel32.dll, requiring two arguments (a pointer and an integer), and will return an integer. In the third line the Win32API object is called (the function contained in @pri is executed). It passes the pointer (that will be the @proc´s returning value) and an integer (in an hexadecimal format).

If i´m wrong in anything please someone correct me. I´m somehow new to the Win32API, and i was in such a hurry, without any reference (all of that i took from my mind, and since it´s a little bit messy... xD)
 
So much thing about it, i don´t guilt you ^^ There´s so much things on Ruby that beginners would like to know, and some of them requires a little more patience and will to find out ^^
i´m trying hard on Win32API and GDI+ right now to try some saving features, and i´ve learned a few things... And hell... RMXP is a holy gift came from heaven! xD I have to say that the Window´s API is not the easiest thing to learn in the world, it´s so complicated. RMXP really makes our RPG dreams come true in the easiest way possible, and i wonder where most of us could be without it... ^^
 
Mr.Mo asked me something about dlls and I think it's the right post to answer his question :
How exactly did you make that DLL?

As in, what language did you use and is there a special format it should be in?

I never made DLLs so, yeah. Can you point me to a tutorial or something?

DLL are made using C languages. I made mine(s) using C# and Bloodshed Dev C++ to compile it.

here's a short code on how to make one :

Code:
// this is dll.h
#ifdef __cplusplus
#define EXPORT extern "C" __declspec (dllexport)
#else
#define EXPORT __declspec (dllexport)
#endif

EXPORT int CALLBACK YourMethodName(YourMethodArguments);

Code:
// this is dllmain.ccp
#include <windows.h>
#include "dll.h"

EXPORT int CALLBACK YourMethodName(YourMethodArguments)
{
   Your_Method_Here   
}

I think there are many tutorials on how to make create them on internet. But unfortunately I don't know anyone...
 
That's nice! A good thing to know.

is there any dll functions listing somewhere? It would be useful to know which dll is doing what. Some functions might interest people like me who want to expand their possibilities with rgss:P
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top