ホーム › Security.AppLocker › SaferiIsExecutableFileType
SaferiIsExecutableFileType
関数指定パスのファイルが実行可能ファイル種別かどうかを判定する。
シグネチャ
// ADVAPI32.dll
#include <windows.h>
BOOL SaferiIsExecutableFileType(
LPCWSTR szFullPathname,
BOOLEAN bFromShellExecute
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| szFullPathname | LPCWSTR | in |
| bFromShellExecute | BOOLEAN | in |
戻り値の型: BOOL
各言語での呼び出し定義
// ADVAPI32.dll
#include <windows.h>
BOOL SaferiIsExecutableFileType(
LPCWSTR szFullPathname,
BOOLEAN bFromShellExecute
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("ADVAPI32.dll", ExactSpelling = true)]
static extern bool SaferiIsExecutableFileType(
[MarshalAs(UnmanagedType.LPWStr)] string szFullPathname, // LPCWSTR
[MarshalAs(UnmanagedType.U1)] bool bFromShellExecute // BOOLEAN
);<DllImport("ADVAPI32.dll", ExactSpelling:=True)>
Public Shared Function SaferiIsExecutableFileType(
<MarshalAs(UnmanagedType.LPWStr)> szFullPathname As String, ' LPCWSTR
<MarshalAs(UnmanagedType.U1)> bFromShellExecute As Boolean ' BOOLEAN
) As Boolean
End Function' szFullPathname : LPCWSTR
' bFromShellExecute : BOOLEAN
Declare PtrSafe Function SaferiIsExecutableFileType Lib "advapi32" ( _
ByVal szFullPathname As LongPtr, _
ByVal bFromShellExecute As Byte) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SaferiIsExecutableFileType = ctypes.windll.advapi32.SaferiIsExecutableFileType
SaferiIsExecutableFileType.restype = wintypes.BOOL
SaferiIsExecutableFileType.argtypes = [
wintypes.LPCWSTR, # szFullPathname : LPCWSTR
ctypes.c_byte, # bFromShellExecute : BOOLEAN
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ADVAPI32.dll')
SaferiIsExecutableFileType = Fiddle::Function.new(
lib['SaferiIsExecutableFileType'],
[
Fiddle::TYPE_VOIDP, # szFullPathname : LPCWSTR
Fiddle::TYPE_CHAR, # bFromShellExecute : BOOLEAN
],
Fiddle::TYPE_INT)#[link(name = "advapi32")]
extern "system" {
fn SaferiIsExecutableFileType(
szFullPathname: *const u16, // LPCWSTR
bFromShellExecute: u8 // BOOLEAN
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("ADVAPI32.dll")]
public static extern bool SaferiIsExecutableFileType([MarshalAs(UnmanagedType.LPWStr)] string szFullPathname, [MarshalAs(UnmanagedType.U1)] bool bFromShellExecute);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_SaferiIsExecutableFileType' -Namespace Win32 -PassThru
# $api::SaferiIsExecutableFileType(szFullPathname, bFromShellExecute)#uselib "ADVAPI32.dll"
#func global SaferiIsExecutableFileType "SaferiIsExecutableFileType" sptr, sptr
; SaferiIsExecutableFileType szFullPathname, bFromShellExecute ; 戻り値は stat
; szFullPathname : LPCWSTR -> "sptr"
; bFromShellExecute : BOOLEAN -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "ADVAPI32.dll"
#cfunc global SaferiIsExecutableFileType "SaferiIsExecutableFileType" wstr, int
; res = SaferiIsExecutableFileType(szFullPathname, bFromShellExecute)
; szFullPathname : LPCWSTR -> "wstr"
; bFromShellExecute : BOOLEAN -> "int"; BOOL SaferiIsExecutableFileType(LPCWSTR szFullPathname, BOOLEAN bFromShellExecute)
#uselib "ADVAPI32.dll"
#cfunc global SaferiIsExecutableFileType "SaferiIsExecutableFileType" wstr, int
; res = SaferiIsExecutableFileType(szFullPathname, bFromShellExecute)
; szFullPathname : LPCWSTR -> "wstr"
; bFromShellExecute : BOOLEAN -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
procSaferiIsExecutableFileType = advapi32.NewProc("SaferiIsExecutableFileType")
)
// szFullPathname (LPCWSTR), bFromShellExecute (BOOLEAN)
r1, _, err := procSaferiIsExecutableFileType.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szFullPathname))),
uintptr(bFromShellExecute),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction SaferiIsExecutableFileType(
szFullPathname: PWideChar; // LPCWSTR
bFromShellExecute: ByteBool // BOOLEAN
): BOOL; stdcall;
external 'ADVAPI32.dll' name 'SaferiIsExecutableFileType';result := DllCall("ADVAPI32\SaferiIsExecutableFileType"
, "WStr", szFullPathname ; LPCWSTR
, "Char", bFromShellExecute ; BOOLEAN
, "Int") ; return: BOOL●SaferiIsExecutableFileType(szFullPathname, bFromShellExecute) = DLL("ADVAPI32.dll", "bool SaferiIsExecutableFileType(char*, byte)")
# 呼び出し: SaferiIsExecutableFileType(szFullPathname, bFromShellExecute)
# szFullPathname : LPCWSTR -> "char*"
# bFromShellExecute : BOOLEAN -> "byte"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。