2000-07-01 17:07:02 +00:00
|
|
|
/* $Id: env.c,v 1.11 2000/07/01 17:07:00 ea Exp $
|
2000-02-18 00:51:03 +00:00
|
|
|
*
|
1998-12-04 18:28:13 +00:00
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS system libraries
|
|
|
|
* FILE: lib/kernel32/misc/env.c
|
|
|
|
* PURPOSE: Environment functions
|
|
|
|
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
|
|
|
|
* UPDATE HISTORY:
|
|
|
|
* Created 01/11/98
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <ddk/ntddk.h>
|
2000-02-18 00:51:03 +00:00
|
|
|
#include <ntdll/rtl.h>
|
1999-10-07 23:46:27 +00:00
|
|
|
#include <windows.h>
|
1999-03-19 05:55:55 +00:00
|
|
|
#include <wchar.h>
|
1998-12-04 18:28:13 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2000-02-18 00:51:03 +00:00
|
|
|
#define NDEBUG
|
1999-04-14 00:52:19 +00:00
|
|
|
#include <kernel32/kernel32.h>
|
2000-07-01 17:07:02 +00:00
|
|
|
#include <kernel32/error.h>
|
1999-04-14 00:52:19 +00:00
|
|
|
|
1998-12-04 18:28:13 +00:00
|
|
|
|
2000-02-18 00:51:03 +00:00
|
|
|
/* FUNCTIONS ******************************************************************/
|
|
|
|
|
|
|
|
DWORD
|
|
|
|
STDCALL
|
|
|
|
GetEnvironmentVariableA (
|
|
|
|
LPCSTR lpName,
|
|
|
|
LPSTR lpBuffer,
|
|
|
|
DWORD nSize
|
|
|
|
)
|
1998-12-04 18:28:13 +00:00
|
|
|
{
|
2000-02-18 00:51:03 +00:00
|
|
|
ANSI_STRING VarName;
|
|
|
|
ANSI_STRING VarValue;
|
|
|
|
UNICODE_STRING VarNameU;
|
|
|
|
UNICODE_STRING VarValueU;
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
/* initialize unicode variable name string */
|
|
|
|
RtlInitAnsiString (&VarName,
|
|
|
|
(LPSTR)lpName);
|
|
|
|
RtlAnsiStringToUnicodeString (&VarNameU,
|
|
|
|
&VarName,
|
|
|
|
TRUE);
|
|
|
|
|
|
|
|
/* initialize ansi variable value string */
|
|
|
|
VarValue.Length = 0;
|
|
|
|
VarValue.MaximumLength = nSize;
|
|
|
|
VarValue.Buffer = lpBuffer;
|
|
|
|
|
|
|
|
/* initialize unicode variable value string and allocate buffer */
|
|
|
|
VarValueU.Length = 0;
|
|
|
|
VarValueU.MaximumLength = nSize * sizeof(WCHAR);
|
|
|
|
VarValueU.Buffer = RtlAllocateHeap (RtlGetProcessHeap (),
|
|
|
|
0,
|
|
|
|
VarValueU.MaximumLength);
|
|
|
|
|
|
|
|
/* get unicode environment variable */
|
|
|
|
Status = RtlQueryEnvironmentVariable_U (NULL,
|
|
|
|
&VarNameU,
|
|
|
|
&VarValueU);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* free unicode buffer */
|
|
|
|
RtlFreeHeap (RtlGetProcessHeap (),
|
|
|
|
0,
|
|
|
|
VarValueU.Buffer);
|
1998-12-04 18:28:13 +00:00
|
|
|
|
2000-02-18 00:51:03 +00:00
|
|
|
/* free unicode variable name string */
|
|
|
|
RtlFreeUnicodeString (&VarNameU);
|
1998-12-04 18:28:13 +00:00
|
|
|
|
2000-07-01 17:07:02 +00:00
|
|
|
SetLastErrorByStatus (Status);
|
2000-02-18 00:51:03 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* convert unicode value string to ansi */
|
|
|
|
RtlUnicodeStringToAnsiString (&VarValue,
|
|
|
|
&VarValueU,
|
|
|
|
FALSE);
|
|
|
|
|
|
|
|
/* free unicode buffer */
|
|
|
|
RtlFreeHeap (RtlGetProcessHeap (),
|
|
|
|
0,
|
|
|
|
VarValueU.Buffer);
|
|
|
|
|
|
|
|
/* free unicode variable name string */
|
|
|
|
RtlFreeUnicodeString (&VarNameU);
|
|
|
|
|
|
|
|
return (VarValueU.Length / sizeof(WCHAR));
|
1999-01-16 02:11:45 +00:00
|
|
|
}
|
1998-12-04 18:28:13 +00:00
|
|
|
|
2000-02-18 00:51:03 +00:00
|
|
|
|
1998-12-04 18:28:13 +00:00
|
|
|
DWORD
|
|
|
|
STDCALL
|
2000-02-18 00:51:03 +00:00
|
|
|
GetEnvironmentVariableW (
|
|
|
|
LPCWSTR lpName,
|
|
|
|
LPWSTR lpBuffer,
|
|
|
|
DWORD nSize
|
|
|
|
)
|
1998-12-04 18:28:13 +00:00
|
|
|
{
|
2000-02-18 00:51:03 +00:00
|
|
|
UNICODE_STRING VarName;
|
|
|
|
UNICODE_STRING VarValue;
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
RtlInitUnicodeString (&VarName,
|
|
|
|
lpName);
|
1998-12-04 18:28:13 +00:00
|
|
|
|
2000-02-18 00:51:03 +00:00
|
|
|
VarValue.Length = 0;
|
|
|
|
VarValue.MaximumLength = nSize * sizeof(WCHAR);
|
|
|
|
VarValue.Buffer = lpBuffer;
|
|
|
|
|
|
|
|
Status = RtlQueryEnvironmentVariable_U (NULL,
|
|
|
|
&VarName,
|
|
|
|
&VarValue);
|
|
|
|
if (!NT_SUCCESS(Status))
|
1998-12-04 18:28:13 +00:00
|
|
|
{
|
2000-07-01 17:07:02 +00:00
|
|
|
SetLastErrorByStatus (Status);
|
2000-02-18 00:51:03 +00:00
|
|
|
return 0;
|
1998-12-04 18:28:13 +00:00
|
|
|
}
|
|
|
|
|
2000-02-18 00:51:03 +00:00
|
|
|
return (VarValue.Length / sizeof(WCHAR));
|
|
|
|
}
|
1998-12-04 18:28:13 +00:00
|
|
|
|
1999-01-16 02:11:45 +00:00
|
|
|
|
|
|
|
WINBOOL
|
|
|
|
STDCALL
|
2000-02-18 00:51:03 +00:00
|
|
|
SetEnvironmentVariableA (
|
|
|
|
LPCSTR lpName,
|
|
|
|
LPCSTR lpValue
|
|
|
|
)
|
1998-12-04 18:28:13 +00:00
|
|
|
{
|
2000-02-18 00:51:03 +00:00
|
|
|
ANSI_STRING VarName;
|
|
|
|
ANSI_STRING VarValue;
|
|
|
|
UNICODE_STRING VarNameU;
|
|
|
|
UNICODE_STRING VarValueU;
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
RtlInitAnsiString (&VarName,
|
|
|
|
(LPSTR)lpName);
|
|
|
|
RtlAnsiStringToUnicodeString (&VarNameU,
|
|
|
|
&VarName,
|
|
|
|
TRUE);
|
|
|
|
|
|
|
|
RtlInitAnsiString (&VarValue,
|
|
|
|
(LPSTR)lpValue);
|
|
|
|
RtlAnsiStringToUnicodeString (&VarValueU,
|
|
|
|
&VarValue,
|
|
|
|
TRUE);
|
|
|
|
|
|
|
|
Status = RtlSetEnvironmentVariable (NULL,
|
|
|
|
&VarNameU,
|
|
|
|
&VarValueU);
|
|
|
|
|
|
|
|
RtlFreeUnicodeString (&VarNameU);
|
|
|
|
RtlFreeUnicodeString (&VarValueU);
|
|
|
|
|
|
|
|
if (!NT_SUCCESS(Status))
|
1999-10-07 23:46:27 +00:00
|
|
|
{
|
2000-07-01 17:07:02 +00:00
|
|
|
SetLastErrorByStatus (Status);
|
2000-02-18 00:51:03 +00:00
|
|
|
return FALSE;
|
1999-10-07 23:46:27 +00:00
|
|
|
}
|
1999-01-16 02:11:45 +00:00
|
|
|
|
2000-02-18 00:51:03 +00:00
|
|
|
return TRUE;
|
1999-01-16 02:11:45 +00:00
|
|
|
}
|
1998-12-04 18:28:13 +00:00
|
|
|
|
1999-10-07 23:46:27 +00:00
|
|
|
|
1998-12-04 18:28:13 +00:00
|
|
|
WINBOOL
|
|
|
|
STDCALL
|
2000-02-18 00:51:03 +00:00
|
|
|
SetEnvironmentVariableW (
|
|
|
|
LPCWSTR lpName,
|
|
|
|
LPCWSTR lpValue
|
|
|
|
)
|
1998-12-04 18:28:13 +00:00
|
|
|
{
|
2000-02-18 00:51:03 +00:00
|
|
|
UNICODE_STRING VarName;
|
|
|
|
UNICODE_STRING VarValue;
|
|
|
|
NTSTATUS Status;
|
1998-12-04 18:28:13 +00:00
|
|
|
|
2000-02-18 00:51:03 +00:00
|
|
|
RtlInitUnicodeString (&VarName,
|
|
|
|
lpName);
|
|
|
|
|
|
|
|
RtlInitUnicodeString (&VarValue,
|
|
|
|
lpValue);
|
1999-01-16 02:11:45 +00:00
|
|
|
|
2000-02-18 00:51:03 +00:00
|
|
|
Status = RtlSetEnvironmentVariable (NULL,
|
|
|
|
&VarName,
|
|
|
|
&VarValue);
|
|
|
|
if (!NT_SUCCESS(Status))
|
1999-01-16 02:11:45 +00:00
|
|
|
{
|
2000-07-01 17:07:02 +00:00
|
|
|
SetLastErrorByStatus (Status);
|
2000-02-18 00:51:03 +00:00
|
|
|
return FALSE;
|
1999-01-16 02:11:45 +00:00
|
|
|
}
|
1998-12-04 18:28:13 +00:00
|
|
|
|
1999-10-07 23:46:27 +00:00
|
|
|
return TRUE;
|
1998-12-04 18:28:13 +00:00
|
|
|
}
|
|
|
|
|
2000-02-18 00:51:03 +00:00
|
|
|
|
1999-10-07 23:46:27 +00:00
|
|
|
DWORD
|
1998-12-04 18:28:13 +00:00
|
|
|
STDCALL
|
|
|
|
GetVersion(VOID)
|
|
|
|
{
|
|
|
|
DWORD Version = 0;
|
|
|
|
OSVERSIONINFO VersionInformation;
|
|
|
|
GetVersionExW(&VersionInformation);
|
1999-10-07 23:46:27 +00:00
|
|
|
|
1998-12-04 18:28:13 +00:00
|
|
|
Version |= ( VersionInformation.dwMajorVersion << 8 );
|
|
|
|
Version |= VersionInformation.dwMinorVersion;
|
1999-10-07 23:46:27 +00:00
|
|
|
|
1998-12-04 18:28:13 +00:00
|
|
|
Version |= ( VersionInformation.dwPlatformId << 16 );
|
|
|
|
|
|
|
|
return Version;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-07 23:46:27 +00:00
|
|
|
WINBOOL
|
1998-12-04 18:28:13 +00:00
|
|
|
STDCALL
|
|
|
|
GetVersionExW(
|
2000-02-18 00:51:03 +00:00
|
|
|
LPOSVERSIONINFO lpVersionInformation
|
|
|
|
)
|
1998-12-04 18:28:13 +00:00
|
|
|
{
|
|
|
|
lpVersionInformation->dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
|
|
|
lpVersionInformation->dwMajorVersion = 4;
|
|
|
|
lpVersionInformation->dwMinorVersion = 0;
|
|
|
|
lpVersionInformation->dwBuildNumber = 12;
|
|
|
|
lpVersionInformation->dwPlatformId = VER_PLATFORM_WIN32_NT;
|
1999-01-16 02:11:45 +00:00
|
|
|
lstrcpyW((WCHAR *)lpVersionInformation->szCSDVersion,L"Ariadne was here...");
|
1998-12-04 18:28:13 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2000-02-18 00:51:03 +00:00
|
|
|
|
1999-10-07 23:46:27 +00:00
|
|
|
WINBOOL
|
1998-12-04 18:28:13 +00:00
|
|
|
STDCALL
|
|
|
|
GetVersionExA(
|
2000-02-18 00:51:03 +00:00
|
|
|
LPOSVERSIONINFO lpVersionInformation
|
|
|
|
)
|
1998-12-04 18:28:13 +00:00
|
|
|
{
|
|
|
|
lpVersionInformation->dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
|
|
|
lpVersionInformation->dwMajorVersion = 4;
|
|
|
|
lpVersionInformation->dwMinorVersion = 0;
|
|
|
|
lpVersionInformation->dwBuildNumber = 12;
|
|
|
|
lpVersionInformation->dwPlatformId = VER_PLATFORM_WIN32_NT;
|
1999-01-16 02:11:45 +00:00
|
|
|
lstrcpyA((char *)lpVersionInformation->szCSDVersion,"ReactOs Pre-Alpha");
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-07 23:46:27 +00:00
|
|
|
LPSTR
|
|
|
|
STDCALL
|
2000-02-18 00:51:03 +00:00
|
|
|
GetEnvironmentStringsA (
|
|
|
|
VOID
|
|
|
|
)
|
1999-01-16 02:11:45 +00:00
|
|
|
{
|
2000-02-18 00:51:03 +00:00
|
|
|
UNICODE_STRING UnicodeString;
|
|
|
|
ANSI_STRING AnsiString;
|
|
|
|
PWCHAR EnvU;
|
|
|
|
PWCHAR PtrU;
|
|
|
|
ULONG Length;
|
|
|
|
PCHAR EnvPtr = NULL;
|
1999-01-16 02:11:45 +00:00
|
|
|
|
2000-02-18 00:51:03 +00:00
|
|
|
EnvU = (PWCHAR)(NtCurrentPeb ()->ProcessParameters->Environment);
|
1999-01-16 02:11:45 +00:00
|
|
|
|
2000-02-18 00:51:03 +00:00
|
|
|
if (EnvU == NULL)
|
|
|
|
return NULL;
|
1999-01-16 02:11:45 +00:00
|
|
|
|
2000-02-18 00:51:03 +00:00
|
|
|
if (*EnvU == 0)
|
|
|
|
return NULL;
|
1999-01-16 02:11:45 +00:00
|
|
|
|
2000-02-18 00:51:03 +00:00
|
|
|
/* get environment size */
|
|
|
|
PtrU = EnvU;
|
|
|
|
while (*PtrU)
|
|
|
|
{
|
|
|
|
while (*PtrU)
|
|
|
|
PtrU++;
|
|
|
|
PtrU++;
|
|
|
|
}
|
|
|
|
Length = (ULONG)(PtrU - EnvU);
|
|
|
|
DPRINT("Length %lu\n", Length);
|
1998-12-04 18:28:13 +00:00
|
|
|
|
2000-02-18 00:51:03 +00:00
|
|
|
/* allocate environment buffer */
|
|
|
|
EnvPtr = RtlAllocateHeap (RtlGetProcessHeap (),
|
|
|
|
0,
|
|
|
|
Length + 1);
|
|
|
|
DPRINT("EnvPtr %p\n", EnvPtr);
|
1999-10-02 20:20:44 +00:00
|
|
|
|
2000-02-18 00:51:03 +00:00
|
|
|
/* convert unicode environment to ansi */
|
|
|
|
UnicodeString.MaximumLength = Length + sizeof(WCHAR);
|
|
|
|
UnicodeString.Buffer = EnvU;
|
1999-10-02 20:20:44 +00:00
|
|
|
|
2000-02-18 00:51:03 +00:00
|
|
|
AnsiString.MaximumLength = Length + 1;
|
|
|
|
AnsiString.Length = 0;
|
|
|
|
AnsiString.Buffer = EnvPtr;
|
1999-10-02 20:20:44 +00:00
|
|
|
|
2000-02-18 00:51:03 +00:00
|
|
|
DPRINT ("UnicodeString.Buffer \'%S\'\n", UnicodeString.Buffer);
|
1999-10-02 20:20:44 +00:00
|
|
|
|
2000-02-18 00:51:03 +00:00
|
|
|
while (*(UnicodeString.Buffer))
|
|
|
|
{
|
|
|
|
UnicodeString.Length = wcslen (UnicodeString.Buffer) * sizeof(WCHAR);
|
|
|
|
if (UnicodeString.Length > 0)
|
|
|
|
{
|
|
|
|
DPRINT("UnicodeString.Buffer \'%S\'\n", UnicodeString.Buffer);
|
1999-10-02 20:20:44 +00:00
|
|
|
|
2000-02-18 00:51:03 +00:00
|
|
|
RtlUnicodeStringToAnsiString (&AnsiString,
|
|
|
|
&UnicodeString,
|
|
|
|
FALSE);
|
1999-10-02 20:20:44 +00:00
|
|
|
|
2000-02-18 00:51:03 +00:00
|
|
|
DPRINT("AnsiString.Buffer \'%s\'\n", AnsiString.Buffer);
|
1999-10-02 20:20:44 +00:00
|
|
|
|
2000-02-18 00:51:03 +00:00
|
|
|
AnsiString.Buffer += (AnsiString.Length + 1);
|
|
|
|
UnicodeString.Buffer += ((UnicodeString.Length / sizeof(WCHAR)) + 1);
|
|
|
|
}
|
1999-10-02 20:20:44 +00:00
|
|
|
}
|
2000-02-18 00:51:03 +00:00
|
|
|
*(AnsiString.Buffer) = 0;
|
1999-10-02 20:20:44 +00:00
|
|
|
|
2000-02-18 00:51:03 +00:00
|
|
|
return EnvPtr;
|
1999-10-02 20:20:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-18 00:51:03 +00:00
|
|
|
LPWSTR
|
|
|
|
STDCALL
|
|
|
|
GetEnvironmentStringsW (
|
|
|
|
VOID
|
|
|
|
)
|
1999-10-02 20:20:44 +00:00
|
|
|
{
|
2000-02-18 00:51:03 +00:00
|
|
|
return (LPWSTR)(NtCurrentPeb ()->ProcessParameters->Environment);
|
1999-10-02 20:20:44 +00:00
|
|
|
}
|
|
|
|
|
2000-02-18 00:51:03 +00:00
|
|
|
|
|
|
|
WINBOOL
|
|
|
|
STDCALL
|
|
|
|
FreeEnvironmentStringsA (
|
|
|
|
LPSTR EnvironmentStrings
|
|
|
|
)
|
1999-10-02 20:20:44 +00:00
|
|
|
{
|
2000-02-18 00:51:03 +00:00
|
|
|
if (EnvironmentStrings == NULL)
|
|
|
|
return FALSE;
|
1999-10-02 20:20:44 +00:00
|
|
|
|
2000-02-18 00:51:03 +00:00
|
|
|
RtlFreeHeap (RtlGetProcessHeap (),
|
|
|
|
0,
|
|
|
|
EnvironmentStrings);
|
1999-10-02 20:20:44 +00:00
|
|
|
|
2000-02-18 00:51:03 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
1999-10-02 20:20:44 +00:00
|
|
|
|
|
|
|
|
2000-02-18 00:51:03 +00:00
|
|
|
WINBOOL
|
|
|
|
STDCALL
|
|
|
|
FreeEnvironmentStringsW (
|
|
|
|
LPWSTR EnvironmentStrings
|
|
|
|
)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
1999-10-02 20:20:44 +00:00
|
|
|
|
|
|
|
|
2000-02-18 00:51:03 +00:00
|
|
|
DWORD
|
|
|
|
STDCALL
|
|
|
|
ExpandEnvironmentStringsA (
|
|
|
|
LPCSTR lpSrc,
|
|
|
|
LPSTR lpDst,
|
|
|
|
DWORD nSize
|
|
|
|
)
|
|
|
|
{
|
|
|
|
ANSI_STRING Source;
|
|
|
|
ANSI_STRING Destination;
|
|
|
|
UNICODE_STRING SourceU;
|
|
|
|
UNICODE_STRING DestinationU;
|
|
|
|
NTSTATUS Status;
|
|
|
|
ULONG Length = 0;
|
|
|
|
|
|
|
|
RtlInitAnsiString (&Source,
|
|
|
|
(LPSTR)lpSrc);
|
|
|
|
RtlAnsiStringToUnicodeString (&SourceU,
|
|
|
|
&Source,
|
|
|
|
TRUE);
|
|
|
|
|
|
|
|
Destination.Length = 0;
|
|
|
|
Destination.MaximumLength = nSize;
|
|
|
|
Destination.Buffer = lpDst,
|
|
|
|
|
|
|
|
DestinationU.Length = 0;
|
|
|
|
DestinationU.MaximumLength = nSize * sizeof(WCHAR);
|
|
|
|
DestinationU.Buffer = RtlAllocateHeap (RtlGetProcessHeap (),
|
|
|
|
0,
|
|
|
|
DestinationU.MaximumLength);
|
|
|
|
|
|
|
|
Status = RtlExpandEnvironmentStrings_U (NULL,
|
|
|
|
&SourceU,
|
|
|
|
&DestinationU,
|
|
|
|
&Length);
|
|
|
|
|
|
|
|
RtlFreeUnicodeString (&SourceU);
|
|
|
|
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
RtlFreeHeap (RtlGetProcessHeap (),
|
|
|
|
0,
|
|
|
|
DestinationU.Buffer);
|
2000-07-01 17:07:02 +00:00
|
|
|
SetLastErrorByStatus (Status);
|
2000-02-18 00:51:03 +00:00
|
|
|
return 0;
|
1999-10-02 20:20:44 +00:00
|
|
|
}
|
|
|
|
|
2000-02-18 00:51:03 +00:00
|
|
|
RtlUnicodeStringToAnsiString (&Destination,
|
|
|
|
&DestinationU,
|
|
|
|
FALSE);
|
1999-10-02 20:20:44 +00:00
|
|
|
|
2000-02-18 00:51:03 +00:00
|
|
|
RtlFreeHeap (RtlGetProcessHeap (),
|
|
|
|
0,
|
|
|
|
DestinationU.Buffer);
|
1999-10-02 20:20:44 +00:00
|
|
|
|
2000-02-18 00:51:03 +00:00
|
|
|
return (Length / sizeof(WCHAR));
|
1999-10-02 20:20:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-18 00:51:03 +00:00
|
|
|
DWORD
|
|
|
|
STDCALL
|
|
|
|
ExpandEnvironmentStringsW (
|
|
|
|
LPCWSTR lpSrc,
|
|
|
|
LPWSTR lpDst,
|
|
|
|
DWORD nSize
|
|
|
|
)
|
1999-10-02 20:20:44 +00:00
|
|
|
{
|
2000-02-18 00:51:03 +00:00
|
|
|
UNICODE_STRING Source;
|
|
|
|
UNICODE_STRING Destination;
|
|
|
|
NTSTATUS Status;
|
|
|
|
ULONG Length = 0;
|
|
|
|
|
|
|
|
RtlInitUnicodeString (&Source,
|
|
|
|
(LPWSTR)lpSrc);
|
|
|
|
|
|
|
|
Destination.Length = 0;
|
|
|
|
Destination.MaximumLength = nSize * sizeof(WCHAR);
|
|
|
|
Destination.Buffer = lpDst;
|
|
|
|
|
|
|
|
Status = RtlExpandEnvironmentStrings_U (NULL,
|
|
|
|
&Source,
|
|
|
|
&Destination,
|
|
|
|
&Length);
|
|
|
|
if (!NT_SUCCESS(Status))
|
1999-10-02 20:20:44 +00:00
|
|
|
{
|
2000-07-01 17:07:02 +00:00
|
|
|
SetLastErrorByStatus (Status);
|
2000-02-18 00:51:03 +00:00
|
|
|
return 0;
|
1999-10-02 20:20:44 +00:00
|
|
|
}
|
2000-02-18 00:51:03 +00:00
|
|
|
|
|
|
|
return (Length / sizeof(WCHAR));
|
1999-10-02 20:20:44 +00:00
|
|
|
}
|
|
|
|
|
2000-07-01 17:07:02 +00:00
|
|
|
/* EOF */
|