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

IndexFilePath

関数
指定ファイルパスをインデックス化し修飾子情報を返す。
DLLMrmSupport.dll呼出規約winapi対応OSWindows 10 以降

シグネチャ

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

HRESULT IndexFilePath(
    void* resourceIndexer,
    LPCWSTR filePath,
    LPWSTR* ppResourceUri,
    DWORD* pQualifierCount,
    IndexedResourceQualifier** ppQualifiers
);

パラメーター

名前方向説明
resourceIndexervoid*inCreateResourceIndexer 関数を呼び出して作成したリソースインデクサーオブジェクト。
filePathLPCWSTRinインデックスするフォルダーのパス。パスはドライブ文字を指定した絶対パスである必要があります。長いファイルパスはサポートされていません。
ppResourceUriLPWSTR*outms-resource URI スキームを使用し、候補の名前付きリソースを表す URI (Uniform Resource Indicator)。URI の権限部分、すなわちリソースマップは空です。たとえば ms-resource:///Resources/String1 や ms-resource:///Files/images/logo.png などです。
pQualifierCountDWORD*outppQualifiers パラメーターのリストに含まれる、インデックスされたリソース修飾子の数。
ppQualifiersIndexedResourceQualifier**outリソースが適切となるコンテキストを宣言する、インデックスされたリソース修飾子のリスト。

戻り値の型: HRESULT

公式ドキュメント

ファイルおよびフォルダーの命名規則に従って、ファイルパスをインデックスします。

戻り値

