Win32 API 日本語リファレンス
ホームSystem.Diagnostics.Debug › MakeSureDirectoryPathExists

MakeSureDirectoryPathExists

関数
指定したディレクトリパスの全階層を作成する。
DLLdbghelp.dll呼出規約winapiSetLastErrorあり

シグネチャ

// dbghelp.dll
#include <windows.h>

BOOL MakeSureDirectoryPathExists(
    LPCSTR DirPath
);

パラメーター

名前方向
DirPathLPCSTRin

戻り値の型: BOOL

各言語での呼び出し定義

// dbghelp.dll
#include <windows.h>

BOOL MakeSureDirectoryPathExists(
    LPCSTR DirPath
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("dbghelp.dll", SetLastError = true, ExactSpelling = true)]
static extern bool MakeSureDirectoryPathExists(
    [MarshalAs(UnmanagedType.LPStr)] string DirPath   // LPCSTR
);
<DllImport("dbghelp.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function MakeSureDirectoryPathExists(
    <MarshalAs(UnmanagedType.LPStr)> DirPath As String   ' LPCSTR
) As Boolean
End Function
' DirPath : LPCSTR
Declare PtrSafe Function MakeSureDirectoryPathExists Lib "dbghelp" ( _
    ByVal DirPath As String) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

MakeSureDirectoryPathExists = ctypes.windll.dbghelp.MakeSureDirectoryPathExists
MakeSureDirectoryPathExists.restype = wintypes.BOOL
MakeSureDirectoryPathExists.argtypes = [
    wintypes.LPCSTR,  # DirPath : LPCSTR
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('dbghelp.dll')
MakeSureDirectoryPathExists = Fiddle::Function.new(
  lib['MakeSureDirectoryPathExists'],
  [
    Fiddle::TYPE_VOIDP,  # DirPath : LPCSTR
  ],
  Fiddle::TYPE_INT)
#[link(name = "dbghelp")]
extern "system" {
    fn MakeSureDirectoryPathExists(
        DirPath: *const u8  // LPCSTR
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("dbghelp.dll", SetLastError = true)]
public static extern bool MakeSureDirectoryPathExists([MarshalAs(UnmanagedType.LPStr)] string DirPath);
"@
$api = Add-Type -MemberDefinition $sig -Name 'dbghelp_MakeSureDirectoryPathExists' -Namespace Win32 -PassThru
# $api::MakeSureDirectoryPathExists(DirPath)
#uselib "dbghelp.dll"
#func global MakeSureDirectoryPathExists "MakeSureDirectoryPathExists" sptr
; MakeSureDirectoryPathExists DirPath   ; 戻り値は stat
; DirPath : LPCSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "dbghelp.dll"
#cfunc global MakeSureDirectoryPathExists "MakeSureDirectoryPathExists" str
; res = MakeSureDirectoryPathExists(DirPath)
; DirPath : LPCSTR -> "str"
; BOOL MakeSureDirectoryPathExists(LPCSTR DirPath)
#uselib "dbghelp.dll"
#cfunc global MakeSureDirectoryPathExists "MakeSureDirectoryPathExists" str
; res = MakeSureDirectoryPathExists(DirPath)
; DirPath : LPCSTR -> "str"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	dbghelp = windows.NewLazySystemDLL("dbghelp.dll")
	procMakeSureDirectoryPathExists = dbghelp.NewProc("MakeSureDirectoryPathExists")
)

// DirPath (LPCSTR)
r1, _, err := procMakeSureDirectoryPathExists.Call(
	uintptr(unsafe.Pointer(windows.BytePtrFromString(DirPath))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function MakeSureDirectoryPathExists(
  DirPath: PAnsiChar   // LPCSTR
): BOOL; stdcall;
  external 'dbghelp.dll' name 'MakeSureDirectoryPathExists';
result := DllCall("dbghelp\MakeSureDirectoryPathExists"
    , "AStr", DirPath   ; LPCSTR
    , "Int")   ; return: BOOL
●MakeSureDirectoryPathExists(DirPath) = DLL("dbghelp.dll", "bool MakeSureDirectoryPathExists(char*)")
# 呼び出し: MakeSureDirectoryPathExists(DirPath)
# DirPath : LPCSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。