ホーム › System.SystemInformation › GetSystemWindowsDirectoryA
GetSystemWindowsDirectoryA
関数共有のWindowsディレクトリのパスを取得する(ANSI版)。
シグネチャ
// KERNEL32.dll (ANSI / -A)
#include <windows.h>
DWORD GetSystemWindowsDirectoryA(
LPSTR lpBuffer, // optional
DWORD uSize
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| lpBuffer | LPSTR | outoptional |
| uSize | DWORD | in |
戻り値の型: DWORD
各言語での呼び出し定義
// KERNEL32.dll (ANSI / -A)
#include <windows.h>
DWORD GetSystemWindowsDirectoryA(
LPSTR lpBuffer, // optional
DWORD uSize
);[DllImport("KERNEL32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern uint GetSystemWindowsDirectoryA(
[MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder lpBuffer, // LPSTR optional, out
uint uSize // DWORD
);<DllImport("KERNEL32.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetSystemWindowsDirectoryA(
<MarshalAs(UnmanagedType.LPStr)> lpBuffer As System.Text.StringBuilder, ' LPSTR optional, out
uSize As UInteger ' DWORD
) As UInteger
End Function' lpBuffer : LPSTR optional, out
' uSize : DWORD
Declare PtrSafe Function GetSystemWindowsDirectoryA Lib "kernel32" ( _
ByVal lpBuffer As String, _
ByVal uSize As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetSystemWindowsDirectoryA = ctypes.windll.kernel32.GetSystemWindowsDirectoryA
GetSystemWindowsDirectoryA.restype = wintypes.DWORD
GetSystemWindowsDirectoryA.argtypes = [
wintypes.LPSTR, # lpBuffer : LPSTR optional, out
wintypes.DWORD, # uSize : DWORD
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
GetSystemWindowsDirectoryA = Fiddle::Function.new(
lib['GetSystemWindowsDirectoryA'],
[
Fiddle::TYPE_VOIDP, # lpBuffer : LPSTR optional, out
-Fiddle::TYPE_INT, # uSize : DWORD
],
-Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn GetSystemWindowsDirectoryA(
lpBuffer: *mut u8, // LPSTR optional, out
uSize: u32 // DWORD
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("KERNEL32.dll", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern uint GetSystemWindowsDirectoryA([MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder lpBuffer, uint uSize);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_GetSystemWindowsDirectoryA' -Namespace Win32 -PassThru
# $api::GetSystemWindowsDirectoryA(lpBuffer, uSize)#uselib "KERNEL32.dll"
#func global GetSystemWindowsDirectoryA "GetSystemWindowsDirectoryA" sptr, sptr
; GetSystemWindowsDirectoryA varptr(lpBuffer), uSize ; 戻り値は stat
; lpBuffer : LPSTR optional, out -> "sptr"
; uSize : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "KERNEL32.dll" #cfunc global GetSystemWindowsDirectoryA "GetSystemWindowsDirectoryA" var, int ; res = GetSystemWindowsDirectoryA(lpBuffer, uSize) ; lpBuffer : LPSTR optional, out -> "var" ; uSize : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "KERNEL32.dll" #cfunc global GetSystemWindowsDirectoryA "GetSystemWindowsDirectoryA" sptr, int ; res = GetSystemWindowsDirectoryA(varptr(lpBuffer), uSize) ; lpBuffer : LPSTR optional, out -> "sptr" ; uSize : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD GetSystemWindowsDirectoryA(LPSTR lpBuffer, DWORD uSize) #uselib "KERNEL32.dll" #cfunc global GetSystemWindowsDirectoryA "GetSystemWindowsDirectoryA" var, int ; res = GetSystemWindowsDirectoryA(lpBuffer, uSize) ; lpBuffer : LPSTR optional, out -> "var" ; uSize : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD GetSystemWindowsDirectoryA(LPSTR lpBuffer, DWORD uSize) #uselib "KERNEL32.dll" #cfunc global GetSystemWindowsDirectoryA "GetSystemWindowsDirectoryA" intptr, int ; res = GetSystemWindowsDirectoryA(varptr(lpBuffer), uSize) ; lpBuffer : LPSTR optional, out -> "intptr" ; uSize : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procGetSystemWindowsDirectoryA = kernel32.NewProc("GetSystemWindowsDirectoryA")
)
// lpBuffer (LPSTR optional, out), uSize (DWORD)
r1, _, err := procGetSystemWindowsDirectoryA.Call(
uintptr(lpBuffer),
uintptr(uSize),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction GetSystemWindowsDirectoryA(
lpBuffer: PAnsiChar; // LPSTR optional, out
uSize: DWORD // DWORD
): DWORD; stdcall;
external 'KERNEL32.dll' name 'GetSystemWindowsDirectoryA';result := DllCall("KERNEL32\GetSystemWindowsDirectoryA"
, "Ptr", lpBuffer ; LPSTR optional, out
, "UInt", uSize ; DWORD
, "UInt") ; return: DWORD●GetSystemWindowsDirectoryA(lpBuffer, uSize) = DLL("KERNEL32.dll", "dword GetSystemWindowsDirectoryA(char*, dword)")
# 呼び出し: GetSystemWindowsDirectoryA(lpBuffer, uSize)
# lpBuffer : LPSTR optional, out -> "char*"
# uSize : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。