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