ホーム › Storage.FileSystem › SetFileAttributesTransactedA
SetFileAttributesTransactedA
関数トランザクション内でファイル属性を設定する(ANSI版)。
シグネチャ
// KERNEL32.dll (ANSI / -A)
#include <windows.h>
BOOL SetFileAttributesTransactedA(
LPCSTR lpFileName,
DWORD dwFileAttributes,
HANDLE hTransaction
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| lpFileName | LPCSTR | in |
| dwFileAttributes | DWORD | in |
| hTransaction | HANDLE | in |
戻り値の型: BOOL
各言語での呼び出し定義
// KERNEL32.dll (ANSI / -A)
#include <windows.h>
BOOL SetFileAttributesTransactedA(
LPCSTR lpFileName,
DWORD dwFileAttributes,
HANDLE hTransaction
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern bool SetFileAttributesTransactedA(
[MarshalAs(UnmanagedType.LPStr)] string lpFileName, // LPCSTR
uint dwFileAttributes, // DWORD
IntPtr hTransaction // HANDLE
);<DllImport("KERNEL32.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetFileAttributesTransactedA(
<MarshalAs(UnmanagedType.LPStr)> lpFileName As String, ' LPCSTR
dwFileAttributes As UInteger, ' DWORD
hTransaction As IntPtr ' HANDLE
) As Boolean
End Function' lpFileName : LPCSTR
' dwFileAttributes : DWORD
' hTransaction : HANDLE
Declare PtrSafe Function SetFileAttributesTransactedA Lib "kernel32" ( _
ByVal lpFileName As String, _
ByVal dwFileAttributes As Long, _
ByVal hTransaction As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SetFileAttributesTransactedA = ctypes.windll.kernel32.SetFileAttributesTransactedA
SetFileAttributesTransactedA.restype = wintypes.BOOL
SetFileAttributesTransactedA.argtypes = [
wintypes.LPCSTR, # lpFileName : LPCSTR
wintypes.DWORD, # dwFileAttributes : DWORD
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')
SetFileAttributesTransactedA = Fiddle::Function.new(
lib['SetFileAttributesTransactedA'],
[
Fiddle::TYPE_VOIDP, # lpFileName : LPCSTR
-Fiddle::TYPE_INT, # dwFileAttributes : DWORD
Fiddle::TYPE_VOIDP, # hTransaction : HANDLE
],
Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn SetFileAttributesTransactedA(
lpFileName: *const u8, // LPCSTR
dwFileAttributes: u32, // DWORD
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.Ansi, SetLastError = true)]
public static extern bool SetFileAttributesTransactedA([MarshalAs(UnmanagedType.LPStr)] string lpFileName, uint dwFileAttributes, IntPtr hTransaction);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_SetFileAttributesTransactedA' -Namespace Win32 -PassThru
# $api::SetFileAttributesTransactedA(lpFileName, dwFileAttributes, hTransaction)#uselib "KERNEL32.dll"
#func global SetFileAttributesTransactedA "SetFileAttributesTransactedA" sptr, sptr, sptr
; SetFileAttributesTransactedA lpFileName, dwFileAttributes, hTransaction ; 戻り値は stat
; lpFileName : LPCSTR -> "sptr"
; dwFileAttributes : DWORD -> "sptr"
; hTransaction : HANDLE -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "KERNEL32.dll"
#cfunc global SetFileAttributesTransactedA "SetFileAttributesTransactedA" str, int, sptr
; res = SetFileAttributesTransactedA(lpFileName, dwFileAttributes, hTransaction)
; lpFileName : LPCSTR -> "str"
; dwFileAttributes : DWORD -> "int"
; hTransaction : HANDLE -> "sptr"; BOOL SetFileAttributesTransactedA(LPCSTR lpFileName, DWORD dwFileAttributes, HANDLE hTransaction)
#uselib "KERNEL32.dll"
#cfunc global SetFileAttributesTransactedA "SetFileAttributesTransactedA" str, int, intptr
; res = SetFileAttributesTransactedA(lpFileName, dwFileAttributes, hTransaction)
; lpFileName : LPCSTR -> "str"
; dwFileAttributes : DWORD -> "int"
; hTransaction : HANDLE -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procSetFileAttributesTransactedA = kernel32.NewProc("SetFileAttributesTransactedA")
)
// lpFileName (LPCSTR), dwFileAttributes (DWORD), hTransaction (HANDLE)
r1, _, err := procSetFileAttributesTransactedA.Call(
uintptr(unsafe.Pointer(windows.BytePtrFromString(lpFileName))),
uintptr(dwFileAttributes),
uintptr(hTransaction),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction SetFileAttributesTransactedA(
lpFileName: PAnsiChar; // LPCSTR
dwFileAttributes: DWORD; // DWORD
hTransaction: THandle // HANDLE
): BOOL; stdcall;
external 'KERNEL32.dll' name 'SetFileAttributesTransactedA';result := DllCall("KERNEL32\SetFileAttributesTransactedA"
, "AStr", lpFileName ; LPCSTR
, "UInt", dwFileAttributes ; DWORD
, "Ptr", hTransaction ; HANDLE
, "Int") ; return: BOOL●SetFileAttributesTransactedA(lpFileName, dwFileAttributes, hTransaction) = DLL("KERNEL32.dll", "bool SetFileAttributesTransactedA(char*, dword, void*)")
# 呼び出し: SetFileAttributesTransactedA(lpFileName, dwFileAttributes, hTransaction)
# lpFileName : LPCSTR -> "char*"
# dwFileAttributes : DWORD -> "dword"
# hTransaction : HANDLE -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。