ホーム › System.MessageQueuing › MQHandleToFormatName
MQHandleToFormatName
関数キューハンドルからフォーマット名を取得する。
シグネチャ
// mqrt.dll
#include <windows.h>
HRESULT MQHandleToFormatName(
INT_PTR hQueue,
LPWSTR lpwcsFormatName,
DWORD* lpdwFormatNameLength
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hQueue | INT_PTR | in | フォーマット名を取得する対象の開いているキューのハンドルを指定する。 |
| lpwcsFormatName | LPWSTR | out | 取得したフォーマット名を受け取るワイド文字列バッファを指定する。 |
| lpdwFormatNameLength | DWORD* | inout | 入力でバッファ文字数、出力で実際の長さを受け渡すDWORDへのポインタを指定する。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// mqrt.dll
#include <windows.h>
HRESULT MQHandleToFormatName(
INT_PTR hQueue,
LPWSTR lpwcsFormatName,
DWORD* lpdwFormatNameLength
);[DllImport("mqrt.dll", ExactSpelling = true)]
static extern int MQHandleToFormatName(
IntPtr hQueue, // INT_PTR
[MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpwcsFormatName, // LPWSTR out
ref uint lpdwFormatNameLength // DWORD* in/out
);<DllImport("mqrt.dll", ExactSpelling:=True)>
Public Shared Function MQHandleToFormatName(
hQueue As IntPtr, ' INT_PTR
<MarshalAs(UnmanagedType.LPWStr)> lpwcsFormatName As System.Text.StringBuilder, ' LPWSTR out
ByRef lpdwFormatNameLength As UInteger ' DWORD* in/out
) As Integer
End Function' hQueue : INT_PTR
' lpwcsFormatName : LPWSTR out
' lpdwFormatNameLength : DWORD* in/out
Declare PtrSafe Function MQHandleToFormatName Lib "mqrt" ( _
ByVal hQueue 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
MQHandleToFormatName = ctypes.windll.mqrt.MQHandleToFormatName
MQHandleToFormatName.restype = ctypes.c_int
MQHandleToFormatName.argtypes = [
ctypes.c_ssize_t, # hQueue : INT_PTR
wintypes.LPWSTR, # lpwcsFormatName : LPWSTR out
ctypes.POINTER(wintypes.DWORD), # lpdwFormatNameLength : DWORD* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('mqrt.dll')
MQHandleToFormatName = Fiddle::Function.new(
lib['MQHandleToFormatName'],
[
Fiddle::TYPE_INTPTR_T, # hQueue : INT_PTR
Fiddle::TYPE_VOIDP, # lpwcsFormatName : LPWSTR out
Fiddle::TYPE_VOIDP, # lpdwFormatNameLength : DWORD* in/out
],
Fiddle::TYPE_INT)#[link(name = "mqrt")]
extern "system" {
fn MQHandleToFormatName(
hQueue: isize, // INT_PTR
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 MQHandleToFormatName(IntPtr hQueue, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpwcsFormatName, ref uint lpdwFormatNameLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'mqrt_MQHandleToFormatName' -Namespace Win32 -PassThru
# $api::MQHandleToFormatName(hQueue, lpwcsFormatName, lpdwFormatNameLength)#uselib "mqrt.dll"
#func global MQHandleToFormatName "MQHandleToFormatName" sptr, sptr, sptr
; MQHandleToFormatName hQueue, varptr(lpwcsFormatName), varptr(lpdwFormatNameLength) ; 戻り値は stat
; hQueue : INT_PTR -> "sptr"
; lpwcsFormatName : LPWSTR out -> "sptr"
; lpdwFormatNameLength : DWORD* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "mqrt.dll" #cfunc global MQHandleToFormatName "MQHandleToFormatName" sptr, var, var ; res = MQHandleToFormatName(hQueue, lpwcsFormatName, lpdwFormatNameLength) ; hQueue : INT_PTR -> "sptr" ; lpwcsFormatName : LPWSTR out -> "var" ; lpdwFormatNameLength : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "mqrt.dll" #cfunc global MQHandleToFormatName "MQHandleToFormatName" sptr, sptr, sptr ; res = MQHandleToFormatName(hQueue, varptr(lpwcsFormatName), varptr(lpdwFormatNameLength)) ; hQueue : INT_PTR -> "sptr" ; lpwcsFormatName : LPWSTR out -> "sptr" ; lpdwFormatNameLength : DWORD* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT MQHandleToFormatName(INT_PTR hQueue, LPWSTR lpwcsFormatName, DWORD* lpdwFormatNameLength) #uselib "mqrt.dll" #cfunc global MQHandleToFormatName "MQHandleToFormatName" intptr, var, var ; res = MQHandleToFormatName(hQueue, lpwcsFormatName, lpdwFormatNameLength) ; hQueue : INT_PTR -> "intptr" ; lpwcsFormatName : LPWSTR out -> "var" ; lpdwFormatNameLength : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT MQHandleToFormatName(INT_PTR hQueue, LPWSTR lpwcsFormatName, DWORD* lpdwFormatNameLength) #uselib "mqrt.dll" #cfunc global MQHandleToFormatName "MQHandleToFormatName" intptr, intptr, intptr ; res = MQHandleToFormatName(hQueue, varptr(lpwcsFormatName), varptr(lpdwFormatNameLength)) ; hQueue : INT_PTR -> "intptr" ; lpwcsFormatName : LPWSTR out -> "intptr" ; lpdwFormatNameLength : DWORD* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
mqrt = windows.NewLazySystemDLL("mqrt.dll")
procMQHandleToFormatName = mqrt.NewProc("MQHandleToFormatName")
)
// hQueue (INT_PTR), lpwcsFormatName (LPWSTR out), lpdwFormatNameLength (DWORD* in/out)
r1, _, err := procMQHandleToFormatName.Call(
uintptr(hQueue),
uintptr(lpwcsFormatName),
uintptr(lpdwFormatNameLength),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction MQHandleToFormatName(
hQueue: NativeInt; // INT_PTR
lpwcsFormatName: PWideChar; // LPWSTR out
lpdwFormatNameLength: Pointer // DWORD* in/out
): Integer; stdcall;
external 'mqrt.dll' name 'MQHandleToFormatName';result := DllCall("mqrt\MQHandleToFormatName"
, "Ptr", hQueue ; INT_PTR
, "Ptr", lpwcsFormatName ; LPWSTR out
, "Ptr", lpdwFormatNameLength ; DWORD* in/out
, "Int") ; return: HRESULT●MQHandleToFormatName(hQueue, lpwcsFormatName, lpdwFormatNameLength) = DLL("mqrt.dll", "int MQHandleToFormatName(int, char*, void*)")
# 呼び出し: MQHandleToFormatName(hQueue, lpwcsFormatName, lpdwFormatNameLength)
# hQueue : INT_PTR -> "int"
# 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 MQHandleToFormatName(
hQueue: isize, // INT_PTR
lpwcsFormatName: [*c]u16, // LPWSTR out
lpdwFormatNameLength: [*c]u32 // DWORD* in/out
) callconv(std.os.windows.WINAPI) i32;proc MQHandleToFormatName(
hQueue: int, # INT_PTR
lpwcsFormatName: ptr uint16, # LPWSTR out
lpdwFormatNameLength: ptr uint32 # DWORD* in/out
): int32 {.importc: "MQHandleToFormatName", stdcall, dynlib: "mqrt.dll".}pragma(lib, "mqrt");
extern(Windows)
int MQHandleToFormatName(
ptrdiff_t hQueue, // INT_PTR
wchar* lpwcsFormatName, // LPWSTR out
uint* lpdwFormatNameLength // DWORD* in/out
);ccall((:MQHandleToFormatName, "mqrt.dll"), stdcall, Int32,
(Int, Ptr{UInt16}, Ptr{UInt32}),
hQueue, lpwcsFormatName, lpdwFormatNameLength)
# hQueue : INT_PTR -> Int
# lpwcsFormatName : LPWSTR out -> Ptr{UInt16}
# lpdwFormatNameLength : DWORD* in/out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t MQHandleToFormatName(
intptr_t hQueue,
uint16_t* lpwcsFormatName,
uint32_t* lpdwFormatNameLength);
]]
local mqrt = ffi.load("mqrt")
-- mqrt.MQHandleToFormatName(hQueue, lpwcsFormatName, lpdwFormatNameLength)
-- hQueue : INT_PTR
-- lpwcsFormatName : LPWSTR out
-- lpdwFormatNameLength : DWORD* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('mqrt.dll');
const MQHandleToFormatName = lib.func('__stdcall', 'MQHandleToFormatName', 'int32_t', ['intptr_t', 'uint16_t *', 'uint32_t *']);
// MQHandleToFormatName(hQueue, lpwcsFormatName, lpdwFormatNameLength)
// hQueue : INT_PTR -> 'intptr_t'
// lpwcsFormatName : LPWSTR out -> 'uint16_t *'
// lpdwFormatNameLength : DWORD* in/out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("mqrt.dll", {
MQHandleToFormatName: { parameters: ["isize", "buffer", "pointer"], result: "i32" },
});
// lib.symbols.MQHandleToFormatName(hQueue, lpwcsFormatName, lpdwFormatNameLength)
// hQueue : INT_PTR -> "isize"
// lpwcsFormatName : LPWSTR out -> "buffer"
// lpdwFormatNameLength : DWORD* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t MQHandleToFormatName(
intptr_t hQueue,
uint16_t* lpwcsFormatName,
uint32_t* lpdwFormatNameLength);
C, "mqrt.dll");
// $ffi->MQHandleToFormatName(hQueue, lpwcsFormatName, lpdwFormatNameLength);
// hQueue : INT_PTR
// 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 MQHandleToFormatName(
long hQueue, // INT_PTR
char[] lpwcsFormatName, // LPWSTR out
IntByReference lpdwFormatNameLength // DWORD* in/out
);
}@[Link("mqrt")]
lib Libmqrt
fun MQHandleToFormatName = MQHandleToFormatName(
hQueue : LibC::SSizeT, # INT_PTR
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 MQHandleToFormatNameNative = Int32 Function(IntPtr, Pointer<Utf16>, Pointer<Uint32>);
typedef MQHandleToFormatNameDart = int Function(int, Pointer<Utf16>, Pointer<Uint32>);
final MQHandleToFormatName = DynamicLibrary.open('mqrt.dll')
.lookupFunction<MQHandleToFormatNameNative, MQHandleToFormatNameDart>('MQHandleToFormatName');
// hQueue : INT_PTR -> IntPtr
// lpwcsFormatName : LPWSTR out -> Pointer<Utf16>
// lpdwFormatNameLength : DWORD* in/out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function MQHandleToFormatName(
hQueue: NativeInt; // INT_PTR
lpwcsFormatName: PWideChar; // LPWSTR out
lpdwFormatNameLength: Pointer // DWORD* in/out
): Integer; stdcall;
external 'mqrt.dll' name 'MQHandleToFormatName';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "MQHandleToFormatName"
c_MQHandleToFormatName :: CIntPtr -> CWString -> Ptr Word32 -> IO Int32
-- hQueue : INT_PTR -> CIntPtr
-- lpwcsFormatName : LPWSTR out -> CWString
-- lpdwFormatNameLength : DWORD* in/out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let mqhandletoformatname =
foreign "MQHandleToFormatName"
(intptr_t @-> (ptr uint16_t) @-> (ptr uint32_t) @-> returning int32_t)
(* hQueue : INT_PTR -> intptr_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 ("MQHandleToFormatName" mqhandle-to-format-name :convention :stdcall) :int32
(h-queue :int64) ; INT_PTR
(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 $MQHandleToFormatName = Win32::API::More->new('mqrt',
'int MQHandleToFormatName(LPARAM hQueue, LPWSTR lpwcsFormatName, LPVOID lpdwFormatNameLength)');
# my $ret = $MQHandleToFormatName->Call($hQueue, $lpwcsFormatName, $lpdwFormatNameLength);
# hQueue : INT_PTR -> LPARAM
# lpwcsFormatName : LPWSTR out -> LPWSTR
# lpdwFormatNameLength : DWORD* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。