Keeping track of data from DLL calls

I have a function that returns a number

int val = 0;TEST_DLLint hello(void){ val += 1; return val;}What it is used for is not important.I want to store this data somewhere. How can I achieve this? Do I have to pass it to RM and let RM store it?
No. val will be kept alive for the duration of your process' life (aka until close or crash of Game.exe). You can keep it alive in the dll, or you can keep it in ruby. Your choice; it's all a matter of design. If you'd like to be able to reference it within your ruby code, you might need to throw it into ruby. If you know how, you can access RGSSEval from your project's dll, and eval the value into a variable within your code, something like this:

std:😮stringstream buffer;buffer << "$some_var = ";buffer << someCppVariable;if buffer.Good()    RGSSEval((char *)Buffer.str().c_str()); Actually, just go ahead and check this out: RPG Maker C/++ SDK
I was doing this as my test code

func = Win32API.new("tester", "hello", "", "L")func.callAnd just calling that repeatedly as a script call in an event.However, it just kept printing 1 again and again.

Why is that happening?
You keep creating new bindings. You should only call Win32API.new("tester", "hello", "", "L") once.

After that you can make subsequencial calls.

Any memory you allocate in the dll code should by standard be stored in the same process address space as the rgss player. Should you use lots of memory I suggest looking into how paging works.

*hugs*

 - Zeriab
Thanks, I didn't think it would make a difference when I created the binding lol.

Original thread: https://forums.rpgmakerweb.com/threads/keeping-track-of-data-from-dll-calls.20268/