Win32 API 日本語リファレンス
ホームUI.Shell › PathIsExe

PathIsExe

関数
指定パスが実行可能ファイルかを判定する。
DLLSHELL32.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

// SHELL32.dll
#include <windows.h>

BOOL PathIsExe(
    LPCWSTR pszPath
);

パラメーター

名前方向
pszPathLPCWSTRin

戻り値の型: BOOL

各言語での呼び出し定義

// SHELL32.dll
#include <windows.h>

BOOL PathIsExe(
    LPCWSTR pszPath
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SHELL32.dll", ExactSpelling = true)]
static extern bool PathIsExe(
    [MarshalAs(UnmanagedType.LPWStr)] string pszPath   // LPCWSTR
);
<DllImport("SHELL32.dll", ExactSpelling:=True)>
Public Shared Function PathIsExe(
    <MarshalAs(UnmanagedType.LPWStr)> pszPath As String   ' LPCWSTR
) As Boolean
End Function
' pszPath : LPCWSTR
Declare PtrSafe Function PathIsExe Lib "shell32" ( _
    ByVal pszPath As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

PathIsExe = ctypes.windll.shell32.PathIsExe
PathIsExe.restype = wintypes.BOOL
PathIsExe.argtypes = [
    wintypes.LPCWSTR,  # pszPath : LPCWSTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SHELL32.dll')
PathIsExe = Fiddle::Function.new(
  lib['PathIsExe'],
  [
    Fiddle::TYPE_VOIDP,  # pszPath : LPCWSTR
  ],
  Fiddle::TYPE_INT)
#[link(name = "shell32")]
extern "system" {
    fn PathIsExe(
        pszPath: *const u16  // LPCWSTR
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SHELL32.dll")]
public static extern bool PathIsExe([MarshalAs(UnmanagedType.LPWStr)] string pszPath);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHELL32_PathIsExe' -Namespace Win32 -PassThru
# $api::PathIsExe(pszPath)
#uselib "SHELL32.dll"
#func global PathIsExe "PathIsExe" sptr
; PathIsExe pszPath   ; 戻り値は stat
; pszPath : LPCWSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "SHELL32.dll"
#cfunc global PathIsExe "PathIsExe" wstr
; res = PathIsExe(pszPath)
; pszPath : LPCWSTR -> "wstr"
; BOOL PathIsExe(LPCWSTR pszPath)
#uselib "SHELL32.dll"
#cfunc global PathIsExe "PathIsExe" wstr
; res = PathIsExe(pszPath)
; pszPath : LPCWSTR -> "wstr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	shell32 = windows.NewLazySystemDLL("SHELL32.dll")
	procPathIsExe = shell32.NewProc("PathIsExe")
)

// pszPath (LPCWSTR)
r1, _, err := procPathIsExe.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszPath))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function PathIsExe(
  pszPath: PWideChar   // LPCWSTR
): BOOL; stdcall;
  external 'SHELL32.dll' name 'PathIsExe';
result := DllCall("SHELL32\PathIsExe"
    , "WStr", pszPath   ; LPCWSTR
    , "Int")   ; return: BOOL
●PathIsExe(pszPath) = DLL("SHELL32.dll", "bool PathIsExe(char*)")
# 呼び出し: PathIsExe(pszPath)
# pszPath : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。