Dll String loading Topic is solved
Dll String loading
Is there a crossplatform way to load strings from a dll file? I looked at the classes for Dll files, but it didn't have a string load function.
if(work == fun)
{
pigsCanFly = true;
}
{
pigsCanFly = true;
}
-
- I live to help wx-kind
- Posts: 172
- Joined: Sun Sep 07, 2008 9:49 pm
- Location: Rio de Janeiro, Brazil
I think you can only get function addresses from DLLs, but if you're the one creating the DLL you can export a function that will return the address of the strings (untested):
and then in the main app you get the address of getString and, by calling it, the address of the strings.
Cheers,
Andre
Code: Select all
/* This goes into the DLL */
static const char *strings[] =
{
"one",
"two",
NULL
};
extern "C" __declspec(dllexport) __stdcall const char *
getStrings(void)
{
return strings;
}
Cheers,
Andre
-
- I live to help wx-kind
- Posts: 172
- Joined: Sun Sep 07, 2008 9:49 pm
- Location: Rio de Janeiro, Brazil
I see.
Well, if the strings are resources in the DLL, you can access them via resource loading functions at least on Windows. Dunno how to do it in other platforms.
If they're just arrays of characters inside the DLL file maybe you won't have any means to access them except by looking into the DLL and extracting them by hand.
Cheers,
Andre
Well, if the strings are resources in the DLL, you can access them via resource loading functions at least on Windows. Dunno how to do it in other platforms.
If they're just arrays of characters inside the DLL file maybe you won't have any means to access them except by looking into the DLL and extracting them by hand.
Cheers,
Andre
A cross-platform solution is the .po file. It can be used to translate aplications but I use it as a string table.
I have an aplication for windows that I am porting so what I did was a short aplication that read the resource aplication and created the po file. So when on linux instead of reading the resource i read po file.
If you are instested in this solution I can post the code for the aplication for the conversion here.
See ya
I have an aplication for windows that I am porting so what I did was a short aplication that read the resource aplication and created the po file. So when on linux instead of reading the resource i read po file.
If you are instested in this solution I can post the code for the aplication for the conversion here.
See ya
Someone had asked me to make a cross platform version, not really sure why, but it made for a good learning experience I had to rewrite the code from scratch anyway, because it was my first program and the code had become unmanagable, with many bugs. I have a much better understanding of writing programs now, so much less bugs this time I hope. Especially since the first one was direct winapi calls *shudder*
if(work == fun)
{
pigsCanFly = true;
}
{
pigsCanFly = true;
}
Well the two places it is used, the objects have internal names as well, so if compiled under windows it will try and get the dll string, but if compiled under something else, it will not even know that the game has dll files (since that is the only reason I load them at all). It seems to work rather well, and only requires three or four "#ifdef __WINDOWS__" plus the ones for the header includes.
if(work == fun)
{
pigsCanFly = true;
}
{
pigsCanFly = true;
}