1

I'm trying to get a path (appdata) and append a filename (smss.dll), and combine these two to form C:\users\username\appdata\roaming\smss.dll I have this already:

static char appdata[MAX_PATH+1];
SHGetSpecialFolderPathA(HWND_DESKTOP, appdata, CSIDL_APPDATA, FALSE);

LPCSTR target = "smss.dll";

How can I combine these to into one variable?

2 Answers2

4

You can use PathAppend (limited to MAX_PATH characters), or PathCchAppendEx starting with Windows 8.

IInspectable
  • 46,945
  • 8
  • 85
  • 181
-3
static char appdata[MAX_PATH+1];
SHGetSpecialFolderPathA(HWND_DESKTOP, appdata, CSIDL_APPDATA, FALSE);

strcat(appdata, "\\smss.dll");

The strcat function appends the right-hand string to the left-hand buffer. It assumes the destination has room for the concatenation to be done. If there is not enough space, it is undefined behavior. Thus it is a good idea to check that there is enough space.

lost_in_the_source
  • 10,998
  • 9
  • 46
  • 75