Win32 API 日本語リファレンス
ホームUI.WindowsAndMessaging › CreateResourceIndexer

CreateResourceIndexer

関数
MRMリソースインデクサを作成する。
DLLMrmSupport.dll呼出規約winapi対応OSWindows 10 以降

シグネチャ

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

HRESULT CreateResourceIndexer(
    LPCWSTR projectRoot,
    LPCWSTR extensionDllPath,   // optional
    void** ppResourceIndexer
);

パラメーター

名前方向説明
projectRootLPCWSTRin生成するファイルのプロジェクトに使用するルートフォルダーのパス(文字列形式)。このパスは、ファイルを含むパッケージからの相対ファイルパスを判別するために使用されます。このパスは、ドライブレターを指定した絶対パスである必要があります。長いファイルパスはサポートされません。
extensionDllPathLPCWSTRinoptionalMicrosoft によって署名され、ext-ms-win-mrmcorer-environment-l1 API セットを実装する拡張ダイナミックリンクライブラリ (DLL) のフルパス。このパスは、モダンリソーステクノロジ (MRT) 環境用の拡張 DLL を読み込むファイルパスを決定します。このパスは、ドライブレターを指定した絶対パスである必要があります。長いファイルパスはサポートされません。
ppResourceIndexervoid**out新しく作成されたリソースインデクサー。

戻り値の型: HRESULT

公式ドキュメント

プロジェクトファイルのルートと拡張 DLL について指定されたパスに対する、新しいリソースインデクサーを作成します。

戻り値

この関数が成功した場合は S_OK を返します。それ以外の場合は HRESULT エラーコードを返します。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

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

HRESULT CreateResourceIndexer(
    LPCWSTR projectRoot,
    LPCWSTR extensionDllPath,   // optional
    void** ppResourceIndexer
);
[DllImport("MrmSupport.dll", ExactSpelling = true)]
static extern int CreateResourceIndexer(
    [MarshalAs(UnmanagedType.LPWStr)] string projectRoot,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string extensionDllPath,   // LPCWSTR optional
    IntPtr ppResourceIndexer   // void** out
);
<DllImport("MrmSupport.dll", ExactSpelling:=True)>
Public Shared Function CreateResourceIndexer(
    <MarshalAs(UnmanagedType.LPWStr)> projectRoot As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> extensionDllPath As String,   ' LPCWSTR optional
    ppResourceIndexer As IntPtr   ' void** out
) As Integer
End Function
' projectRoot : LPCWSTR
' extensionDllPath : LPCWSTR optional
' ppResourceIndexer : void** out
Declare PtrSafe Function CreateResourceIndexer Lib "mrmsupport" ( _
    ByVal projectRoot As LongPtr, _
    ByVal extensionDllPath As LongPtr, _
    ByVal ppResourceIndexer As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CreateResourceIndexer = ctypes.windll.mrmsupport.CreateResourceIndexer
CreateResourceIndexer.restype = ctypes.c_int
CreateResourceIndexer.argtypes = [
    wintypes.LPCWSTR,  # projectRoot : LPCWSTR
    wintypes.LPCWSTR,  # extensionDllPath : LPCWSTR optional
    ctypes.c_void_p,  # ppResourceIndexer : void** out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('MrmSupport.dll')
CreateResourceIndexer = Fiddle::Function.new(
  lib['CreateResourceIndexer'],
  [
    Fiddle::TYPE_VOIDP,  # projectRoot : LPCWSTR
    Fiddle::TYPE_VOIDP,  # extensionDllPath : LPCWSTR optional
    Fiddle::TYPE_VOIDP,  # ppResourceIndexer : void** out
  ],
  Fiddle::TYPE_INT)
#[link(name = "mrmsupport")]
extern "system" {
    fn CreateResourceIndexer(
        projectRoot: *const u16,  // LPCWSTR
        extensionDllPath: *const u16,  // LPCWSTR optional
        ppResourceIndexer: *mut *mut ()  // void** out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("MrmSupport.dll")]
public static extern int CreateResourceIndexer([MarshalAs(UnmanagedType.LPWStr)] string projectRoot, [MarshalAs(UnmanagedType.LPWStr)] string extensionDllPath, IntPtr ppResourceIndexer);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MrmSupport_CreateResourceIndexer' -Namespace Win32 -PassThru
# $api::CreateResourceIndexer(projectRoot, extensionDllPath, ppResourceIndexer)
#uselib "MrmSupport.dll"
#func global CreateResourceIndexer "CreateResourceIndexer" sptr, sptr, sptr
; CreateResourceIndexer projectRoot, extensionDllPath, ppResourceIndexer   ; 戻り値は stat
; projectRoot : LPCWSTR -> "sptr"
; extensionDllPath : LPCWSTR optional -> "sptr"
; ppResourceIndexer : void** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "MrmSupport.dll"
#cfunc global CreateResourceIndexer "CreateResourceIndexer" wstr, wstr, sptr
; res = CreateResourceIndexer(projectRoot, extensionDllPath, ppResourceIndexer)
; projectRoot : LPCWSTR -> "wstr"
; extensionDllPath : LPCWSTR optional -> "wstr"
; ppResourceIndexer : void** out -> "sptr"
; HRESULT CreateResourceIndexer(LPCWSTR projectRoot, LPCWSTR extensionDllPath, void** ppResourceIndexer)
#uselib "MrmSupport.dll"
#cfunc global CreateResourceIndexer "CreateResourceIndexer" wstr, wstr, intptr
; res = CreateResourceIndexer(projectRoot, extensionDllPath, ppResourceIndexer)
; projectRoot : LPCWSTR -> "wstr"
; extensionDllPath : LPCWSTR optional -> "wstr"
; ppResourceIndexer : void** out -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	mrmsupport = windows.NewLazySystemDLL("MrmSupport.dll")
	procCreateResourceIndexer = mrmsupport.NewProc("CreateResourceIndexer")
)

// projectRoot (LPCWSTR), extensionDllPath (LPCWSTR optional), ppResourceIndexer (void** out)
r1, _, err := procCreateResourceIndexer.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(projectRoot))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(extensionDllPath))),
	uintptr(ppResourceIndexer),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function CreateResourceIndexer(
  projectRoot: PWideChar;   // LPCWSTR
  extensionDllPath: PWideChar;   // LPCWSTR optional
  ppResourceIndexer: Pointer   // void** out
): Integer; stdcall;
  external 'MrmSupport.dll' name 'CreateResourceIndexer';
