I'm trying to use the StringCchCat function:
It says the required header is "Strsafe.h"

However, I keep getting these errors:
error: strsafe.h: No such file or directory
error: 'StringCchCat' was not declared in this scope

Could someone please lend some insight as to what the problem is and/or an alternative to StringCchCat? (since strsafe.h apparently doesn't exist)

(If this matters) I am using Windows Vista, and the computer the program is intended for is Windows XP SP3.
alternative to StringCchCat?

Why are you not using std::string?
First: I'm trying to use SHGetFolderPath (I know, it says not to use it on msdn, but I was also told to use it anyways because the program is intended for a computer using windows XP) with CSIDL_PROGRAM_FILES to get the path to the program files folder.

Second: I was trying to use StringCchCat to concatenate a string containing the name of a directory to the path returned by SHGetFolderPath.

Third: I was trying to use MoveFile to move the directory to the path returned by StringCchCat.

When I tried to use std::string, it gives this error:
error: cannot convert 'std::string' to 'CHAR*' for argument '5' to 'HRESULT SHGetFolderPathA(HWND__*, int, void*, DWORD, CHAR*)'
Last edited on
Try using the c_str() method. The function wants a char*, so give it one.
With regard to the strsafe.h - it comes with the Windows SDK and is really a Microsoft Visual Studio thing.

If you are using something like CodeBlocks with MinGW G++ compiler, then you probably won't have the windows SDK anyway.

The strsafe.h header file is self contained - the functions are inline functions.
But this header file contains a load of MS Compiler related macros and pragmas which would choke the G++ compiler (the pragmas will be unknown and be skipped by the G++ compiler).

So are you using visual studio?? if so then download the windows SDK.

if you are using MinGW/GCC you could well be stuffed and have to use the standard strcat function.
Yes, thank you.

I am using Code::Blocks. Thank you.
Topic archived. No new replies allowed.