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

MQADsPathToFormatName

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

シグネチャ

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

HRESULT MQADsPathToFormatName(
    LPCWSTR lpwcsADsPath,
    LPWSTR lpwcsFormatName,
    DWORD* lpdwFormatNameLength
);

パラメーター

名前方向
lpwcsADsPathLPCWSTRin
lpwcsFormatNameLPWSTRout
lpdwFormatNameLengthDWORD*inout

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT MQADsPathToFormatName(
    LPCWSTR lpwcsADsPath,
    LPWSTR lpwcsFormatName,
    DWORD* lpdwFormatNameLength
);
[DllImport("mqrt.dll", ExactSpelling = true)]
static extern int MQADsPathToFormatName(
    [MarshalAs(UnmanagedType.LPWStr)] string lpwcsADsPath,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpwcsFormatName,   // LPWSTR out
    ref uint lpdwFormatNameLength   // DWORD* in/out
);
<DllImport("mqrt.dll", ExactSpelling:=True)>
Public Shared Function MQADsPathToFormatName(
    <MarshalAs(UnmanagedType.LPWStr)> lpwcsADsPath As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> lpwcsFormatName As System.Text.StringBuilder,   ' LPWSTR out
    ByRef lpdwFormatNameLength As UInteger   ' DWORD* in/out
) As Integer
End Function
' lpwcsADsPath : LPCWSTR
' lpwcsFormatName : LPWSTR out
' lpdwFormatNameLength : DWORD* in/out
Declare PtrSafe Function MQADsPathToFormatName Lib "mqrt" ( _
    ByVal lpwcsADsPath 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

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

lib = Fiddle.dlopen('mqrt.dll')
MQADsPathToFormatName = Fiddle::Function.new(
  lib['MQADsPathToFormatName'],
  [
    Fiddle::TYPE_VOIDP,  # lpwcsADsPath : LPCWSTR
    Fiddle::TYPE_VOIDP,  # lpwcsFormatName : LPWSTR out
    Fiddle::TYPE_VOIDP,  # lpdwFormatNameLength : DWORD* in/out
  ],
  Fiddle::TYPE_INT)
#[link(name = "mqrt")]
extern "system" {
    fn MQADsPathToFormatName(
        lpwcsADsPath: *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 MQADsPathToFormatName([MarshalAs(UnmanagedType.LPWStr)] string lpwcsADsPath, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpwcsFormatName, ref uint lpdwFormatNameLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'mqrt_MQADsPathToFormatName' -Namespace Win32 -PassThru
# $api::MQADsPathToFormatName(lpwcsADsPath, lpwcsFormatName, lpdwFormatNameLength)
#uselib "mqrt.dll"
#func global MQADsPathToFormatName "MQADsPathToFormatName" sptr, sptr, sptr
; MQADsPathToFormatName lpwcsADsPath, varptr(lpwcsFormatName), varptr(lpdwFormatNameLength)   ; 戻り値は stat
; lpwcsADsPath : LPCWSTR -> "sptr"
; lpwcsFormatName : LPWSTR out -> "sptr"
; lpdwFormatNameLength : DWORD* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "mqrt.dll"
#cfunc global MQADsPathToFormatName "MQADsPathToFormatName" wstr, var, var
; res = MQADsPathToFormatName(lpwcsADsPath, lpwcsFormatName, lpdwFormatNameLength)
; lpwcsADsPath : LPCWSTR -> "wstr"
; lpwcsFormatName : LPWSTR out -> "var"
; lpdwFormatNameLength : DWORD* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT MQADsPathToFormatName(LPCWSTR lpwcsADsPath, LPWSTR lpwcsFormatName, DWORD* lpdwFormatNameLength)
#uselib "mqrt.dll"
#cfunc global MQADsPathToFormatName "MQADsPathToFormatName" wstr, var, var
; res = MQADsPathToFormatName(lpwcsADsPath, lpwcsFormatName, lpdwFormatNameLength)
; lpwcsADsPath : 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")
	procMQADsPathToFormatName = mqrt.NewProc("MQADsPathToFormatName")
)

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