📄 userenv.h
字号:
//=============================================================================
// userenv.h - Header file for user environment API.
// User Profiles, environment variables, and Group Policy
//
// Copyright (c) Microsoft Corporation 1995-1999
// All rights reserved
//
//=============================================================================
#ifndef _INC_USERENV
#pragma option push -b -a8 -pc -A- /*P_O_Push*/
#define _INC_USERENV
//
// Define API decoration for direct importing of DLL references.
//
#if !defined(_USERENV_)
#define USERENVAPI DECLSPEC_IMPORT
#else
#define USERENVAPI
#endif
#ifdef __cplusplus
extern "C" {
#endif
//=============================================================================
//
// LoadUserProfile
//
// Loads the specified user's profile.
//
// Most applications should not need to use this function. It's used
// when a user has logged onto the system or a service starts in a named
// user account.
//
// hToken - Token for the user, returned from LogonUser()
// lpProfileInfo - Address of a PROFILEINFO structure
//
// Returns: TRUE if successful
// FALSE if not. Call GetLastError() for more details
//
// Note: The caller of this function must have admin privileges on the machine.
//
// Upon successful return, the hProfile member of the PROFILEINFO
// structure is a registry key handle opened to the root
// of the user's hive. It has been opened with full access. If
// you need to read or write to the user's registry file, use
// this key instead of HKEY_CURRENT_USER. Do not close this
// handle. Instead pass it to UnloadUserProfile to close
// the handle.
//
//=============================================================================
//
// Flags that can be set in the dwFlags field
//
#define PI_NOUI 0x00000001 // Prevents displaying of messages
#define PI_APPLYPOLICY 0x00000002 // Apply NT4 style policy
typedef struct _PROFILEINFOA {
DWORD dwSize; // Set to sizeof(PROFILEINFO) before calling
DWORD dwFlags; // See flags above
LPSTR lpUserName; // User name (required)
LPSTR lpProfilePath; // Roaming profile path (optional, can be NULL)
LPSTR lpDefaultPath; // Default user profile path (optional, can be NULL)
LPSTR lpServerName; // Validating domain controller name in netbios format (optional, can be NULL but group NT4 style policy won't be applied)
LPSTR lpPolicyPath; // Path to the NT4 style policy file (optional, can be NULL)
HANDLE hProfile; // Filled in by the function. Registry key handle open to the root.
} PROFILEINFOA, FAR * LPPROFILEINFOA;
typedef struct _PROFILEINFOW {
DWORD dwSize; // Set to sizeof(PROFILEINFO) before calling
DWORD dwFlags; // See flags above
LPWSTR lpUserName; // User name (required)
LPWSTR lpProfilePath; // Roaming profile path (optional, can be NULL)
LPWSTR lpDefaultPath; // Default user profile path (optional, can be NULL)
LPWSTR lpServerName; // Validating domain controller name in netbios format (optional, can be NULL but group NT4 style policy won't be applied)
LPWSTR lpPolicyPath; // Path to the NT4 style policy file (optional, can be NULL)
HANDLE hProfile; // Filled in by the function. Registry key handle open to the root.
} PROFILEINFOW, FAR * LPPROFILEINFOW;
#ifdef UNICODE
typedef PROFILEINFOW PROFILEINFO;
typedef LPPROFILEINFOW LPPROFILEINFO;
#else
typedef PROFILEINFOA PROFILEINFO;
typedef LPPROFILEINFOA LPPROFILEINFO;
#endif // UNICODE
USERENVAPI
BOOL
WINAPI
LoadUserProfileA(
IN HANDLE hToken,
IN OUT LPPROFILEINFOA lpProfileInfo);
USERENVAPI
BOOL
WINAPI
LoadUserProfileW(
IN HANDLE hToken,
IN OUT LPPROFILEINFOW lpProfileInfo);
#ifdef UNICODE
#define LoadUserProfile LoadUserProfileW
#else
#define LoadUserProfile LoadUserProfileA
#endif // !UNICODE
//=============================================================================
//
// UnloadUserProfile
//
// Unloads a user's profile that was loaded by LoadUserProfile()
//
// hToken - Token for the user, returned from LogonUser()
// hProfile - hProfile member of the PROFILEINFO structure
//
// Returns: TRUE if successful
// FALSE if not. Call GetLastError() for more details
//
// Note: The caller of this function must have admin privileges on the machine.
//
//=============================================================================
USERENVAPI
BOOL
WINAPI
UnloadUserProfile(
IN HANDLE hToken,
IN HANDLE hProfile);
//=============================================================================
//
// GetProfilesDirectory
//
// Returns the path to the root of where all user profiles are stored.
//
// lpProfilesDir - Receives the path
// lpcchSize - Size of lpProfilesDir
//
// Returns: TRUE if successful
// FALSE if not. Call GetLastError() for more details
//
// Note: If lpProfilesDir is not large enough, the function will fail,
// and lpcchSize will contain the necessary buffer size.
//
// Example return value: C:\Documents and Settings
//
//=============================================================================
USERENVAPI
BOOL
WINAPI
GetProfilesDirectoryA(
OUT LPSTR lpProfilesDir,
IN OUT LPDWORD lpcchSize);
USERENVAPI
BOOL
WINAPI
GetProfilesDirectoryW(
OUT LPWSTR lpProfilesDir,
IN OUT LPDWORD lpcchSize);
#ifdef UNICODE
#define GetProfilesDirectory GetProfilesDirectoryW
#else
#define GetProfilesDirectory GetProfilesDirectoryA
#endif // !UNICODE
//=============================================================================
//
// GetProfileType()
//
// Returns the type of the profile that is loaded for a user.
//
// dwFlags - Returns the profile flags
//
// Return: TRUE if successful
// FALSE if an error occurs. Call GetLastError for more details
//
// Comments: if profile is not already loaded the function will return an error.
// The caller needs to have access to HKLM part of the registry.
// (exists by default)
//
//=============================================================================
#if(WINVER >= 0x0500)
//
// Flags that can be set in the dwFlags field
//
#define PT_TEMPORARY 0x00000001 // A profile has been allocated that will be deleted at logoff.
#define PT_ROAMING 0x00000002 // The loaded profile is a roaming profile.
#define PT_MANDATORY 0x00000004 // The loaded profile is mandatory.
USERENVAPI
BOOL
WINAPI
GetProfileType(
OUT DWORD *dwFlags);
#endif /* WINVER >= 0x0500 */
//=============================================================================
//
// DeleteProfile()
//
// Deletes the profile and all other user related settings from the machine
//
// lpSidString - String form of the user sid.
// lpProfilePath - ProfilePath (if Null, lookup in the registry)
// lpComputerName - Computer Name from which profile has to be deleted
//
// Return: TRUE if successful
// FALSE if an error occurs. Call GetLastError for more details
//
// Comments: Deletes the profile directory, registry and appmgmt stuff
//=============================================================================
#if(WINVER >= 0x0500)
USERENVAPI
BOOL
WINAPI
DeleteProfileA (
IN LPCSTR lpSidString,
IN LPCSTR lpProfilePath,
IN LPCSTR lpComputerName);
USERENVAPI
BOOL
WINAPI
DeleteProfileW (
IN LPCWSTR lpSidString,
IN LPCWSTR lpProfilePath,
IN LPCWSTR lpComputerName);
#ifdef UNICODE
#define DeleteProfile DeleteProfileW
#else
#define DeleteProfile DeleteProfileA
#endif // !UNICODE
#endif /* WINVER >= 0x0500 */
//=============================================================================
//
// GetDefaultUserProfilesDirectory
//
// Returns the path to the root of the default user profile
//
// lpProfileDir - Receives the path
// lpcchSize - Size of lpProfileDir
//
// Returns: TRUE if successful
// FALSE if not. Call GetLastError() for more details
//
// Note: If lpProfileDir is not large enough, the function will fail,
// and lpcchSize will contain the necessary buffer size.
//
// Example return value: C:\Documents and Settings\Default User
//
//=============================================================================
#if(WINVER >= 0x0500)
USERENVAPI
BOOL
WINAPI
GetDefaultUserProfileDirectoryA(
OUT LPSTR lpProfileDir,
IN OUT LPDWORD lpcchSize);
USERENVAPI
BOOL
WINAPI
GetDefaultUserProfileDirectoryW(
OUT LPWSTR lpProfileDir,
IN OUT LPDWORD lpcchSize);
#ifdef UNICODE
#define GetDefaultUserProfileDirectory GetDefaultUserProfileDirectoryW
#else
#define GetDefaultUserProfileDirectory GetDefaultUserProfileDirectoryA
#endif // !UNICODE
#endif /* WINVER >= 0x0500 */
//=============================================================================
//
// GetAllUsersProfilesDirectory
//
// Returns the path to the root of the All Users profile
//
// lpProfileDir - Receives the path
// lpcchSize - Size of lpProfileDir
//
// Returns: TRUE if successful
// FALSE if not. Call GetLastError() for more details
//
// Note: If lpProfileDir is not large enough, the function will fail,
// and lpcchSize will contain the necessary buffer size.
//
// Example return value: C:\Documents and Settings\All Users
//
//=============================================================================
#if(WINVER >= 0x0500)
USERENVAPI
BOOL
WINAPI
GetAllUsersProfileDirectoryA(
OUT LPSTR lpProfileDir,
IN OUT LPDWORD lpcchSize);
USERENVAPI
BOOL
WINAPI
GetAllUsersProfileDirectoryW(
OUT LPWSTR lpProfileDir,
IN OUT LPDWORD lpcchSize);
#ifdef UNICODE
#define GetAllUsersProfileDirectory GetAllUsersProfileDirectoryW
#else
#define GetAllUsersProfileDirectory GetAllUsersProfileDirectoryA
#endif // !UNICODE
#endif /* WINVER >= 0x0500 */
//=============================================================================
//
// GetUserProfileDirectory
//
// Returns the path to the root of the requested user's profile
//
// hToken - User's token returned from LogonUser()
// lpProfileDir - Receives the path
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -