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

MrmIndexFileAutoQualifiers

関数
修飾子を自動判定してファイルをインデックス化する。
DLLMrmSupport.dll呼出規約winapi

シグネチャ

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

HRESULT MrmIndexFileAutoQualifiers(
    MrmResourceIndexerHandle indexer,
    LPCWSTR filePath   // optional
);

パラメーター

名前型方向説明
indexerMrmResourceIndexerHandlein使用するリソースインデクサのハンドル。
filePathLPCWSTRinoptionalインデックス登録するファイルのパス。修飾子はパスから自動推論される。

戻り値の型: HRESULT

公式ドキュメント

ファイル リソースを Resource Indexer に追加します。リソース名と修飾子はファイル パスから推測されます。

戻り値

型: HRESULT

関数が成功した場合は S_OK、それ以外の場合はそれ以外の値が返されます。成功したか失敗したかを判断するには、winerror.h で定義されている SUCCEEDED マクロまたは FAILED マクロを使用してください。

なお、filePath パラメーターに無効な値を渡した場合でも、この関数が成功することがあります。その場合、エラーは MrmCreateResourceFile または関連する関数で PRI ファイルを作成しようとしたときに 0x8007000B (HRESULT_FROM_WIN32(ERROR_BAD_FORMAT)) として報告されます。詳細については Remarks を参照してください。

解説(Remarks)

この関数は MrmIndexFile と同等ですが、resourceUri パラメーターと qualifiers パラメーターが filePath 引数から推測される点が異なります。path1\path2\pathn\filename という形式の filePath が指定された場合、次の基本的なアルゴリズムが使用されます。

  1. resourceName を文字列 ms-resource:///Files/ とします。
  2. qualifiers を空の文字列とします。
  3. filePath 内の各 path セグメントについて、それが有効な修飾子リスト文字列で構成されているかどうかを確認します (詳細については MRM における修飾子 を参照してください)。構成されている場合は、それらの修飾子を qualifiers に追加し、そうでない場合は resourceName に追加します。
  4. filename については、ドット (.) で区切られたセグメントに分割します。
  5. 各セグメントについて、有効な修飾子リストであれば qualifiers に追加し、そうでなければ resourceName に追加します。
  6. MrmIndexFile(indexer, resourceName, filePath, qualifiers) と同等の処理を呼び出します。

例:

filePath resourecName qualifiers
Assets\language-en\scale-200\logo.png ms-resource:///files/Assets/logo.png language-en_scale-200
Images\icon.scale-100.contrast-high.jpg ms-resource:///files/Images/icon.jpg scale-100_contrast-high
Data\menu.txt ms-resource:///files/Data/menu.txt <N/A>
Images\scale-200\HomePage\language-de\welcome.contrast-high.png ms-resource:///files/Images/HomePage/welcome.png scale-200_language-de_contrast-high

なお、指定された文字列に対して推測された resourceName と qualifiers が何であるかを判断する手段はありません。これらは単にインデクサーに追加されるだけです。推測された値を確認する唯一の方法は、PRI ファイルを作成し、MrmDump... 関数のいずれかを使用してダンプすることです。

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

各言語での呼び出し定義

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

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

