PDA

View Full Version : Converting fortmat of paths



jorgemejia
03-14-2005, 04:59 AM
I'm trying copying a file into a folder. I am retreiving the path from the registers; but the format of it is C:\Program File\Dynamics\xx.xxx and the format of the CopyFile is C:\\Program File\\Dynamics\\xx.xx. Is there a way to convert the format of C:\Program File\Dynamics\xx.xxx to C:\\Program File\\Dynamics\\xx.xx.

Thanks a lot

Wincor
03-14-2005, 06:16 AM
Unsure what you mean, but..

you need to quote the backslash within strings, so you need to type "C:\\Program Files" in your string var. However, when reading a string from disk by IS function, the result will be "C:\Program Files". Both will internally lead to the same result.

HTH
Wincor

jorgemejia
03-14-2005, 06:44 AM
Thanks for the answer; sorry I didn't explain myself clearly.

The format of the path I'm retrieving from the registry is C:\Program File\Dynamics\xx.xxx and I want to use this path in the CopyFile function; but the argument of this function has to be in following format: C:\\Program File\\Dynamics\\xx.xx.

I would like to know if I could convert the format of the path from C:\Program File\Dynamics\xx.xxx to C:\\Program File\\Dynamics\\xx.xx.

Thanks a lot

Wincor
03-14-2005, 08:18 AM
Just use what you read from the registry. It will be in the correct format for further usage.

If you define a string somthing like:

szPath = "C:\\Program Files\\...."

you have to quote the backslash, otherwise InstallShield will interpret the backslash as a quote to the next character (e.g. \P), which will result in something strange. But, if you retrieve a string from registry (or any other function which will return a string), it will be just right the way you retrieve it. So no further converting is required.

No conversion or special handling is required. You only need to quote a backslash when assiging a string as shown above. Strings as a result from a function can be used without further modification.

Ciao
Wincor

jorgemejia
03-15-2005, 05:20 AM
Thanks for your answer, it was very helpful, I didn't realized that the backslash was interpreted as a quote. I just used the string value return by the RegDBGetKeyValueEx function and it works!