ホーム › Storage.FileSystem › SetFileAttributesFromAppW
SetFileAttributesFromAppW
関数アプリコンテナからファイルの属性を設定する。
シグネチャ
// api-ms-win-core-file-fromapp-l1-1-0.dll
#include <windows.h>
BOOL SetFileAttributesFromAppW(
LPCWSTR lpFileName,
DWORD dwFileAttributes
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| lpFileName | LPCWSTR | in |
| dwFileAttributes | DWORD | in |
戻り値の型: BOOL
各言語での呼び出し定義
// api-ms-win-core-file-fromapp-l1-1-0.dll
#include <windows.h>
BOOL SetFileAttributesFromAppW(
LPCWSTR lpFileName,
DWORD dwFileAttributes
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("api-ms-win-core-file-fromapp-l1-1-0.dll", ExactSpelling = true)]
static extern bool SetFileAttributesFromAppW(
[MarshalAs(UnmanagedType.LPWStr)] string lpFileName, // LPCWSTR
uint dwFileAttributes // DWORD
);<DllImport("api-ms-win-core-file-fromapp-l1-1-0.dll", ExactSpelling:=True)>
Public Shared Function SetFileAttributesFromAppW(
<MarshalAs(UnmanagedType.LPWStr)> lpFileName As String, ' LPCWSTR
dwFileAttributes As UInteger ' DWORD
) As Boolean
End Function' lpFileName : LPCWSTR
' dwFileAttributes : DWORD
Declare PtrSafe Function SetFileAttributesFromAppW Lib "api-ms-win-core-file-fromapp-l1-1-0" ( _
ByVal lpFileName As LongPtr, _
ByVal dwFileAttributes As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SetFileAttributesFromAppW = ctypes.windll.LoadLibrary("api-ms-win-core-file-fromapp-l1-1-0.dll").SetFileAttributesFromAppW
SetFileAttributesFromAppW.restype = wintypes.BOOL
SetFileAttributesFromAppW.argtypes = [
wintypes.LPCWSTR, # lpFileName : LPCWSTR
wintypes.DWORD, # dwFileAttributes : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('api-ms-win-core-file-fromapp-l1-1-0.dll')
SetFileAttributesFromAppW = Fiddle::Function.new(
lib['SetFileAttributesFromAppW'],
[
Fiddle::TYPE_VOIDP, # lpFileName : LPCWSTR
-Fiddle::TYPE_INT, # dwFileAttributes : DWORD
],
Fiddle::TYPE_INT)#[link(name = "api-ms-win-core-file-fromapp-l1-1-0")]
extern "system" {
fn SetFileAttributesFromAppW(
lpFileName: *const u16, // LPCWSTR
dwFileAttributes: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("api-ms-win-core-file-fromapp-l1-1-0.dll")]
public static extern bool SetFileAttributesFromAppW([MarshalAs(UnmanagedType.LPWStr)] string lpFileName, uint dwFileAttributes);
"@
$api = Add-Type -MemberDefinition $sig -Name 'api-ms-win-core-file-fromapp-l1-1-0_SetFileAttributesFromAppW' -Namespace Win32 -PassThru
# $api::SetFileAttributesFromAppW(lpFileName, dwFileAttributes)#uselib "api-ms-win-core-file-fromapp-l1-1-0.dll"
#func global SetFileAttributesFromAppW "SetFileAttributesFromAppW" sptr, sptr
; SetFileAttributesFromAppW lpFileName, dwFileAttributes ; 戻り値は stat
; lpFileName : LPCWSTR -> "sptr"
; dwFileAttributes : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "api-ms-win-core-file-fromapp-l1-1-0.dll"
#cfunc global SetFileAttributesFromAppW "SetFileAttributesFromAppW" wstr, int
; res = SetFileAttributesFromAppW(lpFileName, dwFileAttributes)
; lpFileName : LPCWSTR -> "wstr"
; dwFileAttributes : DWORD -> "int"; BOOL SetFileAttributesFromAppW(LPCWSTR lpFileName, DWORD dwFileAttributes)
#uselib "api-ms-win-core-file-fromapp-l1-1-0.dll"
#cfunc global SetFileAttributesFromAppW "SetFileAttributesFromAppW" wstr, int
; res = SetFileAttributesFromAppW(lpFileName, dwFileAttributes)
; lpFileName : LPCWSTR -> "wstr"
; dwFileAttributes : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
api_ms_win_core_file_fromapp_l1_1_0 = windows.NewLazySystemDLL("api-ms-win-core-file-fromapp-l1-1-0.dll")
procSetFileAttributesFromAppW = api_ms_win_core_file_fromapp_l1_1_0.NewProc("SetFileAttributesFromAppW")
)
// lpFileName (LPCWSTR), dwFileAttributes (DWORD)
r1, _, err := procSetFileAttributesFromAppW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpFileName))),
uintptr(dwFileAttributes),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction SetFileAttributesFromAppW(
lpFileName: PWideChar; // LPCWSTR
dwFileAttributes: DWORD // DWORD
): BOOL; stdcall;
external 'api-ms-win-core-file-fromapp-l1-1-0.dll' name 'SetFileAttributesFromAppW';result := DllCall("api-ms-win-core-file-fromapp-l1-1-0\SetFileAttributesFromAppW"
, "WStr", lpFileName ; LPCWSTR
, "UInt", dwFileAttributes ; DWORD
, "Int") ; return: BOOL●SetFileAttributesFromAppW(lpFileName, dwFileAttributes) = DLL("api-ms-win-core-file-fromapp-l1-1-0.dll", "bool SetFileAttributesFromAppW(char*, dword)")
# 呼び出し: SetFileAttributesFromAppW(lpFileName, dwFileAttributes)
# lpFileName : LPCWSTR -> "char*"
# dwFileAttributes : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。