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