Win32 API 日本語リファレンス
ホームSystem.MessageQueuing › MQPathNameToFormatName

MQPathNameToFormatName

関数
キューのパス名をフォーマット名へ変換する。
DLLmqrt.dll呼出規約winapi

シグネチャ

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

HRESULT MQPathNameToFormatName(
    LPCWSTR lpwcsPathName,
    LPWSTR lpwcsFormatName,
    DWORD* lpdwFormatNameLength
);

パラメーター

名前方向説明
lpwcsPathNameLPCWSTRin変換元となるキューのパス名(ワイド文字列)を指定する。
lpwcsFormatNameLPWSTRout変換後のフォーマット名を受け取るワイド文字列バッファを指定する。
lpdwFormatNameLengthDWORD*inout入力でバッファ文字数、出力で実際の長さを受け渡すDWORDへのポインタを指定する。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT MQPathNameToFormatName(
    LPCWSTR lpwcsPathName,
    LPWSTR lpwcsFormatName,
    DWORD* lpdwFormatNameLength
);
[DllImport("mqrt.dll", ExactSpelling = true)]
static extern int MQPathNameToFormatName(
    [MarshalAs(UnmanagedType.LPWStr)] string lpwcsPathName,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpwcsFormatName,   // LPWSTR out
    ref uint lpdwFormatNameLength   // DWORD* in/out
);
<DllImport("mqrt.dll", ExactSpelling:=True)>
Public Shared Function MQPathNameToFormatName(
    <MarshalAs(UnmanagedType.LPWStr)> lpwcsPathName As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> lpwcsFormatName As System.Text.StringBuilder,   ' LPWSTR out
    ByRef lpdwFormatNameLength As UInteger   ' DWORD* in/out
) As Integer
End Function
' lpwcsPathName : LPCWSTR
' lpwcsFormatName : LPWSTR out
' lpdwFormatNameLength : DWORD* in/out
Declare PtrSafe Function MQPathNameToFormatName Lib "mqrt" ( _
    ByVal lpwcsPathName As LongPtr, _
    ByVal lpwcsFormatName As LongPtr, _
    ByRef lpdwFormatNameLength As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

MQPathNameToFormatName = ctypes.windll.mqrt.MQPathNameToFormatName
MQPathNameToFormatName.restype = ctypes.c_int
MQPathNameToFormatName.argtypes = [
    wintypes.LPCWSTR,  # lpwcsPathName : LPCWSTR
    wintypes.LPWSTR,  # lpwcsFormatName : LPWSTR out
    ctypes.POINTER(wintypes.DWORD),  # lpdwFormatNameLength : DWORD* in/out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	mqrt = windows.NewLazySystemDLL("mqrt.dll")
	procMQPathNameToFormatName = mqrt.NewProc("MQPathNameToFormatName")
)

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

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

typedef MQPathNameToFormatNameNative = Int32 Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Uint32>);
typedef MQPathNameToFormatNameDart = int Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Uint32>);
final MQPathNameToFormatName = DynamicLibrary.open('mqrt.dll')
    .lookupFunction<MQPathNameToFormatNameNative, MQPathNameToFormatNameDart>('MQPathNameToFormatName');
// lpwcsPathName : LPCWSTR -> Pointer<Utf16>
// lpwcsFormatName : LPWSTR out -> Pointer<Utf16>
// lpdwFormatNameLength : DWORD* in/out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function MQPathNameToFormatName(
  lpwcsPathName: PWideChar;   // LPCWSTR
  lpwcsFormatName: PWideChar;   // LPWSTR out
  lpdwFormatNameLength: Pointer   // DWORD* in/out
): Integer; stdcall;
  external 'mqrt.dll' name 'MQPathNameToFormatName';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "MQPathNameToFormatName"
  c_MQPathNameToFormatName :: CWString -> CWString -> Ptr Word32 -> IO Int32
-- lpwcsPathName : LPCWSTR -> CWString
-- lpwcsFormatName : LPWSTR out -> CWString
-- lpdwFormatNameLength : DWORD* in/out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let mqpathnametoformatname =
  foreign "MQPathNameToFormatName"
    ((ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint32_t) @-> returning int32_t)
(* lpwcsPathName : LPCWSTR -> (ptr uint16_t) *)
(* lpwcsFormatName : LPWSTR out -> (ptr uint16_t) *)
(* lpdwFormatNameLength : DWORD* in/out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library mqrt (t "mqrt.dll"))
(cffi:use-foreign-library mqrt)

(cffi:defcfun ("MQPathNameToFormatName" mqpath-name-to-format-name :convention :stdcall) :int32
  (lpwcs-path-name (:string :encoding :utf-16le))   ; LPCWSTR
  (lpwcs-format-name :pointer)   ; LPWSTR out
  (lpdw-format-name-length :pointer))   ; DWORD* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $MQPathNameToFormatName = Win32::API::More->new('mqrt',
    'int MQPathNameToFormatName(LPCWSTR lpwcsPathName, LPWSTR lpwcsFormatName, LPVOID lpdwFormatNameLength)');
# my $ret = $MQPathNameToFormatName->Call($lpwcsPathName, $lpwcsFormatName, $lpdwFormatNameLength);
# lpwcsPathName : LPCWSTR -> LPCWSTR
# lpwcsFormatName : LPWSTR out -> LPWSTR
# lpdwFormatNameLength : DWORD* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。