result := DllCall("MrmSupport\CreateResourceIndexer"
    , "WStr", projectRoot   ; LPCWSTR
    , "WStr", extensionDllPath   ; LPCWSTR optional
    , "Ptr", ppResourceIndexer   ; void** out
    , "Int")   ; return: HRESULT
●CreateResourceIndexer(projectRoot, extensionDllPath, ppResourceIndexer) = DLL("MrmSupport.dll", "int CreateResourceIndexer(char*, char*, void*)")
# 呼び出し: CreateResourceIndexer(projectRoot, extensionDllPath, ppResourceIndexer)
# projectRoot : LPCWSTR -> "char*"
# extensionDllPath : LPCWSTR optional -> "char*"
# ppResourceIndexer : void** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "mrmsupport" fn CreateResourceIndexer(
    projectRoot: [*c]const u16, // LPCWSTR
    extensionDllPath: [*c]const u16, // LPCWSTR optional
    ppResourceIndexer: ?*anyopaque // void** out
) callconv(std.os.windows.WINAPI) i32;
proc CreateResourceIndexer(
    projectRoot: WideCString,  # LPCWSTR
    extensionDllPath: WideCString,  # LPCWSTR optional
    ppResourceIndexer: pointer  # void** out
): int32 {.importc: "CreateResourceIndexer", stdcall, dynlib: "MrmSupport.dll".}
pragma(lib, "mrmsupport");
extern(Windows)
int CreateResourceIndexer(
    const(wchar)* projectRoot,   // LPCWSTR
    const(wchar)* extensionDllPath,   // LPCWSTR optional
    void** ppResourceIndexer   // void** out
);
ccall((:CreateResourceIndexer, "MrmSupport.dll"), stdcall, Int32,
      (Cwstring, Cwstring, Ptr{Cvoid}),
      projectRoot, extensionDllPath, ppResourceIndexer)
