SHCreateDirectory
関数指定パスのディレクトリ階層を作成する。
シグネチャ
// SHELL32.dll
#include <windows.h>
INT SHCreateDirectory(
HWND hwnd, // optional
LPCWSTR pszPath
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hwnd | HWND | inoptional |
| pszPath | LPCWSTR | in |
戻り値の型: INT
各言語での呼び出し定義
// SHELL32.dll
#include <windows.h>
INT SHCreateDirectory(
HWND hwnd, // optional
LPCWSTR pszPath
);[DllImport("SHELL32.dll", ExactSpelling = true)]
static extern int SHCreateDirectory(
IntPtr hwnd, // HWND optional
[MarshalAs(UnmanagedType.LPWStr)] string pszPath // LPCWSTR
);<DllImport("SHELL32.dll", ExactSpelling:=True)>
Public Shared Function SHCreateDirectory(
hwnd As IntPtr, ' HWND optional
<MarshalAs(UnmanagedType.LPWStr)> pszPath As String ' LPCWSTR
) As Integer
End Function' hwnd : HWND optional
' pszPath : LPCWSTR
Declare PtrSafe Function SHCreateDirectory Lib "shell32" ( _
ByVal hwnd As LongPtr, _
ByVal pszPath As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SHCreateDirectory = ctypes.windll.shell32.SHCreateDirectory
SHCreateDirectory.restype = ctypes.c_int
SHCreateDirectory.argtypes = [
wintypes.HANDLE, # hwnd : HWND optional
wintypes.LPCWSTR, # pszPath : LPCWSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SHELL32.dll')
SHCreateDirectory = Fiddle::Function.new(
lib['SHCreateDirectory'],
[
Fiddle::TYPE_VOIDP, # hwnd : HWND optional
Fiddle::TYPE_VOIDP, # pszPath : LPCWSTR
],
Fiddle::TYPE_INT)#[link(name = "shell32")]
extern "system" {
fn SHCreateDirectory(
hwnd: *mut core::ffi::c_void, // HWND optional
pszPath: *const u16 // LPCWSTR
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("SHELL32.dll")]
public static extern int SHCreateDirectory(IntPtr hwnd, [MarshalAs(UnmanagedType.LPWStr)] string pszPath);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHELL32_SHCreateDirectory' -Namespace Win32 -PassThru
# $api::SHCreateDirectory(hwnd, pszPath)#uselib "SHELL32.dll"
#func global SHCreateDirectory "SHCreateDirectory" sptr, sptr
; SHCreateDirectory hwnd, pszPath ; 戻り値は stat
; hwnd : HWND optional -> "sptr"
; pszPath : LPCWSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "SHELL32.dll"
#cfunc global SHCreateDirectory "SHCreateDirectory" sptr, wstr
; res = SHCreateDirectory(hwnd, pszPath)
; hwnd : HWND optional -> "sptr"
; pszPath : LPCWSTR -> "wstr"; INT SHCreateDirectory(HWND hwnd, LPCWSTR pszPath)
#uselib "SHELL32.dll"
#cfunc global SHCreateDirectory "SHCreateDirectory" intptr, wstr
; res = SHCreateDirectory(hwnd, pszPath)
; hwnd : HWND optional -> "intptr"
; pszPath : LPCWSTR -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
shell32 = windows.NewLazySystemDLL("SHELL32.dll")
procSHCreateDirectory = shell32.NewProc("SHCreateDirectory")
)
// hwnd (HWND optional), pszPath (LPCWSTR)
r1, _, err := procSHCreateDirectory.Call(
uintptr(hwnd),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszPath))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction SHCreateDirectory(
hwnd: THandle; // HWND optional
pszPath: PWideChar // LPCWSTR
): Integer; stdcall;
external 'SHELL32.dll' name 'SHCreateDirectory';result := DllCall("SHELL32\SHCreateDirectory"
, "Ptr", hwnd ; HWND optional
, "WStr", pszPath ; LPCWSTR
, "Int") ; return: INT●SHCreateDirectory(hwnd, pszPath) = DLL("SHELL32.dll", "int SHCreateDirectory(void*, char*)")
# 呼び出し: SHCreateDirectory(hwnd, pszPath)
# hwnd : HWND optional -> "void*"
# pszPath : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。