How to concatenate two LPCWSTR's in c++

c++, concatenation, winapi, windows

Solution

It sounds like you're trying to combine two `LPCWSTR` which represent paths elements into a combined paths. If that's the case then you want to use the PathCombine method

LPCWSTR root = ...;
LPCWSTR name = ...;
WCHAR combined[MAX_PATH];
if (PathCombineW(combined, root, name) != NULL) {
  // Succeeded
}

Problem

I'm trying to use the MoveFile(LPCWSTR existing, LPCWSTR new) function. I'd like to be able the one of the directories (represented by LPCWSTR) by concatenating different data (for example: root directories and potential file names). Despite hours of research, I can't figure out how to do this. Appreciate any help.

Original source