ホーム › System.Environment › NeedCurrentDirectoryForExePathW
NeedCurrentDirectoryForExePathW
関数実行ファイル検索でカレントディレクトリが必要かを判定する(Unicode版)。
シグネチャ
// KERNEL32.dll (Unicode / -W)
#include <windows.h>
BOOL NeedCurrentDirectoryForExePathW(
LPCWSTR ExeName
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| ExeName | LPCWSTR | in |
戻り値の型: BOOL
各言語での呼び出し定義
// KERNEL32.dll (Unicode / -W)
#include <windows.h>
BOOL NeedCurrentDirectoryForExePathW(
LPCWSTR ExeName
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern bool NeedCurrentDirectoryForExePathW(
[MarshalAs(UnmanagedType.LPWStr)] string ExeName // LPCWSTR
);<DllImport("KERNEL32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function NeedCurrentDirectoryForExePathW(
<MarshalAs(UnmanagedType.LPWStr)> ExeName As String ' LPCWSTR
) As Boolean
End Function' ExeName : LPCWSTR
Declare PtrSafe Function NeedCurrentDirectoryForExePathW Lib "kernel32" ( _
ByVal ExeName As LongPtr) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
NeedCurrentDirectoryForExePathW = ctypes.windll.kernel32.NeedCurrentDirectoryForExePathW
NeedCurrentDirectoryForExePathW.restype = wintypes.BOOL
NeedCurrentDirectoryForExePathW.argtypes = [
wintypes.LPCWSTR, # ExeName : LPCWSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
NeedCurrentDirectoryForExePathW = Fiddle::Function.new(
lib['NeedCurrentDirectoryForExePathW'],
[
Fiddle::TYPE_VOIDP, # ExeName : LPCWSTR
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "kernel32")]
extern "system" {
fn NeedCurrentDirectoryForExePathW(
ExeName: *const u16 // LPCWSTR
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", CharSet = CharSet.Unicode)]
public static extern bool NeedCurrentDirectoryForExePathW([MarshalAs(UnmanagedType.LPWStr)] string ExeName);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_NeedCurrentDirectoryForExePathW' -Namespace Win32 -PassThru
# $api::NeedCurrentDirectoryForExePathW(ExeName)#uselib "KERNEL32.dll"
#func global NeedCurrentDirectoryForExePathW "NeedCurrentDirectoryForExePathW" wptr
; NeedCurrentDirectoryForExePathW ExeName ; 戻り値は stat
; ExeName : LPCWSTR -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "KERNEL32.dll"
#cfunc global NeedCurrentDirectoryForExePathW "NeedCurrentDirectoryForExePathW" wstr
; res = NeedCurrentDirectoryForExePathW(ExeName)
; ExeName : LPCWSTR -> "wstr"; BOOL NeedCurrentDirectoryForExePathW(LPCWSTR ExeName)
#uselib "KERNEL32.dll"
#cfunc global NeedCurrentDirectoryForExePathW "NeedCurrentDirectoryForExePathW" wstr
; res = NeedCurrentDirectoryForExePathW(ExeName)
; ExeName : LPCWSTR -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procNeedCurrentDirectoryForExePathW = kernel32.NewProc("NeedCurrentDirectoryForExePathW")
)
// ExeName (LPCWSTR)
r1, _, err := procNeedCurrentDirectoryForExePathW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(ExeName))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction NeedCurrentDirectoryForExePathW(
ExeName: PWideChar // LPCWSTR
): BOOL; stdcall;
external 'KERNEL32.dll' name 'NeedCurrentDirectoryForExePathW';result := DllCall("KERNEL32\NeedCurrentDirectoryForExePathW"
, "WStr", ExeName ; LPCWSTR
, "Int") ; return: BOOL●NeedCurrentDirectoryForExePathW(ExeName) = DLL("KERNEL32.dll", "bool NeedCurrentDirectoryForExePathW(char*)")
# 呼び出し: NeedCurrentDirectoryForExePathW(ExeName)
# ExeName : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。