ホーム › Globalization › GetFileMUIPath
GetFileMUIPath
関数指定ファイルに対応する言語別MUIファイルのパスを取得する。
シグネチャ
// KERNEL32.dll
#include <windows.h>
BOOL GetFileMUIPath(
DWORD dwFlags,
LPCWSTR pcwszFilePath,
LPWSTR pwszLanguage, // optional
DWORD* pcchLanguage,
LPWSTR pwszFileMUIPath, // optional
DWORD* pcchFileMUIPath,
ULONGLONG* pululEnumerator
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| dwFlags | DWORD | in |
| pcwszFilePath | LPCWSTR | in |
| pwszLanguage | LPWSTR | inoutoptional |
| pcchLanguage | DWORD* | inout |
| pwszFileMUIPath | LPWSTR | outoptional |
| pcchFileMUIPath | DWORD* | inout |
| pululEnumerator | ULONGLONG* | inout |
戻り値の型: BOOL
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
BOOL GetFileMUIPath(
DWORD dwFlags,
LPCWSTR pcwszFilePath,
LPWSTR pwszLanguage, // optional
DWORD* pcchLanguage,
LPWSTR pwszFileMUIPath, // optional
DWORD* pcchFileMUIPath,
ULONGLONG* pululEnumerator
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool GetFileMUIPath(
uint dwFlags, // DWORD
[MarshalAs(UnmanagedType.LPWStr)] string pcwszFilePath, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pwszLanguage, // LPWSTR optional, in/out
ref uint pcchLanguage, // DWORD* in/out
[MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pwszFileMUIPath, // LPWSTR optional, out
ref uint pcchFileMUIPath, // DWORD* in/out
ref ulong pululEnumerator // ULONGLONG* in/out
);<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetFileMUIPath(
dwFlags As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPWStr)> pcwszFilePath As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> pwszLanguage As System.Text.StringBuilder, ' LPWSTR optional, in/out
ByRef pcchLanguage As UInteger, ' DWORD* in/out
<MarshalAs(UnmanagedType.LPWStr)> pwszFileMUIPath As System.Text.StringBuilder, ' LPWSTR optional, out
ByRef pcchFileMUIPath As UInteger, ' DWORD* in/out
ByRef pululEnumerator As ULong ' ULONGLONG* in/out
) As Boolean
End Function' dwFlags : DWORD
' pcwszFilePath : LPCWSTR
' pwszLanguage : LPWSTR optional, in/out
' pcchLanguage : DWORD* in/out
' pwszFileMUIPath : LPWSTR optional, out
' pcchFileMUIPath : DWORD* in/out
' pululEnumerator : ULONGLONG* in/out
Declare PtrSafe Function GetFileMUIPath Lib "kernel32" ( _
ByVal dwFlags As Long, _
ByVal pcwszFilePath As LongPtr, _
ByVal pwszLanguage As LongPtr, _
ByRef pcchLanguage As Long, _
ByVal pwszFileMUIPath As LongPtr, _
ByRef pcchFileMUIPath As Long, _
ByRef pululEnumerator As LongLong) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetFileMUIPath = ctypes.windll.kernel32.GetFileMUIPath
GetFileMUIPath.restype = wintypes.BOOL
GetFileMUIPath.argtypes = [
wintypes.DWORD, # dwFlags : DWORD
wintypes.LPCWSTR, # pcwszFilePath : LPCWSTR
wintypes.LPWSTR, # pwszLanguage : LPWSTR optional, in/out
ctypes.POINTER(wintypes.DWORD), # pcchLanguage : DWORD* in/out
wintypes.LPWSTR, # pwszFileMUIPath : LPWSTR optional, out
ctypes.POINTER(wintypes.DWORD), # pcchFileMUIPath : DWORD* in/out
ctypes.POINTER(ctypes.c_ulonglong), # pululEnumerator : ULONGLONG* in/out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
GetFileMUIPath = Fiddle::Function.new(
lib['GetFileMUIPath'],
[
-Fiddle::TYPE_INT, # dwFlags : DWORD
Fiddle::TYPE_VOIDP, # pcwszFilePath : LPCWSTR
Fiddle::TYPE_VOIDP, # pwszLanguage : LPWSTR optional, in/out
Fiddle::TYPE_VOIDP, # pcchLanguage : DWORD* in/out
Fiddle::TYPE_VOIDP, # pwszFileMUIPath : LPWSTR optional, out
Fiddle::TYPE_VOIDP, # pcchFileMUIPath : DWORD* in/out
Fiddle::TYPE_VOIDP, # pululEnumerator : ULONGLONG* in/out
],
Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn GetFileMUIPath(
dwFlags: u32, // DWORD
pcwszFilePath: *const u16, // LPCWSTR
pwszLanguage: *mut u16, // LPWSTR optional, in/out
pcchLanguage: *mut u32, // DWORD* in/out
pwszFileMUIPath: *mut u16, // LPWSTR optional, out
pcchFileMUIPath: *mut u32, // DWORD* in/out
pululEnumerator: *mut u64 // ULONGLONG* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true)]
public static extern bool GetFileMUIPath(uint dwFlags, [MarshalAs(UnmanagedType.LPWStr)] string pcwszFilePath, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pwszLanguage, ref uint pcchLanguage, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pwszFileMUIPath, ref uint pcchFileMUIPath, ref ulong pululEnumerator);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_GetFileMUIPath' -Namespace Win32 -PassThru
# $api::GetFileMUIPath(dwFlags, pcwszFilePath, pwszLanguage, pcchLanguage, pwszFileMUIPath, pcchFileMUIPath, pululEnumerator)#uselib "KERNEL32.dll"
#func global GetFileMUIPath "GetFileMUIPath" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; GetFileMUIPath dwFlags, pcwszFilePath, varptr(pwszLanguage), varptr(pcchLanguage), varptr(pwszFileMUIPath), varptr(pcchFileMUIPath), varptr(pululEnumerator) ; 戻り値は stat
; dwFlags : DWORD -> "sptr"
; pcwszFilePath : LPCWSTR -> "sptr"
; pwszLanguage : LPWSTR optional, in/out -> "sptr"
; pcchLanguage : DWORD* in/out -> "sptr"
; pwszFileMUIPath : LPWSTR optional, out -> "sptr"
; pcchFileMUIPath : DWORD* in/out -> "sptr"
; pululEnumerator : ULONGLONG* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "KERNEL32.dll" #cfunc global GetFileMUIPath "GetFileMUIPath" int, wstr, var, var, var, var, var ; res = GetFileMUIPath(dwFlags, pcwszFilePath, pwszLanguage, pcchLanguage, pwszFileMUIPath, pcchFileMUIPath, pululEnumerator) ; dwFlags : DWORD -> "int" ; pcwszFilePath : LPCWSTR -> "wstr" ; pwszLanguage : LPWSTR optional, in/out -> "var" ; pcchLanguage : DWORD* in/out -> "var" ; pwszFileMUIPath : LPWSTR optional, out -> "var" ; pcchFileMUIPath : DWORD* in/out -> "var" ; pululEnumerator : ULONGLONG* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "KERNEL32.dll" #cfunc global GetFileMUIPath "GetFileMUIPath" int, wstr, sptr, sptr, sptr, sptr, sptr ; res = GetFileMUIPath(dwFlags, pcwszFilePath, varptr(pwszLanguage), varptr(pcchLanguage), varptr(pwszFileMUIPath), varptr(pcchFileMUIPath), varptr(pululEnumerator)) ; dwFlags : DWORD -> "int" ; pcwszFilePath : LPCWSTR -> "wstr" ; pwszLanguage : LPWSTR optional, in/out -> "sptr" ; pcchLanguage : DWORD* in/out -> "sptr" ; pwszFileMUIPath : LPWSTR optional, out -> "sptr" ; pcchFileMUIPath : DWORD* in/out -> "sptr" ; pululEnumerator : ULONGLONG* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL GetFileMUIPath(DWORD dwFlags, LPCWSTR pcwszFilePath, LPWSTR pwszLanguage, DWORD* pcchLanguage, LPWSTR pwszFileMUIPath, DWORD* pcchFileMUIPath, ULONGLONG* pululEnumerator) #uselib "KERNEL32.dll" #cfunc global GetFileMUIPath "GetFileMUIPath" int, wstr, var, var, var, var, var ; res = GetFileMUIPath(dwFlags, pcwszFilePath, pwszLanguage, pcchLanguage, pwszFileMUIPath, pcchFileMUIPath, pululEnumerator) ; dwFlags : DWORD -> "int" ; pcwszFilePath : LPCWSTR -> "wstr" ; pwszLanguage : LPWSTR optional, in/out -> "var" ; pcchLanguage : DWORD* in/out -> "var" ; pwszFileMUIPath : LPWSTR optional, out -> "var" ; pcchFileMUIPath : DWORD* in/out -> "var" ; pululEnumerator : ULONGLONG* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL GetFileMUIPath(DWORD dwFlags, LPCWSTR pcwszFilePath, LPWSTR pwszLanguage, DWORD* pcchLanguage, LPWSTR pwszFileMUIPath, DWORD* pcchFileMUIPath, ULONGLONG* pululEnumerator) #uselib "KERNEL32.dll" #cfunc global GetFileMUIPath "GetFileMUIPath" int, wstr, intptr, intptr, intptr, intptr, intptr ; res = GetFileMUIPath(dwFlags, pcwszFilePath, varptr(pwszLanguage), varptr(pcchLanguage), varptr(pwszFileMUIPath), varptr(pcchFileMUIPath), varptr(pululEnumerator)) ; dwFlags : DWORD -> "int" ; pcwszFilePath : LPCWSTR -> "wstr" ; pwszLanguage : LPWSTR optional, in/out -> "intptr" ; pcchLanguage : DWORD* in/out -> "intptr" ; pwszFileMUIPath : LPWSTR optional, out -> "intptr" ; pcchFileMUIPath : DWORD* in/out -> "intptr" ; pululEnumerator : ULONGLONG* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procGetFileMUIPath = kernel32.NewProc("GetFileMUIPath")
)
// dwFlags (DWORD), pcwszFilePath (LPCWSTR), pwszLanguage (LPWSTR optional, in/out), pcchLanguage (DWORD* in/out), pwszFileMUIPath (LPWSTR optional, out), pcchFileMUIPath (DWORD* in/out), pululEnumerator (ULONGLONG* in/out)
r1, _, err := procGetFileMUIPath.Call(
uintptr(dwFlags),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pcwszFilePath))),
uintptr(pwszLanguage),
uintptr(pcchLanguage),
uintptr(pwszFileMUIPath),
uintptr(pcchFileMUIPath),
uintptr(pululEnumerator),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction GetFileMUIPath(
dwFlags: DWORD; // DWORD
pcwszFilePath: PWideChar; // LPCWSTR
pwszLanguage: PWideChar; // LPWSTR optional, in/out
pcchLanguage: Pointer; // DWORD* in/out
pwszFileMUIPath: PWideChar; // LPWSTR optional, out
pcchFileMUIPath: Pointer; // DWORD* in/out
pululEnumerator: Pointer // ULONGLONG* in/out
): BOOL; stdcall;
external 'KERNEL32.dll' name 'GetFileMUIPath';result := DllCall("KERNEL32\GetFileMUIPath"
, "UInt", dwFlags ; DWORD
, "WStr", pcwszFilePath ; LPCWSTR
, "Ptr", pwszLanguage ; LPWSTR optional, in/out
, "Ptr", pcchLanguage ; DWORD* in/out
, "Ptr", pwszFileMUIPath ; LPWSTR optional, out
, "Ptr", pcchFileMUIPath ; DWORD* in/out
, "Ptr", pululEnumerator ; ULONGLONG* in/out
, "Int") ; return: BOOL●GetFileMUIPath(dwFlags, pcwszFilePath, pwszLanguage, pcchLanguage, pwszFileMUIPath, pcchFileMUIPath, pululEnumerator) = DLL("KERNEL32.dll", "bool GetFileMUIPath(dword, char*, char*, void*, char*, void*, void*)")
# 呼び出し: GetFileMUIPath(dwFlags, pcwszFilePath, pwszLanguage, pcchLanguage, pwszFileMUIPath, pcchFileMUIPath, pululEnumerator)
# dwFlags : DWORD -> "dword"
# pcwszFilePath : LPCWSTR -> "char*"
# pwszLanguage : LPWSTR optional, in/out -> "char*"
# pcchLanguage : DWORD* in/out -> "void*"
# pwszFileMUIPath : LPWSTR optional, out -> "char*"
# pcchFileMUIPath : DWORD* in/out -> "void*"
# pululEnumerator : ULONGLONG* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。