mirror of
https://github.com/reactos/reactos.git
synced 2025-04-04 20:50:41 +00:00
Implement CreateEnvironmentBlock() and DestroyEnvironmentBlock().
svn path=/trunk/; revision=8790
This commit is contained in:
parent
d3d3ab535d
commit
d037d068ff
4 changed files with 111 additions and 3 deletions
103
reactos/lib/userenv/environment.c
Normal file
103
reactos/lib/userenv/environment.c
Normal file
|
@ -0,0 +1,103 @@
|
|||
/* $Id: environment.c,v 1.1 2004/03/19 12:40:49 ekohl Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/userenv/environment.c
|
||||
* PURPOSE: User environment functions
|
||||
* PROGRAMMER: Eric Kohl
|
||||
*/
|
||||
|
||||
#define NTOS_MODE_USER
|
||||
#include <ntos.h>
|
||||
#include <windows.h>
|
||||
#include <userenv.h>
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
|
||||
static BOOL
|
||||
SetUserEnvironmentVariable (LPVOID *Environment,
|
||||
LPWSTR lpName,
|
||||
LPWSTR lpValue)
|
||||
{
|
||||
UNICODE_STRING Name;
|
||||
UNICODE_STRING Value;
|
||||
NTSTATUS Status;
|
||||
|
||||
RtlInitUnicodeString (&Name, lpName);
|
||||
RtlInitUnicodeString (&Value, lpValue);
|
||||
|
||||
Status = RtlSetEnvironmentVariable ((PWSTR*)Environment,
|
||||
&Name,
|
||||
&Value);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1 ("RtlSetEnvironmentVariable() failed (Status %lx)\n", Status);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
BOOL WINAPI
|
||||
CreateEnvironmentBlock (LPVOID *lpEnvironment,
|
||||
HANDLE hToken,
|
||||
BOOL bInherit)
|
||||
{
|
||||
WCHAR Buffer[MAX_PATH];
|
||||
DWORD Length;
|
||||
NTSTATUS Status;
|
||||
|
||||
DPRINT1 ("CreateEnvironmentBlock() called\n");
|
||||
|
||||
if (lpEnvironment == NULL)
|
||||
return FALSE;
|
||||
|
||||
Status = RtlCreateEnvironment ((BOOLEAN)bInherit,
|
||||
(PWSTR*)lpEnvironment);
|
||||
if (!NT_SUCCESS (Status))
|
||||
{
|
||||
DPRINT1 ("RtlCreateEnvironment() failed (Status %lx)\n", Status);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Set 'COMPUTERNAME' variable */
|
||||
Length = MAX_PATH;
|
||||
if (GetComputerNameW (Buffer,
|
||||
&Length))
|
||||
{
|
||||
SetUserEnvironmentVariable (lpEnvironment,
|
||||
L"COMPUTERNAME",
|
||||
Buffer);
|
||||
}
|
||||
|
||||
/* Set 'USERPROFILE' variable */
|
||||
Length = MAX_PATH;
|
||||
if (GetUserProfileDirectoryW (hToken,
|
||||
Buffer,
|
||||
&Length))
|
||||
{
|
||||
SetUserEnvironmentVariable (lpEnvironment,
|
||||
L"USERPROFILE",
|
||||
Buffer);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
BOOL WINAPI
|
||||
DestroyEnvironmentBlock (LPVOID lpEnvironment)
|
||||
{
|
||||
DPRINT ("DestroyEnvironmentBlock() called\n");
|
||||
|
||||
if (lpEnvironment == NULL)
|
||||
return FALSE;
|
||||
|
||||
RtlDestroyEnvironment (lpEnvironment);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* EOF */
|
|
@ -15,7 +15,8 @@ TARGET_LFLAGS = -nostdlib -nostartfiles
|
|||
|
||||
TARGET_SDKLIBS = ntdll.a kernel32.a advapi32.a
|
||||
|
||||
TARGET_OBJECTS = directory.o profile.o misc.o registry.o setup.o userenv.o
|
||||
TARGET_OBJECTS = directory.o environment.o profile.o misc.o registry.o \
|
||||
setup.o userenv.o
|
||||
|
||||
DEP_OBJECTS = $(TARGET_OBJECTS)
|
||||
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
LIBRARY userenv.dll
|
||||
EXPORTS
|
||||
InitializeProfiles@0 @100 NONAME
|
||||
CreateUserProfileW@8 @110 NONAME
|
||||
CreateEnvironmentBlock@12
|
||||
DestroyEnvironmentBlock@4
|
||||
GetAllUsersProfileDirectoryW@8
|
||||
GetDefaultUserProfileDirectoryW@8
|
||||
GetProfilesDirectoryW@8
|
||||
GetUserProfileDirectoryW@12
|
||||
CreateUserProfileW@8
|
||||
LoadUserProfileW@8
|
||||
UnloadUserProfile@8
|
||||
;EOF
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
LIBRARY userenv.dll
|
||||
EXPORTS
|
||||
InitializeProfiles=InitializeProfiles@0 @100 NONAME
|
||||
CreateUserProfileW=CreateUserProfileW@8 @110 NONAME
|
||||
CreateEnvironmentBlock=CreateEnvironmentBlock@12
|
||||
DestroyEnvironmentBlock=DestroyEnvironmentBlock@4
|
||||
GetAllUsersProfileDirectoryW=GetAllUsersProfileDirectoryW@8
|
||||
GetDefaultUserProfileDirectoryW=GetDefaultUserProfileDirectoryW@8
|
||||
GetProfilesDirectoryW=GetProfilesDirectoryW@8
|
||||
GetUserProfileDirectoryW=GetUserProfileDirectoryW@12
|
||||
CreateUserProfileW=CreateUserProfileW@8
|
||||
LoadUserProfileW=LoadUserProfileW@8
|
||||
UnloadUserProfile=UnloadUserProfile@8
|
||||
;EOF
|
||||
|
|
Loading…
Reference in a new issue