ホーム › Storage.FileSystem › GetFileAttributesTransactedW
GetFileAttributesTransactedW
関数トランザクション内でファイル属性情報を取得する(Unicode版)。
シグネチャ
// KERNEL32.dll (Unicode / -W)
#include <windows.h>
BOOL GetFileAttributesTransactedW(
LPCWSTR lpFileName,
GET_FILEEX_INFO_LEVELS fInfoLevelId,
void* lpFileInformation,
HANDLE hTransaction
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| lpFileName | LPCWSTR | in |
| fInfoLevelId | GET_FILEEX_INFO_LEVELS | in |
| lpFileInformation | void* | out |
| hTransaction | HANDLE | in |
戻り値の型: BOOL
各言語での呼び出し定義
// KERNEL32.dll (Unicode / -W)
#include <windows.h>
BOOL GetFileAttributesTransactedW(
LPCWSTR lpFileName,
GET_FILEEX_INFO_LEVELS fInfoLevelId,
void* lpFileInformation,
HANDLE hTransaction
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern bool GetFileAttributesTransactedW(
[MarshalAs(UnmanagedType.LPWStr)] string lpFileName, // LPCWSTR
int fInfoLevelId, // GET_FILEEX_INFO_LEVELS
IntPtr lpFileInformation, // void* out
IntPtr hTransaction // HANDLE
);<DllImport("KERNEL32.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetFileAttributesTransactedW(
<MarshalAs(UnmanagedType.LPWStr)> lpFileName As String, ' LPCWSTR
fInfoLevelId As Integer, ' GET_FILEEX_INFO_LEVELS
lpFileInformation As IntPtr, ' void* out
hTransaction As IntPtr ' HANDLE
) As Boolean
End Function' lpFileName : LPCWSTR
' fInfoLevelId : GET_FILEEX_INFO_LEVELS
' lpFileInformation : void* out
' hTransaction : HANDLE
Declare PtrSafe Function GetFileAttributesTransactedW Lib "kernel32" ( _
ByVal lpFileName As LongPtr, _
ByVal fInfoLevelId As Long, _
ByVal lpFileInformation As LongPtr, _
ByVal hTransaction 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
GetFileAttributesTransactedW = ctypes.windll.kernel32.GetFileAttributesTransactedW
GetFileAttributesTransactedW.restype = wintypes.BOOL
GetFileAttributesTransactedW.argtypes = [
wintypes.LPCWSTR, # lpFileName : LPCWSTR
ctypes.c_int, # fInfoLevelId : GET_FILEEX_INFO_LEVELS
ctypes.POINTER(None), # lpFileInformation : void* out
wintypes.HANDLE, # hTransaction : HANDLE
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
GetFileAttributesTransactedW = Fiddle::Function.new(
lib['GetFileAttributesTransactedW'],
[
Fiddle::TYPE_VOIDP, # lpFileName : LPCWSTR
Fiddle::TYPE_INT, # fInfoLevelId : GET_FILEEX_INFO_LEVELS
Fiddle::TYPE_VOIDP, # lpFileInformation : void* out
Fiddle::TYPE_VOIDP, # hTransaction : HANDLE
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "kernel32")]
extern "system" {
fn GetFileAttributesTransactedW(
lpFileName: *const u16, // LPCWSTR
fInfoLevelId: i32, // GET_FILEEX_INFO_LEVELS
lpFileInformation: *mut (), // void* out
hTransaction: *mut core::ffi::c_void // HANDLE
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool GetFileAttributesTransactedW([MarshalAs(UnmanagedType.LPWStr)] string lpFileName, int fInfoLevelId, IntPtr lpFileInformation, IntPtr hTransaction);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_GetFileAttributesTransactedW' -Namespace Win32 -PassThru
# $api::GetFileAttributesTransactedW(lpFileName, fInfoLevelId, lpFileInformation, hTransaction)#uselib "KERNEL32.dll"
#func global GetFileAttributesTransactedW "GetFileAttributesTransactedW" wptr, wptr, wptr, wptr
; GetFileAttributesTransactedW lpFileName, fInfoLevelId, lpFileInformation, hTransaction ; 戻り値は stat
; lpFileName : LPCWSTR -> "wptr"
; fInfoLevelId : GET_FILEEX_INFO_LEVELS -> "wptr"
; lpFileInformation : void* out -> "wptr"
; hTransaction : HANDLE -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "KERNEL32.dll"
#cfunc global GetFileAttributesTransactedW "GetFileAttributesTransactedW" wstr, int, sptr, sptr
; res = GetFileAttributesTransactedW(lpFileName, fInfoLevelId, lpFileInformation, hTransaction)
; lpFileName : LPCWSTR -> "wstr"
; fInfoLevelId : GET_FILEEX_INFO_LEVELS -> "int"
; lpFileInformation : void* out -> "sptr"
; hTransaction : HANDLE -> "sptr"; BOOL GetFileAttributesTransactedW(LPCWSTR lpFileName, GET_FILEEX_INFO_LEVELS fInfoLevelId, void* lpFileInformation, HANDLE hTransaction)
#uselib "KERNEL32.dll"
#cfunc global GetFileAttributesTransactedW "GetFileAttributesTransactedW" wstr, int, intptr, intptr
; res = GetFileAttributesTransactedW(lpFileName, fInfoLevelId, lpFileInformation, hTransaction)
; lpFileName : LPCWSTR -> "wstr"
; fInfoLevelId : GET_FILEEX_INFO_LEVELS -> "int"
; lpFileInformation : void* out -> "intptr"
; hTransaction : HANDLE -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procGetFileAttributesTransactedW = kernel32.NewProc("GetFileAttributesTransactedW")
)
// lpFileName (LPCWSTR), fInfoLevelId (GET_FILEEX_INFO_LEVELS), lpFileInformation (void* out), hTransaction (HANDLE)
r1, _, err := procGetFileAttributesTransactedW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpFileName))),
uintptr(fInfoLevelId),
uintptr(lpFileInformation),
uintptr(hTransaction),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction GetFileAttributesTransactedW(
lpFileName: PWideChar; // LPCWSTR
fInfoLevelId: Integer; // GET_FILEEX_INFO_LEVELS
lpFileInformation: Pointer; // void* out
hTransaction: THandle // HANDLE
): BOOL; stdcall;
external 'KERNEL32.dll' name 'GetFileAttributesTransactedW';result := DllCall("KERNEL32\GetFileAttributesTransactedW"
, "WStr", lpFileName ; LPCWSTR
, "Int", fInfoLevelId ; GET_FILEEX_INFO_LEVELS
, "Ptr", lpFileInformation ; void* out
, "Ptr", hTransaction ; HANDLE
, "Int") ; return: BOOL●GetFileAttributesTransactedW(lpFileName, fInfoLevelId, lpFileInformation, hTransaction) = DLL("KERNEL32.dll", "bool GetFileAttributesTransactedW(char*, int, void*, void*)")
# 呼び出し: GetFileAttributesTransactedW(lpFileName, fInfoLevelId, lpFileInformation, hTransaction)
# lpFileName : LPCWSTR -> "char*"
# fInfoLevelId : GET_FILEEX_INFO_LEVELS -> "int"
# lpFileInformation : void* out -> "void*"
# hTransaction : HANDLE -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。