ホーム › Web.InternetExplorer › IECreateDirectory
IECreateDirectory
関数IE保護モードでディレクトリを作成する。
シグネチャ
// Ieframe.dll
#include <windows.h>
BOOL IECreateDirectory(
LPCWSTR lpPathName,
SECURITY_ATTRIBUTES* lpSecurityAttributes
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| lpPathName | LPCWSTR | in | 作成するディレクトリのパスを指す文字列を指定する。 |
| lpSecurityAttributes | SECURITY_ATTRIBUTES* | in | ディレクトリのセキュリティ記述子を持つSECURITY_ATTRIBUTES構造体へのポインタ。NULL可。 |
戻り値の型: BOOL
各言語での呼び出し定義
// Ieframe.dll
#include <windows.h>
BOOL IECreateDirectory(
LPCWSTR lpPathName,
SECURITY_ATTRIBUTES* lpSecurityAttributes
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("Ieframe.dll", ExactSpelling = true)]
static extern bool IECreateDirectory(
[MarshalAs(UnmanagedType.LPWStr)] string lpPathName, // LPCWSTR
IntPtr lpSecurityAttributes // SECURITY_ATTRIBUTES*
);<DllImport("Ieframe.dll", ExactSpelling:=True)>
Public Shared Function IECreateDirectory(
<MarshalAs(UnmanagedType.LPWStr)> lpPathName As String, ' LPCWSTR
lpSecurityAttributes As IntPtr ' SECURITY_ATTRIBUTES*
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' lpPathName : LPCWSTR
' lpSecurityAttributes : SECURITY_ATTRIBUTES*
Declare PtrSafe Function IECreateDirectory Lib "ieframe" ( _
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
IECreateDirectory = ctypes.windll.ieframe.IECreateDirectory
IECreateDirectory.restype = wintypes.BOOL
IECreateDirectory.argtypes = [
wintypes.LPCWSTR, # lpPathName : LPCWSTR
ctypes.c_void_p, # lpSecurityAttributes : SECURITY_ATTRIBUTES*
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('Ieframe.dll')
IECreateDirectory = Fiddle::Function.new(
lib['IECreateDirectory'],
[
Fiddle::TYPE_VOIDP, # lpPathName : LPCWSTR
Fiddle::TYPE_VOIDP, # lpSecurityAttributes : SECURITY_ATTRIBUTES*
],
Fiddle::TYPE_INT)#[link(name = "ieframe")]
extern "system" {
fn IECreateDirectory(
lpPathName: *const u16, // LPCWSTR
lpSecurityAttributes: *mut SECURITY_ATTRIBUTES // SECURITY_ATTRIBUTES*
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("Ieframe.dll")]
public static extern bool IECreateDirectory([MarshalAs(UnmanagedType.LPWStr)] string lpPathName, IntPtr lpSecurityAttributes);
"@
$api = Add-Type -MemberDefinition $sig -Name 'Ieframe_IECreateDirectory' -Namespace Win32 -PassThru
# $api::IECreateDirectory(lpPathName, lpSecurityAttributes)#uselib "Ieframe.dll"
#func global IECreateDirectory "IECreateDirectory" sptr, sptr
; IECreateDirectory lpPathName, varptr(lpSecurityAttributes) ; 戻り値は stat
; lpPathName : LPCWSTR -> "sptr"
; lpSecurityAttributes : SECURITY_ATTRIBUTES* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "Ieframe.dll" #cfunc global IECreateDirectory "IECreateDirectory" wstr, var ; res = IECreateDirectory(lpPathName, lpSecurityAttributes) ; lpPathName : LPCWSTR -> "wstr" ; lpSecurityAttributes : SECURITY_ATTRIBUTES* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "Ieframe.dll" #cfunc global IECreateDirectory "IECreateDirectory" wstr, sptr ; res = IECreateDirectory(lpPathName, varptr(lpSecurityAttributes)) ; lpPathName : LPCWSTR -> "wstr" ; lpSecurityAttributes : SECURITY_ATTRIBUTES* -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL IECreateDirectory(LPCWSTR lpPathName, SECURITY_ATTRIBUTES* lpSecurityAttributes) #uselib "Ieframe.dll" #cfunc global IECreateDirectory "IECreateDirectory" wstr, var ; res = IECreateDirectory(lpPathName, lpSecurityAttributes) ; lpPathName : LPCWSTR -> "wstr" ; lpSecurityAttributes : SECURITY_ATTRIBUTES* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL IECreateDirectory(LPCWSTR lpPathName, SECURITY_ATTRIBUTES* lpSecurityAttributes) #uselib "Ieframe.dll" #cfunc global IECreateDirectory "IECreateDirectory" wstr, intptr ; res = IECreateDirectory(lpPathName, varptr(lpSecurityAttributes)) ; lpPathName : LPCWSTR -> "wstr" ; lpSecurityAttributes : SECURITY_ATTRIBUTES* -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
ieframe = windows.NewLazySystemDLL("Ieframe.dll")
procIECreateDirectory = ieframe.NewProc("IECreateDirectory")
)
// lpPathName (LPCWSTR), lpSecurityAttributes (SECURITY_ATTRIBUTES*)
r1, _, err := procIECreateDirectory.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpPathName))),
uintptr(lpSecurityAttributes),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction IECreateDirectory(
lpPathName: PWideChar; // LPCWSTR
lpSecurityAttributes: Pointer // SECURITY_ATTRIBUTES*
): BOOL; stdcall;
external 'Ieframe.dll' name 'IECreateDirectory';result := DllCall("Ieframe\IECreateDirectory"
, "WStr", lpPathName ; LPCWSTR
, "Ptr", lpSecurityAttributes ; SECURITY_ATTRIBUTES*
, "Int") ; return: BOOL●IECreateDirectory(lpPathName, lpSecurityAttributes) = DLL("Ieframe.dll", "bool IECreateDirectory(char*, void*)")
# 呼び出し: IECreateDirectory(lpPathName, lpSecurityAttributes)
# lpPathName : LPCWSTR -> "char*"
# lpSecurityAttributes : SECURITY_ATTRIBUTES* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "ieframe" fn IECreateDirectory(
lpPathName: [*c]const u16, // LPCWSTR
lpSecurityAttributes: [*c]SECURITY_ATTRIBUTES // SECURITY_ATTRIBUTES*
) callconv(std.os.windows.WINAPI) i32;proc IECreateDirectory(
lpPathName: WideCString, # LPCWSTR
lpSecurityAttributes: ptr SECURITY_ATTRIBUTES # SECURITY_ATTRIBUTES*
): int32 {.importc: "IECreateDirectory", stdcall, dynlib: "Ieframe.dll".}pragma(lib, "ieframe");
extern(Windows)
int IECreateDirectory(
const(wchar)* lpPathName, // LPCWSTR
SECURITY_ATTRIBUTES* lpSecurityAttributes // SECURITY_ATTRIBUTES*
);ccall((:IECreateDirectory, "Ieframe.dll"), stdcall, Int32,
(Cwstring, Ptr{SECURITY_ATTRIBUTES}),
lpPathName, lpSecurityAttributes)
# lpPathName : LPCWSTR -> Cwstring
# lpSecurityAttributes : SECURITY_ATTRIBUTES* -> Ptr{SECURITY_ATTRIBUTES}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t IECreateDirectory(
const uint16_t* lpPathName,
void* lpSecurityAttributes);
]]
local ieframe = ffi.load("ieframe")
-- ieframe.IECreateDirectory(lpPathName, lpSecurityAttributes)
-- lpPathName : LPCWSTR
-- lpSecurityAttributes : SECURITY_ATTRIBUTES*
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('Ieframe.dll');
const IECreateDirectory = lib.func('__stdcall', 'IECreateDirectory', 'int32_t', ['str16', 'void *']);
// IECreateDirectory(lpPathName, lpSecurityAttributes)
// lpPathName : LPCWSTR -> 'str16'
// lpSecurityAttributes : SECURITY_ATTRIBUTES* -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("Ieframe.dll", {
IECreateDirectory: { parameters: ["buffer", "pointer"], result: "i32" },
});
// lib.symbols.IECreateDirectory(lpPathName, lpSecurityAttributes)
// lpPathName : LPCWSTR -> "buffer"
// lpSecurityAttributes : SECURITY_ATTRIBUTES* -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t IECreateDirectory(
const uint16_t* lpPathName,
void* lpSecurityAttributes);
C, "Ieframe.dll");
// $ffi->IECreateDirectory(lpPathName, lpSecurityAttributes);
// lpPathName : LPCWSTR
// lpSecurityAttributes : SECURITY_ATTRIBUTES*
// 構造体/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 Ieframe extends StdCallLibrary {
Ieframe INSTANCE = Native.load("ieframe", Ieframe.class);
boolean IECreateDirectory(
WString lpPathName, // LPCWSTR
Pointer lpSecurityAttributes // SECURITY_ATTRIBUTES*
);
}@[Link("ieframe")]
lib LibIeframe
fun IECreateDirectory = IECreateDirectory(
lpPathName : UInt16*, # LPCWSTR
lpSecurityAttributes : SECURITY_ATTRIBUTES* # SECURITY_ATTRIBUTES*
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef IECreateDirectoryNative = Int32 Function(Pointer<Utf16>, Pointer<Void>);
typedef IECreateDirectoryDart = int Function(Pointer<Utf16>, Pointer<Void>);
final IECreateDirectory = DynamicLibrary.open('Ieframe.dll')
.lookupFunction<IECreateDirectoryNative, IECreateDirectoryDart>('IECreateDirectory');
// lpPathName : LPCWSTR -> Pointer<Utf16>
// lpSecurityAttributes : SECURITY_ATTRIBUTES* -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function IECreateDirectory(
lpPathName: PWideChar; // LPCWSTR
lpSecurityAttributes: Pointer // SECURITY_ATTRIBUTES*
): BOOL; stdcall;
external 'Ieframe.dll' name 'IECreateDirectory';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "IECreateDirectory"
c_IECreateDirectory :: CWString -> Ptr () -> IO CInt
-- lpPathName : LPCWSTR -> CWString
-- lpSecurityAttributes : SECURITY_ATTRIBUTES* -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let iecreatedirectory =
foreign "IECreateDirectory"
((ptr uint16_t) @-> (ptr void) @-> returning int32_t)
(* lpPathName : LPCWSTR -> (ptr uint16_t) *)
(* lpSecurityAttributes : SECURITY_ATTRIBUTES* -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library ieframe (t "Ieframe.dll"))
(cffi:use-foreign-library ieframe)
(cffi:defcfun ("IECreateDirectory" iecreate-directory :convention :stdcall) :int32
(lp-path-name (:string :encoding :utf-16le)) ; LPCWSTR
(lp-security-attributes :pointer)) ; SECURITY_ATTRIBUTES*
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $IECreateDirectory = Win32::API::More->new('Ieframe',
'BOOL IECreateDirectory(LPCWSTR lpPathName, LPVOID lpSecurityAttributes)');
# my $ret = $IECreateDirectory->Call($lpPathName, $lpSecurityAttributes);
# lpPathName : LPCWSTR -> LPCWSTR
# lpSecurityAttributes : SECURITY_ATTRIBUTES* -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。