ICorProfilerInfo11::GetEnvironmentVariable 方法

从进程中获取环境变量。 在非 Windows 平台上,运行时会保留环境变量的内部缓存,以确保线程安全。 这意味着调用 getenv 将不会读取启动后进程中运行的托管代码所设置的任何新的或更新的环境变量。

语法

    HRESULT GetEnvironmentVariable(
                [in, string] const WCHAR *szName,
                [in]         ULONG cchValue,
                [out]        ULONG *pcchValue,
                [out, annotation("_Out_writes_to_(cchValue, *pcchValue)")]
                             WCHAR szValue[]);

参数

szName
[in] 指向以 null 结尾的宽字符串的指针,该字符串包含要获取的环境变量的名称。

cchValue
[in] szValue 的长度(以字符为单位)。

pcchValue
[out] 指向 szValue 总字符长度的指针。

szValue
[out] 调用方提供的宽字符缓冲区。 当函数返回时,缓冲区将包含环境变量的值。

要求

平台:请参阅 .NET 支持的操作系统

头文件: CorProf.idl、CorProf.h

.NET 版本:自 .NET Core 3.1 起可用

另请参阅