Win32 API 日本語リファレンス
ホームSystem.Environment › GetEnvironmentStrings

GetEnvironmentStrings

関数
現在のプロセスの環境ブロックを取得する(ANSI版)。
DLLKERNEL32.dll文字セットANSI (-A)呼出規約winapi対応OSWindows XP 以降

シグネチャ

// KERNEL32.dll  (ANSI / -A)
#include <windows.h>

LPSTR GetEnvironmentStrings(void);

パラメーターなし。戻り値: LPSTR

各言語での呼び出し定義

// KERNEL32.dll  (ANSI / -A)
#include <windows.h>

LPSTR GetEnvironmentStrings(void);
[DllImport("KERNEL32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern IntPtr GetEnvironmentStrings();
<DllImport("KERNEL32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function GetEnvironmentStrings() As IntPtr
End Function
Declare PtrSafe Function GetEnvironmentStrings Lib "kernel32" () As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetEnvironmentStrings = ctypes.windll.kernel32.GetEnvironmentStrings
GetEnvironmentStrings.restype = wintypes.LPSTR
GetEnvironmentStrings.argtypes = []
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('KERNEL32.dll')
GetEnvironmentStrings = Fiddle::Function.new(
  lib['GetEnvironmentStrings'],
  [],
  Fiddle::TYPE_VOIDP)
#[link(name = "kernel32")]
extern "system" {
    fn GetEnvironmentStrings() -> *mut u8;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("KERNEL32.dll", CharSet = CharSet.Ansi)]
public static extern IntPtr GetEnvironmentStrings();
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_GetEnvironmentStrings' -Namespace Win32 -PassThru
# $api::GetEnvironmentStrings()
#uselib "KERNEL32.dll"
#func global GetEnvironmentStrings "GetEnvironmentStrings"
; GetEnvironmentStrings   ; 戻り値は stat
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "KERNEL32.dll"
#cfunc global GetEnvironmentStrings "GetEnvironmentStrings"
; res = GetEnvironmentStrings()
; LPSTR GetEnvironmentStrings()
#uselib "KERNEL32.dll"
#cfunc global GetEnvironmentStrings "GetEnvironmentStrings"
; res = GetEnvironmentStrings()
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procGetEnvironmentStrings = kernel32.NewProc("GetEnvironmentStrings")
)

r1, _, err := procGetEnvironmentStrings.Call()
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // LPSTR
function GetEnvironmentStrings: PAnsiChar; stdcall;
  external 'KERNEL32.dll' name 'GetEnvironmentStrings';
result := DllCall("KERNEL32\GetEnvironmentStrings", "Ptr")
●GetEnvironmentStrings() = DLL("KERNEL32.dll", "char* GetEnvironmentStrings()")
# 呼び出し: GetEnvironmentStrings()
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。