未分类--Windows API--CreateEnvironmentBlock

来源:互联网 发布:淘宝手机店招图片 编辑:程序博客网 时间:2024/05/02 00:36

原文来自MSDN Library for Visual Studio 2008 SP1,翻译部分仅为个人观点,想要看更多信息请看MSDN,如有版权问题请联系QQ 643166601,邮件643166601@qq.com

 

CreateEnvironmentBlock Function

--------------------------------------------------------------------------------

Retrieves the environment variables for the specified user.
取回指定用户的环境变量。
This block can then be passed to the CreateProcessAsUser function.
这个块可以传递到CreateProcessAsUser函数。
Syntax

BOOL WINAPI CreateEnvironmentBlock(         
LPVOID *lpEnvironment,
HANDLE hToken,
BOOL bInherit
);
Parameters

lpEnvironment
[out] When this function returns, receives a pointer to the new environment block.
当这个函数返回时,取回一个指向新的环境块。
The environment block is an array of null-terminated Unicode strings.
这个环境块是一个以null结尾的Unicode字符串数组。
The list ends with two nulls (\0\0).
这个列表结尾用两个nulls (\0\0)。
hToken
[in] Token for the user, returned from the LogonUser function.
用户的令牌环,从LogonUser函数返回。
If this is a primary token, the token must have TOKEN_QUERY and TOKEN_DUPLICATE access.
如果这个是一个主令牌环,这个令牌环必须有TOKEN_QUERY 和 TOKEN_DUPLICATE 访问权限。
If the token is an impersonation token, it must have TOKEN_QUERY access.
如果这个是一个模拟令牌环,它必须有TOKEN_QUERY访问权限。
For more information, see Access Rights for Access-Token Objects.
更多信息,请看Access Rights for Access-Token Objects。
If this parameter is NULL, the returned environment block contains system variables only.
如果这个参数是NULL,这个返回的环境块只包含系统变量。
bInherit
[in] Specifies whether to inherit from the current process's environment.
指定是否从当前进程的环境中继承。
If this value is TRUE, the process inherits the current process's environment.
如果这个值是TRUE,这个进程继承当前进程的环境。
If this value is FALSE, the process does not inherit the current process's environment.
Return Value
如果这个值是FALSE,这个进程不继承当前进程的环境。
TRUE if successful; otherwise, FALSE.
如果成功是TRUE,否则是FALSE。
To get extended error information, call GetLastError.
去获得额外的错误信息,调用GetLastError。
Remarks

To free the buffer when you have finished with the environment block, call the DestroyEnvironmentBlock function.
当你用完环境块时调用DestroyEnvironmentBlock函数去释放缓冲区。
If the environment block is passed to CreateProcessAsUser, you must also specify the CREATE_UNICODE_ENVIRONMENT flag.
如果这个环境块传递到CreateProcessAsUser中,你也必须指定CREATE_UNICODE_ENVIRONMENT flag。
After CreateProcessAsUser has returned, the new process has a copy of the environment block, and DestroyEnvironmentBlock can be safely called.
在CreateProcessAsUser返回后,这个新的进程有一个环境块的拷贝,并且可以安全的调用DestroyEnvironmentBlock。
User-specific environment variables such as %USERPROFILE% are set only when the user's profile is loaded.
只用当用户的配置文件加载时,用户指定的环境变量像 %USERPROFILE% 才被设置。
To load a user's profile, call the LoadUserProfile function.
调用LoadUserProfile函数去加载用户的配置文件
Function Information

Minimum DLL Version Userenv.dll
Custom Implementation No
Header Userenv.h
Import library Userenv.lib
Minimum operating systems Windows NT 4.0

See Also

User Profiles Overview, User Profiles Reference, CreateProcessAsUser, DestroyEnvironmentBlock, LogonUser

--------------------------------------------------------------------------------

 

 

0 0
原创粉丝点击