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

MQADsPathToFormatName

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

シグネチャ

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

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

パラメーター

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

戻り値の型: 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)。
const std = @import("std");

extern "mqrt" fn MQADsPathToFormatName(
    lpwcsADsPath: [*c]const u16, // LPCWSTR
    lpwcsFormatName: [*c]u16, // LPWSTR out
    lpdwFormatNameLength: [*c]u32 // DWORD* in/out
) callconv(std.os.windows.WINAPI) i32;
proc MQADsPathToFormatName(
    lpwcsADsPath: WideCString,  # LPCWSTR
    lpwcsFormatName: ptr uint16,  # LPWSTR out
    lpdwFormatNameLength: ptr uint32  # DWORD* in/out
): int32 {.importc: "MQADsPathToFormatName", stdcall, dynlib: "mqrt.dll".}
pragma(lib, "mqrt");
extern(Windows)
int MQADsPathToFormatName(
    const(wchar)* lpwcsADsPath,   // LPCWSTR
    wchar* lpwcsFormatName,   // LPWSTR out
    uint* lpdwFormatNameLength   // DWORD* in/out
);
ccall((:MQADsPathToFormatName, "mqrt.dll"), stdcall, Int32,
      (Cwstring, Ptr{UInt16}, Ptr{UInt32}),
      lpwcsADsPath, lpwcsFormatName, lpdwFormatNameLength)
# lpwcsADsPath : LPCWSTR -> Cwstring
# lpwcsFormatName : LPWSTR out -> Ptr{UInt16}
# lpdwFormatNameLength : DWORD* in/out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t MQADsPathToFormatName(
    const uint16_t* lpwcsADsPath,
    uint16_t* lpwcsFormatName,
    uint32_t* lpdwFormatNameLength);
]]
local mqrt = ffi.load("mqrt")
-- mqrt.MQADsPathToFormatName(lpwcsADsPath, lpwcsFormatName, lpdwFormatNameLength)
-- lpwcsADsPath : 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 MQADsPathToFormatName = lib.func('__stdcall', 'MQADsPathToFormatName', 'int32_t', ['str16', 'uint16_t *', 'uint32_t *']);
// MQADsPathToFormatName(lpwcsADsPath, lpwcsFormatName, lpdwFormatNameLength)
// lpwcsADsPath : LPCWSTR -> 'str16'
// lpwcsFormatName : LPWSTR out -> 'uint16_t *'
// lpdwFormatNameLength : DWORD* in/out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("mqrt.dll", {
  MQADsPathToFormatName: { parameters: ["buffer", "buffer", "pointer"], result: "i32" },
});
// lib.symbols.MQADsPathToFormatName(lpwcsADsPath, lpwcsFormatName, lpdwFormatNameLength)
// lpwcsADsPath : LPCWSTR -> "buffer"
// lpwcsFormatName : LPWSTR out -> "buffer"
// lpdwFormatNameLength : DWORD* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t MQADsPathToFormatName(
    const uint16_t* lpwcsADsPath,
    uint16_t* lpwcsFormatName,
    uint32_t* lpdwFormatNameLength);
C, "mqrt.dll");
// $ffi->MQADsPathToFormatName(lpwcsADsPath, lpwcsFormatName, lpdwFormatNameLength);
// lpwcsADsPath : 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 MQADsPathToFormatName(
        WString lpwcsADsPath,   // LPCWSTR
        char[] lpwcsFormatName,   // LPWSTR out
        IntByReference lpdwFormatNameLength   // DWORD* in/out
    );
}
@[Link("mqrt")]
lib Libmqrt
  fun MQADsPathToFormatName = MQADsPathToFormatName(
    lpwcsADsPath : 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 MQADsPathToFormatNameNative = Int32 Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Uint32>);
typedef MQADsPathToFormatNameDart = int Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Uint32>);
final MQADsPathToFormatName = DynamicLibrary.open('mqrt.dll')
    .lookupFunction<MQADsPathToFormatNameNative, MQADsPathToFormatNameDart>('MQADsPathToFormatName');
// lpwcsADsPath : LPCWSTR -> Pointer<Utf16>
// lpwcsFormatName : LPWSTR out -> Pointer<Utf16>
// lpdwFormatNameLength : DWORD* in/out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function MQADsPathToFormatName(
  lpwcsADsPath: PWideChar;   // LPCWSTR
  lpwcsFormatName: PWideChar;   // LPWSTR out
  lpdwFormatNameLength: Pointer   // DWORD* in/out
): Integer; stdcall;
  external 'mqrt.dll' name 'MQADsPathToFormatName';
import Foreign
import Foreign.C.Types
import Foreign.C.String

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

let mqadspathtoformatname =
  foreign "MQADsPathToFormatName"
    ((ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint32_t) @-> returning int32_t)
(* lpwcsADsPath : 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 ("MQADsPathToFormatName" mqads-path-to-format-name :convention :stdcall) :int32
  (lpwcs-ads-path (: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 $MQADsPathToFormatName = Win32::API::More->new('mqrt',
    'int MQADsPathToFormatName(LPCWSTR lpwcsADsPath, LPWSTR lpwcsFormatName, LPVOID lpdwFormatNameLength)');
# my $ret = $MQADsPathToFormatName->Call($lpwcsADsPath, $lpwcsFormatName, $lpdwFormatNameLength);
# lpwcsADsPath : LPCWSTR -> LPCWSTR
# lpwcsFormatName : LPWSTR out -> LPWSTR
# lpdwFormatNameLength : DWORD* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。