ホーム › System.LibraryLoader › SetDllDirectoryA
SetDllDirectoryA
関数DLL検索ディレクトリをANSIパスで設定する。
シグネチャ
// KERNEL32.dll (ANSI / -A)
#include <windows.h>
BOOL SetDllDirectoryA(
LPCSTR lpPathName // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| lpPathName | LPCSTR | inoptional |
戻り値の型: BOOL
各言語での呼び出し定義
// KERNEL32.dll (ANSI / -A)
#include <windows.h>
BOOL SetDllDirectoryA(
LPCSTR lpPathName // optional
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern bool SetDllDirectoryA(
[MarshalAs(UnmanagedType.LPStr)] string lpPathName // LPCSTR optional
);<DllImport("KERNEL32.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetDllDirectoryA(
<MarshalAs(UnmanagedType.LPStr)> lpPathName As String ' LPCSTR optional
) As Boolean
End Function' lpPathName : LPCSTR optional
Declare PtrSafe Function SetDllDirectoryA Lib "kernel32" ( _
ByVal lpPathName As String) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SetDllDirectoryA = ctypes.windll.kernel32.SetDllDirectoryA
SetDllDirectoryA.restype = wintypes.BOOL
SetDllDirectoryA.argtypes = [
wintypes.LPCSTR, # lpPathName : LPCSTR optional
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
SetDllDirectoryA = Fiddle::Function.new(
lib['SetDllDirectoryA'],
[
Fiddle::TYPE_VOIDP, # lpPathName : LPCSTR optional
],
Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn SetDllDirectoryA(
lpPathName: *const u8 // LPCSTR optional
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern bool SetDllDirectoryA([MarshalAs(UnmanagedType.LPStr)] string lpPathName);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_SetDllDirectoryA' -Namespace Win32 -PassThru
# $api::SetDllDirectoryA(lpPathName)#uselib "KERNEL32.dll"
#func global SetDllDirectoryA "SetDllDirectoryA" sptr
; SetDllDirectoryA lpPathName ; 戻り値は stat
; lpPathName : LPCSTR optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "KERNEL32.dll"
#cfunc global SetDllDirectoryA "SetDllDirectoryA" str
; res = SetDllDirectoryA(lpPathName)
; lpPathName : LPCSTR optional -> "str"; BOOL SetDllDirectoryA(LPCSTR lpPathName)
#uselib "KERNEL32.dll"
#cfunc global SetDllDirectoryA "SetDllDirectoryA" str
; res = SetDllDirectoryA(lpPathName)
; lpPathName : LPCSTR optional -> "str"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procSetDllDirectoryA = kernel32.NewProc("SetDllDirectoryA")
)
// lpPathName (LPCSTR optional)
r1, _, err := procSetDllDirectoryA.Call(
uintptr(unsafe.Pointer(windows.BytePtrFromString(lpPathName))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction SetDllDirectoryA(
lpPathName: PAnsiChar // LPCSTR optional
): BOOL; stdcall;
external 'KERNEL32.dll' name 'SetDllDirectoryA';result := DllCall("KERNEL32\SetDllDirectoryA"
, "AStr", lpPathName ; LPCSTR optional
, "Int") ; return: BOOL●SetDllDirectoryA(lpPathName) = DLL("KERNEL32.dll", "bool SetDllDirectoryA(char*)")
# 呼び出し: SetDllDirectoryA(lpPathName)
# lpPathName : LPCSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。