As this is running as a service, I am able to get the disk letter from the Registry, and store it
into a static variable. I am not sure how to do the prepend_disk bit.
I have tried,
char [] prepend_disk (char* path)
{
char myPath [1024];
memset (myPath, '\0', sizeof (myPath));
//
// If this is the first time I am called, get the disk drive from the Registry
//
//Once we get going in a multi threaded environment
// EnterCriticalSection ( &m_csCrit ) ;
if (myDisk [0] == '\0')
{
read_in_drive ();
}
//Once we get going in a multi threaded environment
// LeaveCriticalSection ( &m_csCrit ) ;
The #defined stuff can only be modified before compile time...
but the information you need (if I understand you correctly) is only available after compile time.
IMHO you should have a configuration file with all those paths in it that your program loads at startup. All #defined names like DiagnosticsLogFile would become actual global values -- which is fine as they are currently static global data anyway and they have the #define clobber effect.
char DiagnosticsLogFile[ MAX_PATH ];
1 2 3 4
the initialization code()
{
...
read initialization file's value for DiagnosticsLogFile, etc
If you aren't allowed to do that, though, just fix the #defines to concatenate with a global:
I am trying to go with the second option. The first won't work, as I also need to prefix the paths for my initialisation files. As the programs are running as services they (internally) think they are running in %WINDIR%\system32.
I do need the
PATH_PREFIX [ MAX_PATH ]
variable to be accessible to all classes within the program, but I am having "fun" with the initial initialisation of the variable to a known value.
Now that I understand it. I know why it has to be MAX_PATH long.
Having moved all the defines into one place, and worked out how to make the g_myDisk variable work, the software is now working on my E: drive.