Win32 API 日本語リファレンス
ホームStorage.FileSystem › CreateResourceManager

CreateResourceManager

関数
KTMリソースマネージャーを新規作成する。
DLLktmw32.dll呼出規約winapiSetLastErrorあり対応OSWindows Vista 以降

シグネチャ

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

HANDLE CreateResourceManager(
    SECURITY_ATTRIBUTES* lpResourceManagerAttributes,
    GUID* ResourceManagerId,
    DWORD CreateOptions,
    HANDLE TmHandle,
    LPWSTR Description   // optional
);

パラメーター

名前方向
lpResourceManagerAttributesSECURITY_ATTRIBUTES*inout
ResourceManagerIdGUID*inout
CreateOptionsDWORDin
TmHandleHANDLEin
DescriptionLPWSTRinoptional

戻り値の型: HANDLE

各言語での呼び出し定義

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

HANDLE CreateResourceManager(
    SECURITY_ATTRIBUTES* lpResourceManagerAttributes,
    GUID* ResourceManagerId,
    DWORD CreateOptions,
    HANDLE TmHandle,
    LPWSTR Description   // optional
);
[DllImport("ktmw32.dll", SetLastError = true, ExactSpelling = true)]
static extern IntPtr CreateResourceManager(
    IntPtr lpResourceManagerAttributes,   // SECURITY_ATTRIBUTES* in/out
    ref Guid ResourceManagerId,   // GUID* in/out
    uint CreateOptions,   // DWORD
    IntPtr TmHandle,   // HANDLE
    [MarshalAs(UnmanagedType.LPWStr)] string Description   // LPWSTR optional
);
<DllImport("ktmw32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function CreateResourceManager(
    lpResourceManagerAttributes As IntPtr,   ' SECURITY_ATTRIBUTES* in/out
    ByRef ResourceManagerId As Guid,   ' GUID* in/out
    CreateOptions As UInteger,   ' DWORD
    TmHandle As IntPtr,   ' HANDLE
    <MarshalAs(UnmanagedType.LPWStr)> Description As String   ' LPWSTR optional
) As IntPtr
End Function
' lpResourceManagerAttributes : SECURITY_ATTRIBUTES* in/out
' ResourceManagerId : GUID* in/out
' CreateOptions : DWORD
' TmHandle : HANDLE
' Description : LPWSTR optional
Declare PtrSafe Function CreateResourceManager Lib "ktmw32" ( _
    ByVal lpResourceManagerAttributes As LongPtr, _
    ByVal ResourceManagerId As LongPtr, _
    ByVal CreateOptions As Long, _
    ByVal TmHandle As LongPtr, _
    ByVal Description As LongPtr) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CreateResourceManager = ctypes.windll.ktmw32.CreateResourceManager
