ホーム › Storage.FileSystem › CreateDirectoryFromAppW
CreateDirectoryFromAppW
関数アプリコンテナからディレクトリを作成する。
シグネチャ
// api-ms-win-core-file-fromapp-l1-1-0.dll
#include <windows.h>
BOOL CreateDirectoryFromAppW(
LPCWSTR lpPathName,
SECURITY_ATTRIBUTES* lpSecurityAttributes // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| lpPathName | LPCWSTR | in |
| lpSecurityAttributes | SECURITY_ATTRIBUTES* | inoptional |
戻り値の型: BOOL
各言語での呼び出し定義
// api-ms-win-core-file-fromapp-l1-1-0.dll
#include <windows.h>
BOOL CreateDirectoryFromAppW(
LPCWSTR lpPathName,
SECURITY_ATTRIBUTES* lpSecurityAttributes // optional
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("api-ms-win-core-file-fromapp-l1-1-0.dll", ExactSpelling = true)]
static extern bool CreateDirectoryFromAppW(
[MarshalAs(UnmanagedType.LPWStr)] string lpPathName, // LPCWSTR
IntPtr lpSecurityAttributes // SECURITY_ATTRIBUTES* optional
);<DllImport("api-ms-win-core-file-fromapp-l1-1-0.dll", ExactSpelling:=True)>
Public Shared Function CreateDirectoryFromAppW(
<MarshalAs(UnmanagedType.LPWStr)> lpPathName As String, ' LPCWSTR
lpSecurityAttributes As IntPtr ' SECURITY_ATTRIBUTES* optional
) As Boolean
End Function' lpPathName : LPCWSTR
' lpSecurityAttributes : SECURITY_ATTRIBUTES* optional
Declare PtrSafe Function CreateDirectoryFromAppW Lib "api-ms-win-core-file-fromapp-l1-1-0" ( _
ByVal lpPathName As LongPtr, _
ByVal lpSecurityAttributes As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CreateDirectoryFromAppW = ctypes.windll.LoadLibrary("api-ms-win-core-file-fromapp-l1-1-0.dll").CreateDirectoryFromAppW
CreateDirectoryFromAppW.restype = wintypes.BOOL
CreateDirectoryFromAppW.argtypes = [
wintypes.LPCWSTR, # lpPathName : LPCWSTR
ctypes.c_void_p, # lpSecurityAttributes : SECURITY_ATTRIBUTES* optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('api-ms-win-core-file-fromapp-l1-1-0.dll')
CreateDirectoryFromAppW = Fiddle::Function.new(
lib['CreateDirectoryFromAppW'],
[
Fiddle::TYPE_VOIDP, # lpPathName : LPCWSTR
Fiddle::TYPE_VOIDP, # lpSecurityAttributes : SECURITY_ATTRIBUTES* optional
],
Fiddle::TYPE_INT)#[link(name = "api-ms-win-core-file-fromapp-l1-1-0")]
extern "system" {
fn CreateDirectoryFromAppW(
lpPathName: *const u16, // LPCWSTR
lpSecurityAttributes: *mut SECURITY_ATTRIBUTES // SECURITY_ATTRIBUTES* optional
) -> 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 CreateDirectoryFromAppW([MarshalAs(UnmanagedType.LPWStr)] string lpPathName, IntPtr lpSecurityAttributes);
"@
$api = Add-Type -MemberDefinition $sig -Name 'api-ms-win-core-file-fromapp-l1-1-0_CreateDirectoryFromAppW' -Namespace Win32 -PassThru
# $api::CreateDirectoryFromAppW(lpPathName, lpSecurityAttributes)#uselib "api-ms-win-core-file-fromapp-l1-1-0.dll"
#func global CreateDirectoryFromAppW "CreateDirectoryFromAppW" sptr, sptr
; CreateDirectoryFromAppW lpPathName, varptr(lpSecurityAttributes) ; 戻り値は stat
; lpPathName : LPCWSTR -> "sptr"
; lpSecurityAttributes : SECURITY_ATTRIBUTES* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "api-ms-win-core-file-fromapp-l1-1-0.dll" #cfunc global CreateDirectoryFromAppW "CreateDirectoryFromAppW" wstr, var ; res = CreateDirectoryFromAppW(lpPathName, lpSecurityAttributes) ; lpPathName : LPCWSTR -> "wstr" ; lpSecurityAttributes : SECURITY_ATTRIBUTES* optional -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "api-ms-win-core-file-fromapp-l1-1-0.dll" #cfunc global CreateDirectoryFromAppW "CreateDirectoryFromAppW" wstr, sptr ; res = CreateDirectoryFromAppW(lpPathName, varptr(lpSecurityAttributes)) ; lpPathName : LPCWSTR -> "wstr" ; lpSecurityAttributes : SECURITY_ATTRIBUTES* optional -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL CreateDirectoryFromAppW(LPCWSTR lpPathName, SECURITY_ATTRIBUTES* lpSecurityAttributes) #uselib "api-ms-win-core-file-fromapp-l1-1-0.dll" #cfunc global CreateDirectoryFromAppW "CreateDirectoryFromAppW" wstr, var ; res = CreateDirectoryFromAppW(lpPathName, lpSecurityAttributes) ; lpPathName : LPCWSTR -> "wstr" ; lpSecurityAttributes : SECURITY_ATTRIBUTES* optional -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL CreateDirectoryFromAppW(LPCWSTR lpPathName, SECURITY_ATTRIBUTES* lpSecurityAttributes) #uselib "api-ms-win-core-file-fromapp-l1-1-0.dll" #cfunc global CreateDirectoryFromAppW "CreateDirectoryFromAppW" wstr, intptr ; res = CreateDirectoryFromAppW(lpPathName, varptr(lpSecurityAttributes)) ; lpPathName : LPCWSTR -> "wstr" ; lpSecurityAttributes : SECURITY_ATTRIBUTES* optional -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
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")
procCreateDirectoryFromAppW = api_ms_win_core_file_fromapp_l1_1_0.NewProc("CreateDirectoryFromAppW")
)
// lpPathName (LPCWSTR), lpSecurityAttributes (SECURITY_ATTRIBUTES* optional)
r1, _, err := procCreateDirectoryFromAppW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpPathName))),
uintptr(lpSecurityAttributes),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction CreateDirectoryFromAppW(
lpPathName: PWideChar; // LPCWSTR
lpSecurityAttributes: Pointer // SECURITY_ATTRIBUTES* optional
): BOOL; stdcall;
external 'api-ms-win-core-file-fromapp-l1-1-0.dll' name 'CreateDirectoryFromAppW';result := DllCall("api-ms-win-core-file-fromapp-l1-1-0\CreateDirectoryFromAppW"
, "WStr", lpPathName ; LPCWSTR
, "Ptr", lpSecurityAttributes ; SECURITY_ATTRIBUTES* optional
, "Int") ; return: BOOL●CreateDirectoryFromAppW(lpPathName, lpSecurityAttributes) = DLL("api-ms-win-core-file-fromapp-l1-1-0.dll", "bool CreateDirectoryFromAppW(char*, void*)")
# 呼び出し: CreateDirectoryFromAppW(lpPathName, lpSecurityAttributes)
# lpPathName : LPCWSTR -> "char*"
# lpSecurityAttributes : SECURITY_ATTRIBUTES* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。