ホーム › Devices.Tapi › tapiRequestMediaCallW
tapiRequestMediaCallW
関数メディア通話を要求する関数のUnicode版。
シグネチャ
// TAPI32.dll (Unicode / -W)
#include <windows.h>
INT tapiRequestMediaCallW(
HWND hwnd,
WPARAM wRequestID,
LPCWSTR lpszDeviceClass,
LPCWSTR lpDeviceID,
DWORD dwSize,
DWORD dwSecure,
LPCWSTR lpszDestAddress,
LPCWSTR lpszAppName,
LPCWSTR lpszCalledParty,
LPCWSTR lpszComment
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hwnd | HWND | in | メディア通話要求を出すアプリケーションのウィンドウハンドル。 |
| wRequestID | WPARAM | in | この要求を識別するための要求ID(WPARAM)。 |
| lpszDeviceClass | LPCWSTR | in | 使用するメディアデバイスクラスを示すUnicode文字列。 |
| lpDeviceID | LPCWSTR | in | デバイスIDデータへのポインタ。書式はデバイスクラス依存。 |
| dwSize | DWORD | in | lpDeviceIDが指すデータのバイト数。 |
| dwSecure | DWORD | in | 通話のセキュア(暗号化)有無を示すフラグ。0で非セキュア。 |
| lpszDestAddress | LPCWSTR | in | 発信先のアドレス(電話番号)を示すUnicode文字列。 |
| lpszAppName | LPCWSTR | in | 発信を要求するアプリケーション名を示すUnicode文字列。NULL可。 |
| lpszCalledParty | LPCWSTR | in | 通話相手の名称を示すUnicode文字列。ログ表示用。NULL可。 |
| lpszComment | LPCWSTR | in | 通話に付随するコメントのUnicode文字列。NULL可。 |
戻り値の型: INT
各言語での呼び出し定義
// TAPI32.dll (Unicode / -W)
#include <windows.h>
INT tapiRequestMediaCallW(
HWND hwnd,
WPARAM wRequestID,
LPCWSTR lpszDeviceClass,
LPCWSTR lpDeviceID,
DWORD dwSize,
DWORD dwSecure,
LPCWSTR lpszDestAddress,
LPCWSTR lpszAppName,
LPCWSTR lpszCalledParty,
LPCWSTR lpszComment
);[DllImport("TAPI32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int tapiRequestMediaCallW(
IntPtr hwnd, // HWND
UIntPtr wRequestID, // WPARAM
[MarshalAs(UnmanagedType.LPWStr)] string lpszDeviceClass, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string lpDeviceID, // LPCWSTR
uint dwSize, // DWORD
uint dwSecure, // DWORD
[MarshalAs(UnmanagedType.LPWStr)] string lpszDestAddress, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string lpszAppName, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string lpszCalledParty, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string lpszComment // LPCWSTR
);<DllImport("TAPI32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function tapiRequestMediaCallW(
hwnd As IntPtr, ' HWND
wRequestID As UIntPtr, ' WPARAM
<MarshalAs(UnmanagedType.LPWStr)> lpszDeviceClass As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> lpDeviceID As String, ' LPCWSTR
dwSize As UInteger, ' DWORD
dwSecure As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPWStr)> lpszDestAddress As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> lpszAppName As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> lpszCalledParty As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> lpszComment As String ' LPCWSTR
) As Integer
End Function' hwnd : HWND
' wRequestID : WPARAM
' lpszDeviceClass : LPCWSTR
' lpDeviceID : LPCWSTR
' dwSize : DWORD
' dwSecure : DWORD
' lpszDestAddress : LPCWSTR
' lpszAppName : LPCWSTR
' lpszCalledParty : LPCWSTR
' lpszComment : LPCWSTR
Declare PtrSafe Function tapiRequestMediaCallW Lib "tapi32" ( _
ByVal hwnd As LongPtr, _
ByVal wRequestID As LongPtr, _
ByVal lpszDeviceClass As LongPtr, _
ByVal lpDeviceID As LongPtr, _
ByVal dwSize As Long, _
ByVal dwSecure As Long, _
ByVal lpszDestAddress As LongPtr, _
ByVal lpszAppName As LongPtr, _
ByVal lpszCalledParty As LongPtr, _
ByVal lpszComment As LongPtr) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
tapiRequestMediaCallW = ctypes.windll.tapi32.tapiRequestMediaCallW
tapiRequestMediaCallW.restype = ctypes.c_int
tapiRequestMediaCallW.argtypes = [
wintypes.HANDLE, # hwnd : HWND
ctypes.c_size_t, # wRequestID : WPARAM
wintypes.LPCWSTR, # lpszDeviceClass : LPCWSTR
wintypes.LPCWSTR, # lpDeviceID : LPCWSTR
wintypes.DWORD, # dwSize : DWORD
wintypes.DWORD, # dwSecure : DWORD
wintypes.LPCWSTR, # lpszDestAddress : LPCWSTR
wintypes.LPCWSTR, # lpszAppName : LPCWSTR
wintypes.LPCWSTR, # lpszCalledParty : LPCWSTR
wintypes.LPCWSTR, # lpszComment : LPCWSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('TAPI32.dll')
tapiRequestMediaCallW = Fiddle::Function.new(
lib['tapiRequestMediaCallW'],
[
Fiddle::TYPE_VOIDP, # hwnd : HWND
Fiddle::TYPE_UINTPTR_T, # wRequestID : WPARAM
Fiddle::TYPE_VOIDP, # lpszDeviceClass : LPCWSTR
Fiddle::TYPE_VOIDP, # lpDeviceID : LPCWSTR
-Fiddle::TYPE_INT, # dwSize : DWORD
-Fiddle::TYPE_INT, # dwSecure : DWORD
Fiddle::TYPE_VOIDP, # lpszDestAddress : LPCWSTR
Fiddle::TYPE_VOIDP, # lpszAppName : LPCWSTR
Fiddle::TYPE_VOIDP, # lpszCalledParty : LPCWSTR
Fiddle::TYPE_VOIDP, # lpszComment : LPCWSTR
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "tapi32")]
extern "system" {
fn tapiRequestMediaCallW(
hwnd: *mut core::ffi::c_void, // HWND
wRequestID: usize, // WPARAM
lpszDeviceClass: *const u16, // LPCWSTR
lpDeviceID: *const u16, // LPCWSTR
dwSize: u32, // DWORD
dwSecure: u32, // DWORD
lpszDestAddress: *const u16, // LPCWSTR
lpszAppName: *const u16, // LPCWSTR
lpszCalledParty: *const u16, // LPCWSTR
lpszComment: *const u16 // LPCWSTR
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("TAPI32.dll", CharSet = CharSet.Unicode)]
public static extern int tapiRequestMediaCallW(IntPtr hwnd, UIntPtr wRequestID, [MarshalAs(UnmanagedType.LPWStr)] string lpszDeviceClass, [MarshalAs(UnmanagedType.LPWStr)] string lpDeviceID, uint dwSize, uint dwSecure, [MarshalAs(UnmanagedType.LPWStr)] string lpszDestAddress, [MarshalAs(UnmanagedType.LPWStr)] string lpszAppName, [MarshalAs(UnmanagedType.LPWStr)] string lpszCalledParty, [MarshalAs(UnmanagedType.LPWStr)] string lpszComment);
"@
$api = Add-Type -MemberDefinition $sig -Name 'TAPI32_tapiRequestMediaCallW' -Namespace Win32 -PassThru
# $api::tapiRequestMediaCallW(hwnd, wRequestID, lpszDeviceClass, lpDeviceID, dwSize, dwSecure, lpszDestAddress, lpszAppName, lpszCalledParty, lpszComment)#uselib "TAPI32.dll"
#func global tapiRequestMediaCallW "tapiRequestMediaCallW" wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr
; tapiRequestMediaCallW hwnd, wRequestID, lpszDeviceClass, lpDeviceID, dwSize, dwSecure, lpszDestAddress, lpszAppName, lpszCalledParty, lpszComment ; 戻り値は stat
; hwnd : HWND -> "wptr"
; wRequestID : WPARAM -> "wptr"
; lpszDeviceClass : LPCWSTR -> "wptr"
; lpDeviceID : LPCWSTR -> "wptr"
; dwSize : DWORD -> "wptr"
; dwSecure : DWORD -> "wptr"
; lpszDestAddress : LPCWSTR -> "wptr"
; lpszAppName : LPCWSTR -> "wptr"
; lpszCalledParty : LPCWSTR -> "wptr"
; lpszComment : LPCWSTR -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "TAPI32.dll"
#cfunc global tapiRequestMediaCallW "tapiRequestMediaCallW" sptr, sptr, wstr, wstr, int, int, wstr, wstr, wstr, wstr
; res = tapiRequestMediaCallW(hwnd, wRequestID, lpszDeviceClass, lpDeviceID, dwSize, dwSecure, lpszDestAddress, lpszAppName, lpszCalledParty, lpszComment)
; hwnd : HWND -> "sptr"
; wRequestID : WPARAM -> "sptr"
; lpszDeviceClass : LPCWSTR -> "wstr"
; lpDeviceID : LPCWSTR -> "wstr"
; dwSize : DWORD -> "int"
; dwSecure : DWORD -> "int"
; lpszDestAddress : LPCWSTR -> "wstr"
; lpszAppName : LPCWSTR -> "wstr"
; lpszCalledParty : LPCWSTR -> "wstr"
; lpszComment : LPCWSTR -> "wstr"; INT tapiRequestMediaCallW(HWND hwnd, WPARAM wRequestID, LPCWSTR lpszDeviceClass, LPCWSTR lpDeviceID, DWORD dwSize, DWORD dwSecure, LPCWSTR lpszDestAddress, LPCWSTR lpszAppName, LPCWSTR lpszCalledParty, LPCWSTR lpszComment)
#uselib "TAPI32.dll"
#cfunc global tapiRequestMediaCallW "tapiRequestMediaCallW" intptr, intptr, wstr, wstr, int, int, wstr, wstr, wstr, wstr
; res = tapiRequestMediaCallW(hwnd, wRequestID, lpszDeviceClass, lpDeviceID, dwSize, dwSecure, lpszDestAddress, lpszAppName, lpszCalledParty, lpszComment)
; hwnd : HWND -> "intptr"
; wRequestID : WPARAM -> "intptr"
; lpszDeviceClass : LPCWSTR -> "wstr"
; lpDeviceID : LPCWSTR -> "wstr"
; dwSize : DWORD -> "int"
; dwSecure : DWORD -> "int"
; lpszDestAddress : LPCWSTR -> "wstr"
; lpszAppName : LPCWSTR -> "wstr"
; lpszCalledParty : LPCWSTR -> "wstr"
; lpszComment : LPCWSTR -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
tapi32 = windows.NewLazySystemDLL("TAPI32.dll")
proctapiRequestMediaCallW = tapi32.NewProc("tapiRequestMediaCallW")
)
// hwnd (HWND), wRequestID (WPARAM), lpszDeviceClass (LPCWSTR), lpDeviceID (LPCWSTR), dwSize (DWORD), dwSecure (DWORD), lpszDestAddress (LPCWSTR), lpszAppName (LPCWSTR), lpszCalledParty (LPCWSTR), lpszComment (LPCWSTR)
r1, _, err := proctapiRequestMediaCallW.Call(
uintptr(hwnd),
uintptr(wRequestID),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszDeviceClass))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpDeviceID))),
uintptr(dwSize),
uintptr(dwSecure),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszDestAddress))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszAppName))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszCalledParty))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszComment))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction tapiRequestMediaCallW(
hwnd: THandle; // HWND
wRequestID: NativeUInt; // WPARAM
lpszDeviceClass: PWideChar; // LPCWSTR
lpDeviceID: PWideChar; // LPCWSTR
dwSize: DWORD; // DWORD
dwSecure: DWORD; // DWORD
lpszDestAddress: PWideChar; // LPCWSTR
lpszAppName: PWideChar; // LPCWSTR
lpszCalledParty: PWideChar; // LPCWSTR
lpszComment: PWideChar // LPCWSTR
): Integer; stdcall;
external 'TAPI32.dll' name 'tapiRequestMediaCallW';result := DllCall("TAPI32\tapiRequestMediaCallW"
, "Ptr", hwnd ; HWND
, "UPtr", wRequestID ; WPARAM
, "WStr", lpszDeviceClass ; LPCWSTR
, "WStr", lpDeviceID ; LPCWSTR
, "UInt", dwSize ; DWORD
, "UInt", dwSecure ; DWORD
, "WStr", lpszDestAddress ; LPCWSTR
, "WStr", lpszAppName ; LPCWSTR
, "WStr", lpszCalledParty ; LPCWSTR
, "WStr", lpszComment ; LPCWSTR
, "Int") ; return: INT●tapiRequestMediaCallW(hwnd, wRequestID, lpszDeviceClass, lpDeviceID, dwSize, dwSecure, lpszDestAddress, lpszAppName, lpszCalledParty, lpszComment) = DLL("TAPI32.dll", "int tapiRequestMediaCallW(void*, int, char*, char*, dword, dword, char*, char*, char*, char*)")
# 呼び出し: tapiRequestMediaCallW(hwnd, wRequestID, lpszDeviceClass, lpDeviceID, dwSize, dwSecure, lpszDestAddress, lpszAppName, lpszCalledParty, lpszComment)
# hwnd : HWND -> "void*"
# wRequestID : WPARAM -> "int"
# lpszDeviceClass : LPCWSTR -> "char*"
# lpDeviceID : LPCWSTR -> "char*"
# dwSize : DWORD -> "dword"
# dwSecure : DWORD -> "dword"
# lpszDestAddress : LPCWSTR -> "char*"
# lpszAppName : LPCWSTR -> "char*"
# lpszCalledParty : LPCWSTR -> "char*"
# lpszComment : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。const std = @import("std");
extern "tapi32" fn tapiRequestMediaCallW(
hwnd: ?*anyopaque, // HWND
wRequestID: usize, // WPARAM
lpszDeviceClass: [*c]const u16, // LPCWSTR
lpDeviceID: [*c]const u16, // LPCWSTR
dwSize: u32, // DWORD
dwSecure: u32, // DWORD
lpszDestAddress: [*c]const u16, // LPCWSTR
lpszAppName: [*c]const u16, // LPCWSTR
lpszCalledParty: [*c]const u16, // LPCWSTR
lpszComment: [*c]const u16 // LPCWSTR
) callconv(std.os.windows.WINAPI) i32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc tapiRequestMediaCallW(
hwnd: pointer, # HWND
wRequestID: uint, # WPARAM
lpszDeviceClass: WideCString, # LPCWSTR
lpDeviceID: WideCString, # LPCWSTR
dwSize: uint32, # DWORD
dwSecure: uint32, # DWORD
lpszDestAddress: WideCString, # LPCWSTR
lpszAppName: WideCString, # LPCWSTR
lpszCalledParty: WideCString, # LPCWSTR
lpszComment: WideCString # LPCWSTR
): int32 {.importc: "tapiRequestMediaCallW", stdcall, dynlib: "TAPI32.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "tapi32");
extern(Windows)
int tapiRequestMediaCallW(
void* hwnd, // HWND
size_t wRequestID, // WPARAM
const(wchar)* lpszDeviceClass, // LPCWSTR
const(wchar)* lpDeviceID, // LPCWSTR
uint dwSize, // DWORD
uint dwSecure, // DWORD
const(wchar)* lpszDestAddress, // LPCWSTR
const(wchar)* lpszAppName, // LPCWSTR
const(wchar)* lpszCalledParty, // LPCWSTR
const(wchar)* lpszComment // LPCWSTR
);ccall((:tapiRequestMediaCallW, "TAPI32.dll"), stdcall, Int32,
(Ptr{Cvoid}, Csize_t, Cwstring, Cwstring, UInt32, UInt32, Cwstring, Cwstring, Cwstring, Cwstring),
hwnd, wRequestID, lpszDeviceClass, lpDeviceID, dwSize, dwSecure, lpszDestAddress, lpszAppName, lpszCalledParty, lpszComment)
# hwnd : HWND -> Ptr{Cvoid}
# wRequestID : WPARAM -> Csize_t
# lpszDeviceClass : LPCWSTR -> Cwstring
# lpDeviceID : LPCWSTR -> Cwstring
# dwSize : DWORD -> UInt32
# dwSecure : DWORD -> UInt32
# lpszDestAddress : LPCWSTR -> Cwstring
# lpszAppName : LPCWSTR -> Cwstring
# lpszCalledParty : LPCWSTR -> Cwstring
# lpszComment : LPCWSTR -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
int32_t tapiRequestMediaCallW(
void* hwnd,
uintptr_t wRequestID,
const uint16_t* lpszDeviceClass,
const uint16_t* lpDeviceID,
uint32_t dwSize,
uint32_t dwSecure,
const uint16_t* lpszDestAddress,
const uint16_t* lpszAppName,
const uint16_t* lpszCalledParty,
const uint16_t* lpszComment);
]]
local tapi32 = ffi.load("tapi32")
-- tapi32.tapiRequestMediaCallW(hwnd, wRequestID, lpszDeviceClass, lpDeviceID, dwSize, dwSecure, lpszDestAddress, lpszAppName, lpszCalledParty, lpszComment)
-- hwnd : HWND
-- wRequestID : WPARAM
-- lpszDeviceClass : LPCWSTR
-- lpDeviceID : LPCWSTR
-- dwSize : DWORD
-- dwSecure : DWORD
-- lpszDestAddress : LPCWSTR
-- lpszAppName : LPCWSTR
-- lpszCalledParty : LPCWSTR
-- lpszComment : LPCWSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。const koffi = require('koffi');
const lib = koffi.load('TAPI32.dll');
const tapiRequestMediaCallW = lib.func('__stdcall', 'tapiRequestMediaCallW', 'int32_t', ['void *', 'uintptr_t', 'str16', 'str16', 'uint32_t', 'uint32_t', 'str16', 'str16', 'str16', 'str16']);
// tapiRequestMediaCallW(hwnd, wRequestID, lpszDeviceClass, lpDeviceID, dwSize, dwSecure, lpszDestAddress, lpszAppName, lpszCalledParty, lpszComment)
// hwnd : HWND -> 'void *'
// wRequestID : WPARAM -> 'uintptr_t'
// lpszDeviceClass : LPCWSTR -> 'str16'
// lpDeviceID : LPCWSTR -> 'str16'
// dwSize : DWORD -> 'uint32_t'
// dwSecure : DWORD -> 'uint32_t'
// lpszDestAddress : LPCWSTR -> 'str16'
// lpszAppName : LPCWSTR -> 'str16'
// lpszCalledParty : LPCWSTR -> 'str16'
// lpszComment : LPCWSTR -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("TAPI32.dll", {
tapiRequestMediaCallW: { parameters: ["pointer", "usize", "buffer", "buffer", "u32", "u32", "buffer", "buffer", "buffer", "buffer"], result: "i32" },
});
// lib.symbols.tapiRequestMediaCallW(hwnd, wRequestID, lpszDeviceClass, lpDeviceID, dwSize, dwSecure, lpszDestAddress, lpszAppName, lpszCalledParty, lpszComment)
// hwnd : HWND -> "pointer"
// wRequestID : WPARAM -> "usize"
// lpszDeviceClass : LPCWSTR -> "buffer"
// lpDeviceID : LPCWSTR -> "buffer"
// dwSize : DWORD -> "u32"
// dwSecure : DWORD -> "u32"
// lpszDestAddress : LPCWSTR -> "buffer"
// lpszAppName : LPCWSTR -> "buffer"
// lpszCalledParty : LPCWSTR -> "buffer"
// lpszComment : LPCWSTR -> "buffer"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t tapiRequestMediaCallW(
void* hwnd,
size_t wRequestID,
const uint16_t* lpszDeviceClass,
const uint16_t* lpDeviceID,
uint32_t dwSize,
uint32_t dwSecure,
const uint16_t* lpszDestAddress,
const uint16_t* lpszAppName,
const uint16_t* lpszCalledParty,
const uint16_t* lpszComment);
C, "TAPI32.dll");
// $ffi->tapiRequestMediaCallW(hwnd, wRequestID, lpszDeviceClass, lpDeviceID, dwSize, dwSecure, lpszDestAddress, lpszAppName, lpszCalledParty, lpszComment);
// hwnd : HWND
// wRequestID : WPARAM
// lpszDeviceClass : LPCWSTR
// lpDeviceID : LPCWSTR
// dwSize : DWORD
// dwSecure : DWORD
// lpszDestAddress : LPCWSTR
// lpszAppName : LPCWSTR
// lpszCalledParty : LPCWSTR
// lpszComment : LPCWSTR
// 構造体/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 Tapi32 extends StdCallLibrary {
Tapi32 INSTANCE = Native.load("tapi32", Tapi32.class, W32APIOptions.UNICODE_OPTIONS);
int tapiRequestMediaCallW(
Pointer hwnd, // HWND
long wRequestID, // WPARAM
WString lpszDeviceClass, // LPCWSTR
WString lpDeviceID, // LPCWSTR
int dwSize, // DWORD
int dwSecure, // DWORD
WString lpszDestAddress, // LPCWSTR
WString lpszAppName, // LPCWSTR
WString lpszCalledParty, // LPCWSTR
WString lpszComment // LPCWSTR
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("tapi32")]
lib LibTAPI32
fun tapiRequestMediaCallW = tapiRequestMediaCallW(
hwnd : Void*, # HWND
wRequestID : LibC::SizeT, # WPARAM
lpszDeviceClass : UInt16*, # LPCWSTR
lpDeviceID : UInt16*, # LPCWSTR
dwSize : UInt32, # DWORD
dwSecure : UInt32, # DWORD
lpszDestAddress : UInt16*, # LPCWSTR
lpszAppName : UInt16*, # LPCWSTR
lpszCalledParty : UInt16*, # LPCWSTR
lpszComment : UInt16* # LPCWSTR
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef tapiRequestMediaCallWNative = Int32 Function(Pointer<Void>, UintPtr, Pointer<Utf16>, Pointer<Utf16>, Uint32, Uint32, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>);
typedef tapiRequestMediaCallWDart = int Function(Pointer<Void>, int, Pointer<Utf16>, Pointer<Utf16>, int, int, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>);
final tapiRequestMediaCallW = DynamicLibrary.open('TAPI32.dll')
.lookupFunction<tapiRequestMediaCallWNative, tapiRequestMediaCallWDart>('tapiRequestMediaCallW');
// hwnd : HWND -> Pointer<Void>
// wRequestID : WPARAM -> UintPtr
// lpszDeviceClass : LPCWSTR -> Pointer<Utf16>
// lpDeviceID : LPCWSTR -> Pointer<Utf16>
// dwSize : DWORD -> Uint32
// dwSecure : DWORD -> Uint32
// lpszDestAddress : LPCWSTR -> Pointer<Utf16>
// lpszAppName : LPCWSTR -> Pointer<Utf16>
// lpszCalledParty : LPCWSTR -> Pointer<Utf16>
// lpszComment : LPCWSTR -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function tapiRequestMediaCallW(
hwnd: THandle; // HWND
wRequestID: NativeUInt; // WPARAM
lpszDeviceClass: PWideChar; // LPCWSTR
lpDeviceID: PWideChar; // LPCWSTR
dwSize: DWORD; // DWORD
dwSecure: DWORD; // DWORD
lpszDestAddress: PWideChar; // LPCWSTR
lpszAppName: PWideChar; // LPCWSTR
lpszCalledParty: PWideChar; // LPCWSTR
lpszComment: PWideChar // LPCWSTR
): Integer; stdcall;
external 'TAPI32.dll' name 'tapiRequestMediaCallW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "tapiRequestMediaCallW"
c_tapiRequestMediaCallW :: Ptr () -> CUIntPtr -> CWString -> CWString -> Word32 -> Word32 -> CWString -> CWString -> CWString -> CWString -> IO Int32
-- hwnd : HWND -> Ptr ()
-- wRequestID : WPARAM -> CUIntPtr
-- lpszDeviceClass : LPCWSTR -> CWString
-- lpDeviceID : LPCWSTR -> CWString
-- dwSize : DWORD -> Word32
-- dwSecure : DWORD -> Word32
-- lpszDestAddress : LPCWSTR -> CWString
-- lpszAppName : LPCWSTR -> CWString
-- lpszCalledParty : LPCWSTR -> CWString
-- lpszComment : LPCWSTR -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let tapirequestmediacallw =
foreign "tapiRequestMediaCallW"
((ptr void) @-> size_t @-> (ptr uint16_t) @-> (ptr uint16_t) @-> uint32_t @-> uint32_t @-> (ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> returning int32_t)
(* hwnd : HWND -> (ptr void) *)
(* wRequestID : WPARAM -> size_t *)
(* lpszDeviceClass : LPCWSTR -> (ptr uint16_t) *)
(* lpDeviceID : LPCWSTR -> (ptr uint16_t) *)
(* dwSize : DWORD -> uint32_t *)
(* dwSecure : DWORD -> uint32_t *)
(* lpszDestAddress : LPCWSTR -> (ptr uint16_t) *)
(* lpszAppName : LPCWSTR -> (ptr uint16_t) *)
(* lpszCalledParty : LPCWSTR -> (ptr uint16_t) *)
(* lpszComment : LPCWSTR -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library tapi32 (t "TAPI32.dll"))
(cffi:use-foreign-library tapi32)
(cffi:defcfun ("tapiRequestMediaCallW" tapi-request-media-call-w :convention :stdcall) :int32
(hwnd :pointer) ; HWND
(w-request-id :uint64) ; WPARAM
(lpsz-device-class (:string :encoding :utf-16le)) ; LPCWSTR
(lp-device-id (:string :encoding :utf-16le)) ; LPCWSTR
(dw-size :uint32) ; DWORD
(dw-secure :uint32) ; DWORD
(lpsz-dest-address (:string :encoding :utf-16le)) ; LPCWSTR
(lpsz-app-name (:string :encoding :utf-16le)) ; LPCWSTR
(lpsz-called-party (:string :encoding :utf-16le)) ; LPCWSTR
(lpsz-comment (:string :encoding :utf-16le))) ; LPCWSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $tapiRequestMediaCallW = Win32::API::More->new('TAPI32',
'int tapiRequestMediaCallW(HANDLE hwnd, WPARAM wRequestID, LPCWSTR lpszDeviceClass, LPCWSTR lpDeviceID, DWORD dwSize, DWORD dwSecure, LPCWSTR lpszDestAddress, LPCWSTR lpszAppName, LPCWSTR lpszCalledParty, LPCWSTR lpszComment)');
# my $ret = $tapiRequestMediaCallW->Call($hwnd, $wRequestID, $lpszDeviceClass, $lpDeviceID, $dwSize, $dwSecure, $lpszDestAddress, $lpszAppName, $lpszCalledParty, $lpszComment);
# hwnd : HWND -> HANDLE
# wRequestID : WPARAM -> WPARAM
# lpszDeviceClass : LPCWSTR -> LPCWSTR
# lpDeviceID : LPCWSTR -> LPCWSTR
# dwSize : DWORD -> DWORD
# dwSecure : DWORD -> DWORD
# lpszDestAddress : LPCWSTR -> LPCWSTR
# lpszAppName : LPCWSTR -> LPCWSTR
# lpszCalledParty : LPCWSTR -> LPCWSTR
# lpszComment : LPCWSTR -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
文字セット違い
- f tapiRequestMediaCallA (ANSI版) — メディア通話を要求する関数のANSI版。