ok, i do this code in C in visual studio:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ClassLibrary1
{
public class Sum
{
public double SumNumber(double num1, double num2)
{
return num1 + num2;
}
}
}
now, in rpg maker, i try use the dll as well
Win32API.new('ClassLibrary1','SumNumber','ll','l')
but i get error: GetProcAddress: SumNumber or SumNumberA
so i think my code is missing something.
Question:
Someone know that code I need to put in the DLL to avoid that error?
Question 2
Someone could put the code in the dll to build a "Hello World!" and in the RPG maker call this as well
helloworld= Win32API.new('HelloWorld','talkme','','P')
p helloworld.call => Hello World!
thanks all and sorry for my english :D
PS) These examples serve me long to start building some dll that I have thought
You can only load dlls that have been compiled with a C compiler. C++ and C# code won't work.
Also, native code dlls (C, C++, old Visual Basic versions) are different than .NET bytecode dlls (VB, C#, etc.).
ok very thanks, i download a compiler Dev-C and i have the DLL working now 8)
now I can investigate further to get the code that I want in the dlls
grateful Blizzard :naughty:
EDIT:
I have a problem here now:
My DLL:
Dll.h#ifndef _DLL_H_
#define _DLL_H_
#if BUILDING_DLL
# define DLLIMPORT __declspec (dllexport)
#else /* Not BUILDING_DLL */
# define DLLIMPORT __declspec (dllimport)
#endif /* Not BUILDING_DLL */
DLLIMPORT double sumNums (double,double);
#endif /* _DLL_H_ */
Main.c/* Replace "dll.h" with the name of your header */
#include "dll.h"
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
DLLIMPORT double sumNums (double n1, double n2)
{
return (n1 + n2);
}
BOOL APIENTRY DllMain (HINSTANCE hInst /* Library instance handle. */ ,
DWORD reason /* Reason this function is being called. */ ,
LPVOID reserved /* Not used. */ )
{
switch (reason)
{
case DLL_PROCESS_ATTACH:
break;
case DLL_PROCESS_DETACH:
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
}
/* Returns TRUE on success, FALSE on failure */
return TRUE;
}
compile without error >> Proyect.dll
now in rpg maker
s = Win32API.new('Proyect','sumNums','ll','l')
p "5 + 8 = " + s.call(5,8).to_s
Error: it print >> 5 + 8 = 8 << ???????
where is error in dll?
EDIT
if i change DLLIMPORT double sumNums (double n1, double n2) by DLLIMPORT int sumNums (int n1, intn2) it works, but if i use double or float don't wotks and i dont know why :wacko:
Using LL for the input means it's the datatype "long". You have to use "double" as argument types and return type.