I have the following code:
// Fetch Local App Data folder path. PWSTR localAppData = (PWSTR) malloc(128); SHGetKnownFolderPath(FOLDERID_LocalAppData, 0, NULL
If you don't like widechar and want ansi string badly, try wcstombs or WideCharToMultiByte.
To call SHGetKnownFolderPath, you don't need to allocate memory by yourself, it will cause memory leak.