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