Copying strings in C
by Neil Marshall · in Torque Game Engine · 03/01/2006 (7:03 am) · 1 replies
I've got what is probably a really simple error which I can't figure out.
I'm working on a plugin version of Torque and am in the process of rewriting the entry code into the engine. So before the main function is called I need to grab some information from the windows registry.
Then I need to compile this into the "command line" so I'm doing this:
Now when I call S32 ret = Game->main(2,commandLine); all I recieve on the other end is the first chatacter of the path. So I get "c" instead of "c:\projects\tge\example\main.cs". I can see that it's only grabbing the first byte, but I don't know how to grab the entire string instead.
I know the code on the other end is working because if I pass:
I'm working on a plugin version of Torque and am in the process of rewriting the entry code into the engine. So before the main function is called I need to grab some information from the windows registry.
static char mainCSPathA[512];
DWORD size = sizeof( mainCSPathA );
if ( RegQueryValueEx( regKey, L"main.cs", NULL, NULL, (unsigned char *) mainCSPathA, &size ) != ERROR_SUCCESS )
{
// ...
}Then I need to compile this into the "command line" so I'm doing this:
LPCSTR commandLine[2]; commandLine[1] = mainCSPathA;
Now when I call S32 ret = Game->main(2,commandLine); all I recieve on the other end is the first chatacter of the path. So I get "c" instead of "c:\projects\tge\example\main.cs". I can see that it's only grabbing the first byte, but I don't know how to grab the entire string instead.
I know the code on the other end is working because if I pass:
LPCSTR commandLine[2]; commandLine[1] = "c:\projects\tge\example\main.cs";instead, then it works.
Torque Owner Neil Marshall
The simple fix was calling RegQueryValueExA directly.