What are the known folder paths returned by SHGetKnownFolderPath on Windows 11 using OneDrive's Known Folder Move Feature?

RLWA32 45,396 Reputation points
2024-10-01T09:00:52.61+00:00

OneDrive now includes a feature called Known Folder Move.

It is my understanding that for consumers (not managed devices) when OneDrive is used on a Windows 11 system it will implement this feature and several of the known folders will now default to OneDrive storage instead of the local file system. The local folders are viewed as "backup" for OneDrive.

I do not use OneDrive or Windows 11 so I cannot determine what code requesting known folder paths will return in that environment.

On my Win10 22H2 system using the 20348 SDK the knownfolders.h file includes GUIDs as shown here -

// {FDD39AD0-238F-46AF-ADB4-6C85480369C7}
DEFINE_KNOWN_FOLDER(FOLDERID_Documents,           0xFDD39AD0, 0x238F, 0x46AF, 0xAD, 0xB4, 0x6C, 0x85, 0x48, 0x03, 0x69, 0xC7);

// {f42ee2d3-909f-4907-8871-4c22fc0bf756}
DEFINE_KNOWN_FOLDER(FOLDERID_LocalDocuments,      0xf42ee2d3, 0x909f, 0x4907, 0x88, 0x71, 0x4c, 0x22, 0xfc, 0x0b, 0xf7, 0x56);

I am seeking the assistance of developers that have a Windows 11 system configured to use OneDrive Known Folder Move to run the following and share the results with us -

#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <ShlObj.h>

#include <stdio.h>

int main()
{
    auto hr = CoInitialize(nullptr);
    if(SUCCEEDED(hr))
    {
        PWSTR pszDocsDefault{}, pszDocsDefaultPath{},
            pszLocalDocsDefault{}, pszLocalDocsDefaultPath{};

        hr = SHGetKnownFolderPath(FOLDERID_Documents, KF_FLAG_DEFAULT, NULL, &pszDocsDefault);
        hr = SHGetKnownFolderPath(FOLDERID_Documents, KF_FLAG_DEFAULT_PATH, NULL, &pszDocsDefaultPath);
        wprintf_s(L"FOLDERID_Documents paths:\n\tKF_FLAG_DEFAULT: %s\n\tKF_FLAG_DEFAULT_PATH: %s\n\n",
            pszDocsDefault, pszDocsDefaultPath);

        hr = SHGetKnownFolderPath(FOLDERID_LocalDocuments, KF_FLAG_DEFAULT, NULL, &pszLocalDocsDefault);
        hr = SHGetKnownFolderPath(FOLDERID_LocalDocuments, KF_FLAG_DEFAULT_PATH, NULL, &pszLocalDocsDefaultPath);
        wprintf_s(L"FOLDERID_LocalDocuments paths:\n\tKF_FLAG_DEFAULT: %s\n\tKF_FLAG_DEFAULT_PATH: %s\n\n",
            pszLocalDocsDefault, pszLocalDocsDefaultPath);

        CoTaskMemFree(pszDocsDefault);
        CoTaskMemFree(pszDocsDefaultPath);
        CoTaskMemFree(pszLocalDocsDefault);
        CoTaskMemFree(pszLocalDocsDefaultPath);
    }

    CoUninitialize();

    return 0;
}

Thanks in advance to all who assist.

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,609 questions
Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
9,580 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.