CreateResourceManager.restype = ctypes.c_void_p
CreateResourceManager.argtypes = [
    ctypes.c_void_p,  # lpResourceManagerAttributes : SECURITY_ATTRIBUTES* in/out
    ctypes.c_void_p,  # ResourceManagerId : GUID* in/out
    wintypes.DWORD,  # CreateOptions : DWORD
    wintypes.HANDLE,  # TmHandle : HANDLE
    wintypes.LPCWSTR,  # Description : LPWSTR optional
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('ktmw32.dll')
CreateResourceManager = Fiddle::Function.new(
  lib['CreateResourceManager'],
  [
    Fiddle::TYPE_VOIDP,  # lpResourceManagerAttributes : SECURITY_ATTRIBUTES* in/out
    Fiddle::TYPE_VOIDP,  # ResourceManagerId : GUID* in/out
    -Fiddle::TYPE_INT,  # CreateOptions : DWORD
    Fiddle::TYPE_VOIDP,  # TmHandle : HANDLE
    Fiddle::TYPE_VOIDP,  # Description : LPWSTR optional
  ],
  Fiddle::TYPE_VOIDP)
#[link(name = "ktmw32")]
extern "system" {
    fn CreateResourceManager(
        lpResourceManagerAttributes: *mut SECURITY_ATTRIBUTES,  // SECURITY_ATTRIBUTES* in/out
        ResourceManagerId: *mut GUID,  // GUID* in/out
        CreateOptions: u32,  // DWORD
        TmHandle: *mut core::ffi::c_void,  // HANDLE
        Description: *mut u16  // LPWSTR optional
    ) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("ktmw32.dll", SetLastError = true)]
public static extern IntPtr CreateResourceManager(IntPtr lpResourceManagerAttributes, ref Guid ResourceManagerId, uint CreateOptions, IntPtr TmHandle, [MarshalAs(UnmanagedType.LPWStr)] string Description);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ktmw32_CreateResourceManager' -Namespace Win32 -PassThru
# $api::CreateResourceManager(lpResourceManagerAttributes, ResourceManagerId, CreateOptions, TmHandle, Description)
#uselib "ktmw32.dll"
#func global CreateResourceManager "CreateResourceManager" sptr, sptr, sptr, sptr, sptr
; CreateResourceManager varptr(lpResourceManagerAttributes), varptr(ResourceManagerId), CreateOptions, TmHandle, Description   ; 戻り値は stat
; lpResourceManagerAttributes : SECURITY_ATTRIBUTES* in/out -> "sptr"
; ResourceManagerId : GUID* in/out -> "sptr"
; CreateOptions : DWORD -> "sptr"
; TmHandle : HANDLE -> "sptr"
; Description : LPWSTR optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "ktmw32.dll"
#cfunc global CreateResourceManager "CreateResourceManager" var, var, int, sptr, wstr
; res = CreateResourceManager(lpResourceManagerAttributes, ResourceManagerId, CreateOptions, TmHandle, Description)
; lpResourceManagerAttributes : SECURITY_ATTRIBUTES* in/out -> "var"
; ResourceManagerId : GUID* in/out -> "var"
; CreateOptions : DWORD -> "int"
; TmHandle : HANDLE -> "sptr"
; Description : LPWSTR optional -> "wstr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HANDLE CreateResourceManager(SECURITY_ATTRIBUTES* lpResourceManagerAttributes, GUID* ResourceManagerId, DWORD CreateOptions, HANDLE TmHandle, LPWSTR Description)
#uselib "ktmw32.dll"
#cfunc global CreateResourceManager "CreateResourceManager" var, var, int, intptr, wstr
; res = CreateResourceManager(lpResourceManagerAttributes, ResourceManagerId, CreateOptions, TmHandle, Description)
; lpResourceManagerAttributes : SECURITY_ATTRIBUTES* in/out -> "var"
; ResourceManagerId : GUID* in/out -> "var"
; CreateOptions : DWORD -> "int"
; TmHandle : HANDLE -> "intptr"
; Description : LPWSTR optional -> "wstr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	ktmw32 = windows.NewLazySystemDLL("ktmw32.dll")
	procCreateResourceManager = ktmw32.NewProc("CreateResourceManager")
)

// lpResourceManagerAttributes (SECURITY_ATTRIBUTES* in/out), ResourceManagerId (GUID* in/out), CreateOptions (DWORD), TmHandle (HANDLE), Description (LPWSTR optional)
r1, _, err := procCreateResourceManager.Call(
	uintptr(lpResourceManagerAttributes),
	uintptr(ResourceManagerId),
	uintptr(CreateOptions),
	uintptr(TmHandle),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(Description))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HANDLE
function CreateResourceManager(
  lpResourceManagerAttributes: Pointer;   // SECURITY_ATTRIBUTES* in/out
  ResourceManagerId: PGUID;   // GUID* in/out
  CreateOptions: DWORD;   // DWORD
  TmHandle: THandle;   // HANDLE
  Description: PWideChar   // LPWSTR optional
): THandle; stdcall;
  external 'ktmw32.dll' name 'CreateResourceManager';
result := DllCall("ktmw32\CreateResourceManager"
    , "Ptr", lpResourceManagerAttributes   ; SECURITY_ATTRIBUTES* in/out
    , "Ptr", ResourceManagerId   ; GUID* in/out
    , "UInt", CreateOptions   ; DWORD
    , "Ptr", TmHandle   ; HANDLE
    , "WStr", Description   ; LPWSTR optional
    , "Ptr")   ; return: HANDLE
●CreateResourceManager(lpResourceManagerAttributes, ResourceManagerId, CreateOptions, TmHandle, Description) = DLL("ktmw32.dll", "void* CreateResourceManager(void*, void*, dword, void*, char*)")
# 呼び出し: CreateResourceManager(lpResourceManagerAttributes, ResourceManagerId, CreateOptions, TmHandle, Description)
# lpResourceManagerAttributes : SECURITY_ATTRIBUTES* in/out -> "void*"
# ResourceManagerId : GUID* in/out -> "void*"
# CreateOptions : DWORD -> "dword"
# TmHandle : HANDLE -> "void*"
# Description : LPWSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。