# projectRoot : LPCWSTR -> Cwstring
# extensionDllPath : LPCWSTR optional -> Cwstring
# ppResourceIndexer : void** out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t CreateResourceIndexer(
    const uint16_t* projectRoot,
    const uint16_t* extensionDllPath,
    void** ppResourceIndexer);
]]
local mrmsupport = ffi.load("mrmsupport")
-- mrmsupport.CreateResourceIndexer(projectRoot, extensionDllPath, ppResourceIndexer)
-- projectRoot : LPCWSTR
-- extensionDllPath : LPCWSTR optional
-- ppResourceIndexer : void** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('MrmSupport.dll');
const CreateResourceIndexer = lib.func('__stdcall', 'CreateResourceIndexer', 'int32_t', ['str16', 'str16', 'void *']);
// CreateResourceIndexer(projectRoot, extensionDllPath, ppResourceIndexer)
// projectRoot : LPCWSTR -> 'str16'
// extensionDllPath : LPCWSTR optional -> 'str16'
// ppResourceIndexer : void** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("MrmSupport.dll", {
  CreateResourceIndexer: { parameters: ["buffer", "buffer", "pointer"], result: "i32" },
});
// lib.symbols.CreateResourceIndexer(projectRoot, extensionDllPath, ppResourceIndexer)
// projectRoot : LPCWSTR -> "buffer"
// extensionDllPath : LPCWSTR optional -> "buffer"
// ppResourceIndexer : void** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t CreateResourceIndexer(
    const uint16_t* projectRoot,
    const uint16_t* extensionDllPath,
    void** ppResourceIndexer);
C, "MrmSupport.dll");
// $ffi->CreateResourceIndexer(projectRoot, extensionDllPath, ppResourceIndexer);
// projectRoot : LPCWSTR
// extensionDllPath : LPCWSTR optional
// ppResourceIndexer : void** out
// 構造体/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 Mrmsupport extends StdCallLibrary {
    Mrmsupport INSTANCE = Native.load("mrmsupport", Mrmsupport.class);
    int CreateResourceIndexer(
        WString projectRoot,   // LPCWSTR
        WString extensionDllPath,   // LPCWSTR optional
        Pointer ppResourceIndexer   // void** out
    );
}
@[Link("mrmsupport")]
lib LibMrmSupport
  fun CreateResourceIndexer = CreateResourceIndexer(
    projectRoot : UInt16*,   # LPCWSTR
    extensionDllPath : UInt16*,   # LPCWSTR optional
    ppResourceIndexer : Void**   # void** out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef CreateResourceIndexerNative = Int32 Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Void>);
typedef CreateResourceIndexerDart = int Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Void>);
final CreateResourceIndexer = DynamicLibrary.open('MrmSupport.dll')
    .lookupFunction<CreateResourceIndexerNative, CreateResourceIndexerDart>('CreateResourceIndexer');
// projectRoot : LPCWSTR -> Pointer<Utf16>
// extensionDllPath : LPCWSTR optional -> Pointer<Utf16>
// ppResourceIndexer : void** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function CreateResourceIndexer(
  projectRoot: PWideChar;   // LPCWSTR
  extensionDllPath: PWideChar;   // LPCWSTR optional
  ppResourceIndexer: Pointer   // void** out
): Integer; stdcall;
  external 'MrmSupport.dll' name 'CreateResourceIndexer';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "CreateResourceIndexer"
  c_CreateResourceIndexer :: CWString -> CWString -> Ptr () -> IO Int32
-- projectRoot : LPCWSTR -> CWString
-- extensionDllPath : LPCWSTR optional -> CWString
-- ppResourceIndexer : void** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let createresourceindexer =
  foreign "CreateResourceIndexer"
    ((ptr uint16_t) @-> (ptr uint16_t) @-> (ptr void) @-> returning int32_t)
(* projectRoot : LPCWSTR -> (ptr uint16_t) *)
(* extensionDllPath : LPCWSTR optional -> (ptr uint16_t) *)
(* ppResourceIndexer : void** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library mrmsupport (t "MrmSupport.dll"))
(cffi:use-foreign-library mrmsupport)

(cffi:defcfun ("CreateResourceIndexer" create-resource-indexer :convention :stdcall) :int32
  (project-root (:string :encoding :utf-16le))   ; LPCWSTR
  (extension-dll-path (:string :encoding :utf-16le))   ; LPCWSTR optional
  (pp-resource-indexer :pointer))   ; void** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $CreateResourceIndexer = Win32::API::More->new('MrmSupport',
    'int CreateResourceIndexer(LPCWSTR projectRoot, LPCWSTR extensionDllPath, LPVOID ppResourceIndexer)');
# my $ret = $CreateResourceIndexer->Call($projectRoot, $extensionDllPath, $ppResourceIndexer);
# projectRoot : LPCWSTR -> LPCWSTR
# extensionDllPath : LPCWSTR optional -> LPCWSTR
# ppResourceIndexer : void** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

公式の関連項目