MrmIndexFileAutoQualifiers = ctypes.windll.mrmsupport.MrmIndexFileAutoQualifiers
MrmIndexFileAutoQualifiers.restype = ctypes.c_int
MrmIndexFileAutoQualifiers.argtypes = [
    MrmResourceIndexerHandle,  # indexer : MrmResourceIndexerHandle
    wintypes.LPCWSTR,  # filePath : LPCWSTR optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('MrmSupport.dll')
MrmIndexFileAutoQualifiers = Fiddle::Function.new(
  lib['MrmIndexFileAutoQualifiers'],
  [
    Fiddle::TYPE_VOIDP,  # indexer : MrmResourceIndexerHandle
    Fiddle::TYPE_VOIDP,  # filePath : LPCWSTR optional
  ],
  Fiddle::TYPE_INT)
#[link(name = "mrmsupport")]
extern "system" {
    fn MrmIndexFileAutoQualifiers(
        indexer: MrmResourceIndexerHandle,  // MrmResourceIndexerHandle
        filePath: *const u16  // LPCWSTR optional
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("MrmSupport.dll")]
public static extern int MrmIndexFileAutoQualifiers(MrmResourceIndexerHandle indexer, [MarshalAs(UnmanagedType.LPWStr)] string filePath);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MrmSupport_MrmIndexFileAutoQualifiers' -Namespace Win32 -PassThru
# $api::MrmIndexFileAutoQualifiers(indexer, filePath)
#uselib "MrmSupport.dll"
#func global MrmIndexFileAutoQualifiers "MrmIndexFileAutoQualifiers" sptr, sptr
; MrmIndexFileAutoQualifiers indexer, filePath   ; 戻り値は stat
; indexer : MrmResourceIndexerHandle -> "sptr"
; filePath : LPCWSTR optional -> "sptr"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "MrmSupport.dll"
#cfunc global MrmIndexFileAutoQualifiers "MrmIndexFileAutoQualifiers" int, wstr
; res = MrmIndexFileAutoQualifiers(indexer, filePath)
; indexer : MrmResourceIndexerHandle -> "int"
; filePath : LPCWSTR optional -> "wstr"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
; HRESULT MrmIndexFileAutoQualifiers(MrmResourceIndexerHandle indexer, LPCWSTR filePath)
#uselib "MrmSupport.dll"
#cfunc global MrmIndexFileAutoQualifiers "MrmIndexFileAutoQualifiers" int, wstr
; res = MrmIndexFileAutoQualifiers(indexer, filePath)
; indexer : MrmResourceIndexerHandle -> "int"
; filePath : LPCWSTR optional -> "wstr"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	mrmsupport = windows.NewLazySystemDLL("MrmSupport.dll")
	procMrmIndexFileAutoQualifiers = mrmsupport.NewProc("MrmIndexFileAutoQualifiers")
)

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

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

typedef MrmIndexFileAutoQualifiersNative = Int32 Function(MrmResourceIndexerHandle, Pointer<Utf16>);
typedef MrmIndexFileAutoQualifiersDart = int Function(int, Pointer<Utf16>);
final MrmIndexFileAutoQualifiers = DynamicLibrary.open('MrmSupport.dll')
    .lookupFunction<MrmIndexFileAutoQualifiersNative, MrmIndexFileAutoQualifiersDart>('MrmIndexFileAutoQualifiers');
// indexer : MrmResourceIndexerHandle -> MrmResourceIndexerHandle
// filePath : LPCWSTR optional -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function MrmIndexFileAutoQualifiers(
  indexer: MrmResourceIndexerHandle;   // MrmResourceIndexerHandle
  filePath: PWideChar   // LPCWSTR optional
): Integer; stdcall;
  external 'MrmSupport.dll' name 'MrmIndexFileAutoQualifiers';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "MrmIndexFileAutoQualifiers"
  c_MrmIndexFileAutoQualifiers :: MrmResourceIndexerHandle -> CWString -> IO Int32
-- indexer : MrmResourceIndexerHandle -> MrmResourceIndexerHandle
-- filePath : LPCWSTR optional -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
-- ※値渡し構造体は GHC FFI で直接渡せません。Ptr で渡すラッパ(C側)経由にしてください。
open Ctypes
open Foreign

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

(cffi:defcfun ("MrmIndexFileAutoQualifiers" mrm-index-file-auto-qualifiers :convention :stdcall) :int32
  (indexer (:struct mrm-resource-indexer-handle))   ; MrmResourceIndexerHandle
  (file-path (:string :encoding :utf-16le)))   ; LPCWSTR optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $MrmIndexFileAutoQualifiers = Win32::API::More->new('MrmSupport',
    'int MrmIndexFileAutoQualifiers(LPVOID indexer, LPCWSTR filePath)');
# my $ret = $MrmIndexFileAutoQualifiers->Call($indexer, $filePath);
# indexer : MrmResourceIndexerHandle -> LPVOID
# filePath : LPCWSTR optional -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型