can i use %windir% to get windows directory???
-
Hi, I want to replace the hardcoded string by the path in %windir% in the following code #ifdef WIN32 CHAR CFM_INI_FILE[CFM_NAME_LEN] = "C:\\Winnt\\abc.ini"; #else CHAR CFM_INI_FILE[CFM_NAME_LEN] = "/Winnt/abc.ini"; #endif can I do that? I cannot use GetWindowsDirectory function because this code is in global space in a cpp file. My understanding is a function can be called only from within a function and not from global space. Please advice.. P.S. :- this code has to be in global space. If i put it in function and initialize there i have to make changes in over 60 files to make sure it is initialized before it is used.
-
Hi, I want to replace the hardcoded string by the path in %windir% in the following code #ifdef WIN32 CHAR CFM_INI_FILE[CFM_NAME_LEN] = "C:\\Winnt\\abc.ini"; #else CHAR CFM_INI_FILE[CFM_NAME_LEN] = "/Winnt/abc.ini"; #endif can I do that? I cannot use GetWindowsDirectory function because this code is in global space in a cpp file. My understanding is a function can be called only from within a function and not from global space. Please advice.. P.S. :- this code has to be in global space. If i put it in function and initialize there i have to make changes in over 60 files to make sure it is initialized before it is used.
It is possible to get the value of %windir% with several functions, amongst them
char *getenv( const char *varname );
but from what I understand in your msg, you do not want to use any initialisation, e.g. function call. So I am afraid that the answer to venadder wrote: can I do that? is : yes, you can, but it will unfortunately not be replaced at runtime with "C:\Winnt". :~ So, be ready to modify your 60 files X| ~RaGE();