ホーム › Networking.Clustering › ResUtilCreateDirectoryTree
ResUtilCreateDirectoryTree
関数指定パスのディレクトリ階層を作成する。
シグネチャ
// RESUTILS.dll
#include <windows.h>
DWORD ResUtilCreateDirectoryTree(
LPCWSTR pszPath
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pszPath | LPCWSTR | in | 作成するディレクトリツリーのパスを示すワイド文字列。中間階層も作成する。 |
戻り値の型: DWORD
各言語での呼び出し定義
// RESUTILS.dll
#include <windows.h>
DWORD ResUtilCreateDirectoryTree(
LPCWSTR pszPath
);[DllImport("RESUTILS.dll", ExactSpelling = true)]
static extern uint ResUtilCreateDirectoryTree(
[MarshalAs(UnmanagedType.LPWStr)] string pszPath // LPCWSTR
);<DllImport("RESUTILS.dll", ExactSpelling:=True)>
Public Shared Function ResUtilCreateDirectoryTree(
<MarshalAs(UnmanagedType.LPWStr)> pszPath As String ' LPCWSTR
) As UInteger
End Function' pszPath : LPCWSTR
Declare PtrSafe Function ResUtilCreateDirectoryTree Lib "resutils" ( _
ByVal pszPath As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ResUtilCreateDirectoryTree = ctypes.windll.resutils.ResUtilCreateDirectoryTree
ResUtilCreateDirectoryTree.restype = wintypes.DWORD
ResUtilCreateDirectoryTree.argtypes = [
wintypes.LPCWSTR, # pszPath : LPCWSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('RESUTILS.dll')
ResUtilCreateDirectoryTree = Fiddle::Function.new(
lib['ResUtilCreateDirectoryTree'],
[
Fiddle::TYPE_VOIDP, # pszPath : LPCWSTR
],
-Fiddle::TYPE_INT)#[link(name = "resutils")]
extern "system" {
fn ResUtilCreateDirectoryTree(
pszPath: *const u16 // LPCWSTR
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("RESUTILS.dll")]
public static extern uint ResUtilCreateDirectoryTree([MarshalAs(UnmanagedType.LPWStr)] string pszPath);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RESUTILS_ResUtilCreateDirectoryTree' -Namespace Win32 -PassThru
# $api::ResUtilCreateDirectoryTree(pszPath)#uselib "RESUTILS.dll"
#func global ResUtilCreateDirectoryTree "ResUtilCreateDirectoryTree" sptr
; ResUtilCreateDirectoryTree pszPath ; 戻り値は stat
; pszPath : LPCWSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "RESUTILS.dll"
#cfunc global ResUtilCreateDirectoryTree "ResUtilCreateDirectoryTree" wstr
; res = ResUtilCreateDirectoryTree(pszPath)
; pszPath : LPCWSTR -> "wstr"; DWORD ResUtilCreateDirectoryTree(LPCWSTR pszPath)
#uselib "RESUTILS.dll"
#cfunc global ResUtilCreateDirectoryTree "ResUtilCreateDirectoryTree" wstr
; res = ResUtilCreateDirectoryTree(pszPath)
; pszPath : LPCWSTR -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
resutils = windows.NewLazySystemDLL("RESUTILS.dll")
procResUtilCreateDirectoryTree = resutils.NewProc("ResUtilCreateDirectoryTree")
)
// pszPath (LPCWSTR)
r1, _, err := procResUtilCreateDirectoryTree.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszPath))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction ResUtilCreateDirectoryTree(
pszPath: PWideChar // LPCWSTR
): DWORD; stdcall;
external 'RESUTILS.dll' name 'ResUtilCreateDirectoryTree';result := DllCall("RESUTILS\ResUtilCreateDirectoryTree"
, "WStr", pszPath ; LPCWSTR
, "UInt") ; return: DWORD●ResUtilCreateDirectoryTree(pszPath) = DLL("RESUTILS.dll", "dword ResUtilCreateDirectoryTree(char*)")
# 呼び出し: ResUtilCreateDirectoryTree(pszPath)
# pszPath : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "resutils" fn ResUtilCreateDirectoryTree(
pszPath: [*c]const u16 // LPCWSTR
) callconv(std.os.windows.WINAPI) u32;proc ResUtilCreateDirectoryTree(
pszPath: WideCString # LPCWSTR
): uint32 {.importc: "ResUtilCreateDirectoryTree", stdcall, dynlib: "RESUTILS.dll".}pragma(lib, "resutils");
extern(Windows)
uint ResUtilCreateDirectoryTree(
const(wchar)* pszPath // LPCWSTR
);ccall((:ResUtilCreateDirectoryTree, "RESUTILS.dll"), stdcall, UInt32,
(Cwstring,),
pszPath)
# pszPath : LPCWSTR -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t ResUtilCreateDirectoryTree(
const uint16_t* pszPath);
]]
local resutils = ffi.load("resutils")
-- resutils.ResUtilCreateDirectoryTree(pszPath)
-- pszPath : LPCWSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('RESUTILS.dll');
const ResUtilCreateDirectoryTree = lib.func('__stdcall', 'ResUtilCreateDirectoryTree', 'uint32_t', ['str16']);
// ResUtilCreateDirectoryTree(pszPath)
// pszPath : LPCWSTR -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("RESUTILS.dll", {
ResUtilCreateDirectoryTree: { parameters: ["buffer"], result: "u32" },
});
// lib.symbols.ResUtilCreateDirectoryTree(pszPath)
// pszPath : LPCWSTR -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t ResUtilCreateDirectoryTree(
const uint16_t* pszPath);
C, "RESUTILS.dll");
// $ffi->ResUtilCreateDirectoryTree(pszPath);
// pszPath : LPCWSTR
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Resutils extends StdCallLibrary {
Resutils INSTANCE = Native.load("resutils", Resutils.class);
int ResUtilCreateDirectoryTree(
WString pszPath // LPCWSTR
);
}@[Link("resutils")]
lib LibRESUTILS
fun ResUtilCreateDirectoryTree = ResUtilCreateDirectoryTree(
pszPath : UInt16* # LPCWSTR
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef ResUtilCreateDirectoryTreeNative = Uint32 Function(Pointer<Utf16>);
typedef ResUtilCreateDirectoryTreeDart = int Function(Pointer<Utf16>);
final ResUtilCreateDirectoryTree = DynamicLibrary.open('RESUTILS.dll')
.lookupFunction<ResUtilCreateDirectoryTreeNative, ResUtilCreateDirectoryTreeDart>('ResUtilCreateDirectoryTree');
// pszPath : LPCWSTR -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function ResUtilCreateDirectoryTree(
pszPath: PWideChar // LPCWSTR
): DWORD; stdcall;
external 'RESUTILS.dll' name 'ResUtilCreateDirectoryTree';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "ResUtilCreateDirectoryTree"
c_ResUtilCreateDirectoryTree :: CWString -> IO Word32
-- pszPath : LPCWSTR -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let resutilcreatedirectorytree =
foreign "ResUtilCreateDirectoryTree"
((ptr uint16_t) @-> returning uint32_t)
(* pszPath : LPCWSTR -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library resutils (t "RESUTILS.dll"))
(cffi:use-foreign-library resutils)
(cffi:defcfun ("ResUtilCreateDirectoryTree" res-util-create-directory-tree :convention :stdcall) :uint32
(psz-path (:string :encoding :utf-16le))) ; LPCWSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ResUtilCreateDirectoryTree = Win32::API::More->new('RESUTILS',
'DWORD ResUtilCreateDirectoryTree(LPCWSTR pszPath)');
# my $ret = $ResUtilCreateDirectoryTree->Call($pszPath);
# pszPath : LPCWSTR -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。