-
dll help...
I am making dlls for Game Maker. There is a certain way to make them. Here is the code to make a function...
Code:
extern "C" __declspec(dllexport) __stdcall double rh_deletefile(LPCTSTR arg1);
extern "C" __declspec(dllexport) __stdcall double rh_deletefile(LPCTSTR arg1)
{
//functions stuff here
return 0; //it has to return somthing or it won't work
};
The rest of the code doesnt' matter, that all works. Now notice the LPCTSTR arg1. I belive most people know what that is. But if you don't that is how I transfer stuff between game maker and the dll basicly. (gives more flexability). So heres the probelem.
I want a function that gives the computers name (for example). Now I can not return it because it is a word nto a number. I need to know how I can return it or somthing so I can send it to Game Maker.
Here is the code so far...
Code:
extern "C" __declspec(dllexport) __stdcall double rh_getcomputername();
extern "C" __declspec(dllexport) __stdcall double rh_getcomputername()
{
LPTSTR computername;
DWORD* size;
GetComputerName(
computername,
size
);
return 0;
};
I only need computername, not the size.
I'm not sure at all how I would do this. Please help me.
Oh and sending it to a variable throw the code here and then trying to call the cariable throw Game Maker doesn't work, I just tired that.
-
Code:
#include <windows.h>
TCHAR computername[MAX_COMPUTERNAME_LENGTH + 1];
DWORD sz = sizeof(computername) / sizeof(*computername);
BOOL ret = GetComputerName(computername, &sz);
gg
-
alright that really doens't help much, it doesn't solve my probeblem.
-
but you did solve an error I had with Game Maker....
-
Code:
extern "C" __declspec(dllexport) __stdcall BOOL GetComputerName(LPTSTR lpBuff, UINT bufflen)
{
DWORD size = bufflen
return GetComputerName(lpBuff, &size);
}