2
* WinPR: Windows Portable Runtime
3
* Process Environment Functions
5
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
7
* Licensed under the Apache License, Version 2.0 (the "License");
8
* you may not use this file except in compliance with the License.
9
* You may obtain a copy of the License at
11
* http://www.apache.org/licenses/LICENSE-2.0
13
* Unless required by applicable law or agreed to in writing, software
14
* distributed under the License is distributed on an "AS IS" BASIS,
15
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
* See the License for the specific language governing permissions and
17
* limitations under the License.
24
#include <winpr/environment.h>
28
#include <winpr/crt.h>
34
DWORD GetCurrentDirectoryA(DWORD nBufferLength, LPSTR lpBuffer)
39
cwd = getcwd(NULL, 0);
46
if ((nBufferLength == 0) && (lpBuffer == NULL))
50
return (DWORD) length;
60
if ((length + 1) > nBufferLength)
63
return (DWORD) (length + 1);
66
memcpy(lpBuffer, cwd, length + 1);
73
DWORD GetCurrentDirectoryW(DWORD nBufferLength, LPWSTR lpBuffer)
78
BOOL SetCurrentDirectoryA(LPCSTR lpPathName)
83
BOOL SetCurrentDirectoryW(LPCWSTR lpPathName)
88
DWORD SearchPathA(LPCSTR lpPath, LPCSTR lpFileName, LPCSTR lpExtension, DWORD nBufferLength, LPSTR lpBuffer, LPSTR* lpFilePart)
93
DWORD SearchPathW(LPCWSTR lpPath, LPCWSTR lpFileName, LPCWSTR lpExtension, DWORD nBufferLength, LPWSTR lpBuffer, LPWSTR* lpFilePart)
98
HANDLE GetStdHandle(DWORD nStdHandle)
103
BOOL SetStdHandle(DWORD nStdHandle, HANDLE hHandle)
108
BOOL SetStdHandleEx(DWORD dwStdHandle, HANDLE hNewHandle, HANDLE* phOldHandle)
113
LPSTR GetCommandLineA(VOID)
118
LPWSTR GetCommandLineW(VOID)
123
BOOL NeedCurrentDirectoryForExePathA(LPCSTR ExeName)
128
BOOL NeedCurrentDirectoryForExePathW(LPCWSTR ExeName)
133
DWORD GetEnvironmentVariableA(LPCSTR lpName, LPSTR lpBuffer, DWORD nSize)
138
env = getenv(lpName);
143
length = strlen(env);
145
if ((length + 1 > nSize) || (!lpBuffer))
148
CopyMemory(lpBuffer, env, length + 1);
153
DWORD GetEnvironmentVariableW(LPCWSTR lpName, LPWSTR lpBuffer, DWORD nSize)
158
BOOL SetEnvironmentVariableA(LPCSTR lpName, LPCSTR lpValue)
163
BOOL SetEnvironmentVariableW(LPCWSTR lpName, LPCWSTR lpValue)
168
LPCH GetEnvironmentStrings(VOID)
173
LPWCH GetEnvironmentStringsW(VOID)
178
BOOL SetEnvironmentStringsA(LPCH NewEnvironment)
183
BOOL SetEnvironmentStringsW(LPWCH NewEnvironment)
188
DWORD ExpandEnvironmentStringsA(LPCSTR lpSrc, LPSTR lpDst, DWORD nSize)
193
DWORD ExpandEnvironmentStringsW(LPCWSTR lpSrc, LPWSTR lpDst, DWORD nSize)
198
BOOL FreeEnvironmentStringsA(LPCH lpszEnvironmentBlock)
203
BOOL FreeEnvironmentStringsW(LPWCH lpszEnvironmentBlock)