Andreas Rosenberg wrote:
>
> ------------------------------------------------------------------------
Almost there, just few small things left.
> + TRACE("%p %s %p\n", hToken, lpProfileDir, lpcchSize);
Don't print output parameters[lpProfileDir] as string only as a point.
Unless it's used as in/out.
> + TRACE( "%p %s %p\n", hToken, debugstr_w(lpProfileDir), lpcchSize );
Same thing here.
> +static const WCHAR profile_pathname[] = {
> + 'S', 'o', 'f', 't', 'w', 'a', 'r', 'e', '\\',
> + 'M', 'i', 'c', 'r', 'o', 's', 'o', 'f', 't', '\\',
> + 'W', 'i', 'n', 'd', 'o', 'w', 's', ' ', 'N', 'T', '\\',
> + 'C', 'u', 'r', 'r', 'e', 'n', 't', 'V', 'e', 'r', 's', 'i', 'o', 'n', '\\',
> + 0 };
> +
> +static const WCHAR profile_subkey[] = {
> + 'P', 'r', 'o', 'f', 'i', 'l', 'e', 'L', 'i', 's', 't',
> + 0 };
> +
> +static const WCHAR profile_keyname[] = {
> + 'P', 'r', 'o', 'f', 'i', 'l', 'e', 's', 'D', 'i', 'r','e', 'c', 't', 'o', 'r', 'y',
> + 0 };
> + res = RegOpenKeyExW( HKEY_LOCAL_MACHINE, profile_pathname, 0L, KEY_QUERY_VALUE, &keyProfileDir );
> + res = RegGetValueW( keyProfileDir, profile_subkey, profile_keyname, RRF_RT_ANY,
> + NULL, buffer, &sizePath ); /* RegGetValue expects pcbData in bytes */
You opening the wrong key and querying the wrong value. You should be
opening "Software\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList" key
and getting the value of "ProfilesDirectory" entry.
Now about those fixed size buffers in GetUserProfileDirectoryW(). Why can't
you use the passed in buffer instead?
And the last thing - token. Look at _GetUserSidStringFromToken() from
shell32/shellpath.c how to get the user from the token.
Vitaliy