msdn上对于CreateEnvironmentBlock的解释:CreateEnvironmentBlock functionRetrieves the environment variables for the specified user. This block can then be passed to theCreateProcessAsUser function.SyntaxCCopyBOOL WINAPI CreateEnvironmentBlock(_Out_LPVOID *lpEnvironment,_In_opt_HANDLE hToken,_In_BOOL bInherit);ParameterslpEnvironment [out]Type: LPVOID*When this function returns, receives a pointer to the new environment block. The environment block is an array of null-terminated Unicode strings. The list ends with two nulls (\0\0).hToken [in, optional]Type: HANDLEToken for the user, returned from theLogonUser function. If this is a primary token, the token must haveTOKEN_QUERY andTOKEN_DUPLICATE access. If the token is an impersonation token, it must haveTOKEN_QUERY access. For moreinformation, seeAccess Rights for Access-Token Objects.If this parameter is NULL, the returned environment block contains system variables only.bInherit [in]Type: BOOLSpecifies whether to inherit from the current process' environment. If this value isTRUE, the process inherits the current process' environment. If this value isFALSE, the process does not inherit the current process' environment.Return valueType: BOOLTRUE if successful; otherwise, FALSE. To get extended error information, callGetLastError.RemarksTo free the buffer when you have finished with the environment block, call theDestroyEnvironmentBlock function.If the environment block is passed toCreateProcessAsUser, you must also specify the CREATE_UNICODE_ENVIRONMENT flag. AfterCreateProcessAsUser has returned, the new process has a copy of the environment block, andDestroyEnvironmentBlockcan be safely called.User-specific environment variables such as %USERPROFILE% are set only when the user's profile is loaded. To load a user's profile, call theLoadUserProfilefunction.RequirementsMinimum supported clientWindows2000 Professional [desktop apps only]Minimum supported serverWindows2000 Server [desktop apps only]HeaderUserenv.hLibraryUserenv.libDLLUserenv.dll
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-52922-2.html
中国品牌严重低估