この関数が成功した場合は 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 IndexFilePath(
    void* resourceIndexer,
    LPCWSTR filePath,
    LPWSTR* ppResourceUri,
    DWORD* pQualifierCount,
    IndexedResourceQualifier** ppQualifiers
);
[DllImport("MrmSupport.dll", ExactSpelling = true)]
static extern int IndexFilePath(
    IntPtr resourceIndexer,   // void*
    [MarshalAs(UnmanagedType.LPWStr)] string filePath,   // LPCWSTR
    IntPtr ppResourceUri,   // LPWSTR* out
    out uint pQualifierCount,   // DWORD* out
    IntPtr ppQualifiers   // IndexedResourceQualifier** out
);
<DllImport("MrmSupport.dll", ExactSpelling:=True)>
Public Shared Function IndexFilePath(
    resourceIndexer As IntPtr,   ' void*
    <MarshalAs(UnmanagedType.LPWStr)> filePath As String,   ' LPCWSTR
    ppResourceUri As IntPtr,   ' LPWSTR* out
    <Out> ByRef pQualifierCount As UInteger,   ' DWORD* out
    ppQualifiers As IntPtr   ' IndexedResourceQualifier** out
) As Integer
End Function
' resourceIndexer : void*
' filePath : LPCWSTR
' ppResourceUri : LPWSTR* out
' pQualifierCount : DWORD* out
' ppQualifiers : IndexedResourceQualifier** out
Declare PtrSafe Function IndexFilePath Lib "mrmsupport" ( _
    ByVal resourceIndexer As LongPtr, _
    ByVal filePath As LongPtr, _
    ByVal ppResourceUri As LongPtr, _
    ByRef pQualifierCount As Long, _
    ByVal ppQualifiers As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

IndexFilePath = ctypes.windll.mrmsupport.IndexFilePath
IndexFilePath.restype = ctypes.c_int
IndexFilePath.argtypes = [
    ctypes.POINTER(None),  # resourceIndexer : void*
    wintypes.LPCWSTR,  # filePath : LPCWSTR
    ctypes.c_void_p,  # ppResourceUri : LPWSTR* out
    ctypes.POINTER(wintypes.DWORD),  # pQualifierCount : DWORD* out
    ctypes.c_void_p,  # ppQualifiers : IndexedResourceQualifier** out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('MrmSupport.dll')
IndexFilePath = Fiddle::Function.new(
  lib['IndexFilePath'],
  [
    Fiddle::TYPE_VOIDP,  # resourceIndexer : void*
    Fiddle::TYPE_VOIDP,  # filePath : LPCWSTR
    Fiddle::TYPE_VOIDP,  # ppResourceUri : LPWSTR* out
    Fiddle::TYPE_VOIDP,  # pQualifierCount : DWORD* out
    Fiddle::TYPE_VOIDP,  # ppQualifiers : IndexedResourceQualifier** out
  ],
  Fiddle::TYPE_INT)
#[link(name = "mrmsupport")]
extern "system" {
    fn IndexFilePath(
        resourceIndexer: *mut (),  // void*
        filePath: *const u16,  // LPCWSTR
        ppResourceUri: *mut *mut u16,  // LPWSTR* out
        pQualifierCount: *mut u32,  // DWORD* out
        ppQualifiers: *mut *mut IndexedResourceQualifier  // IndexedResourceQualifier** out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("MrmSupport.dll")]
public static extern int IndexFilePath(IntPtr resourceIndexer, [MarshalAs(UnmanagedType.LPWStr)] string filePath, IntPtr ppResourceUri, out uint pQualifierCount, IntPtr ppQualifiers);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MrmSupport_IndexFilePath' -Namespace Win32 -PassThru
# $api::IndexFilePath(resourceIndexer, filePath, ppResourceUri, pQualifierCount, ppQualifiers)
#uselib "MrmSupport.dll"
#func global IndexFilePath "IndexFilePath" sptr, sptr, sptr, sptr, sptr
; IndexFilePath resourceIndexer, filePath, varptr(ppResourceUri), varptr(pQualifierCount), varptr(ppQualifiers)   ; 戻り値は stat
; resourceIndexer : void* -> "sptr"
; filePath : LPCWSTR -> "sptr"
; ppResourceUri : LPWSTR* out -> "sptr"
; pQualifierCount : DWORD* out -> "sptr"
; ppQualifiers : IndexedResourceQualifier** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "MrmSupport.dll"
#cfunc global IndexFilePath "IndexFilePath" sptr, wstr, var, var, var
; res = IndexFilePath(resourceIndexer, filePath, ppResourceUri, pQualifierCount, ppQualifiers)
; resourceIndexer : void* -> "sptr"
; filePath : LPCWSTR -> "wstr"
; ppResourceUri : LPWSTR* out -> "var"
; pQualifierCount : DWORD* out -> "var"
; ppQualifiers : IndexedResourceQualifier** out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT IndexFilePath(void* resourceIndexer, LPCWSTR filePath, LPWSTR* ppResourceUri, DWORD* pQualifierCount, IndexedResourceQualifier** ppQualifiers)
#uselib "MrmSupport.dll"
#cfunc global IndexFilePath "IndexFilePath" intptr, wstr, var, var, var
; res = IndexFilePath(resourceIndexer, filePath, ppResourceUri, pQualifierCount, ppQualifiers)
; resourceIndexer : void* -> "intptr"
; filePath : LPCWSTR -> "wstr"
; ppResourceUri : LPWSTR* out -> "var"
; pQualifierCount : DWORD* out -> "var"
; ppQualifiers : IndexedResourceQualifier** out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	mrmsupport = windows.NewLazySystemDLL("MrmSupport.dll")
	procIndexFilePath = mrmsupport.NewProc("IndexFilePath")
)

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

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

typedef IndexFilePathNative = Int32 Function(Pointer<Void>, Pointer<Utf16>, Pointer<Pointer<Utf16>>, Pointer<Uint32>, Pointer<Void>);
typedef IndexFilePathDart = int Function(Pointer<Void>, Pointer<Utf16>, Pointer<Pointer<Utf16>>, Pointer<Uint32>, Pointer<Void>);
final IndexFilePath = DynamicLibrary.open('MrmSupport.dll')
    .lookupFunction<IndexFilePathNative, IndexFilePathDart>('IndexFilePath');
// resourceIndexer : void* -> Pointer<Void>
// filePath : LPCWSTR -> Pointer<Utf16>
// ppResourceUri : LPWSTR* out -> Pointer<Pointer<Utf16>>
// pQualifierCount : DWORD* out -> Pointer<Uint32>
// ppQualifiers : IndexedResourceQualifier** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function IndexFilePath(
  resourceIndexer: Pointer;   // void*
  filePath: PWideChar;   // LPCWSTR
  ppResourceUri: PPWideChar;   // LPWSTR* out
  pQualifierCount: Pointer;   // DWORD* out
  ppQualifiers: Pointer   // IndexedResourceQualifier** out
): Integer; stdcall;
  external 'MrmSupport.dll' name 'IndexFilePath';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "IndexFilePath"
  c_IndexFilePath :: Ptr () -> CWString -> Ptr CWString -> Ptr Word32 -> Ptr () -> IO Int32
-- resourceIndexer : void* -> Ptr ()
-- filePath : LPCWSTR -> CWString
-- ppResourceUri : LPWSTR* out -> Ptr CWString
-- pQualifierCount : DWORD* out -> Ptr Word32
-- ppQualifiers : IndexedResourceQualifier** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let indexfilepath =
  foreign "IndexFilePath"
    ((ptr void) @-> (ptr uint16_t) @-> (ptr (ptr uint16_t)) @-> (ptr uint32_t) @-> (ptr void) @-> returning int32_t)
(* resourceIndexer : void* -> (ptr void) *)
(* filePath : LPCWSTR -> (ptr uint16_t) *)
(* ppResourceUri : LPWSTR* out -> (ptr (ptr uint16_t)) *)
(* pQualifierCount : DWORD* out -> (ptr uint32_t) *)
(* ppQualifiers : IndexedResourceQualifier** 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 ("IndexFilePath" index-file-path :convention :stdcall) :int32
  (resource-indexer :pointer)   ; void*
  (file-path (:string :encoding :utf-16le))   ; LPCWSTR
  (pp-resource-uri :pointer)   ; LPWSTR* out
  (p-qualifier-count :pointer)   ; DWORD* out
  (pp-qualifiers :pointer))   ; IndexedResourceQualifier** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $IndexFilePath = Win32::API::More->new('MrmSupport',
    'int IndexFilePath(LPVOID resourceIndexer, LPCWSTR filePath, LPVOID ppResourceUri, LPVOID pQualifierCount, LPVOID ppQualifiers)');
# my $ret = $IndexFilePath->Call($resourceIndexer, $filePath, $ppResourceUri, $pQualifierCount, $ppQualifiers);
# resourceIndexer : void* -> LPVOID
# filePath : LPCWSTR -> LPCWSTR
# ppResourceUri : LPWSTR* out -> LPVOID
# pQualifierCount : DWORD* out -> LPVOID
# ppQualifiers : IndexedResourceQualifier** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

公式の関連項目
使用する型