Win32 API 日本語リファレンス
ホームDevices.Tapi › tapiRequestMediaCallA

tapiRequestMediaCallA

関数
メディア通話を要求する関数のANSI版。
DLLTAPI32.dll文字セットANSI (-A)呼出規約winapi

シグネチャ

// TAPI32.dll  (ANSI / -A)
#include <windows.h>

INT tapiRequestMediaCallA(
    HWND hwnd,
    WPARAM wRequestID,
    LPCSTR lpszDeviceClass,
    LPCSTR lpDeviceID,
    DWORD dwSize,
    DWORD dwSecure,
    LPCSTR lpszDestAddress,
    LPCSTR lpszAppName,
    LPCSTR lpszCalledParty,
    LPCSTR lpszComment
);

パラメーター

名前方向説明
hwndHWNDinメディア通話要求を出すアプリケーションのウィンドウハンドル。
wRequestIDWPARAMinこの要求を識別するための要求ID(WPARAM)。
lpszDeviceClassLPCSTRin使用するメディアデバイスクラスを示す文字列。
lpDeviceIDLPCSTRinデバイスIDデータへのポインタ。書式はデバイスクラス依存。
dwSizeDWORDinlpDeviceIDが指すデータのバイト数。
dwSecureDWORDin通話のセキュア(暗号化)有無を示すフラグ。0で非セキュア。
lpszDestAddressLPCSTRin発信先のアドレス(電話番号)を示す文字列。
lpszAppNameLPCSTRin発信を要求するアプリケーション名を示す文字列。NULL可。
lpszCalledPartyLPCSTRin通話相手の名称を示す文字列。ログ表示用。NULL可。
lpszCommentLPCSTRin通話に付随するコメント文字列。NULL可。

戻り値の型: INT

各言語での呼び出し定義

// TAPI32.dll  (ANSI / -A)
#include <windows.h>

INT tapiRequestMediaCallA(
    HWND hwnd,
    WPARAM wRequestID,
    LPCSTR lpszDeviceClass,
    LPCSTR lpDeviceID,
    DWORD dwSize,
    DWORD dwSecure,
    LPCSTR lpszDestAddress,
    LPCSTR lpszAppName,
    LPCSTR lpszCalledParty,
    LPCSTR lpszComment
);
[DllImport("TAPI32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern int tapiRequestMediaCallA(
    IntPtr hwnd,   // HWND
    UIntPtr wRequestID,   // WPARAM
    [MarshalAs(UnmanagedType.LPStr)] string lpszDeviceClass,   // LPCSTR
    [MarshalAs(UnmanagedType.LPStr)] string lpDeviceID,   // LPCSTR
    uint dwSize,   // DWORD
    uint dwSecure,   // DWORD
    [MarshalAs(UnmanagedType.LPStr)] string lpszDestAddress,   // LPCSTR
    [MarshalAs(UnmanagedType.LPStr)] string lpszAppName,   // LPCSTR
    [MarshalAs(UnmanagedType.LPStr)] string lpszCalledParty,   // LPCSTR
    [MarshalAs(UnmanagedType.LPStr)] string lpszComment   // LPCSTR
);
<DllImport("TAPI32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function tapiRequestMediaCallA(
    hwnd As IntPtr,   ' HWND
    wRequestID As UIntPtr,   ' WPARAM
    <MarshalAs(UnmanagedType.LPStr)> lpszDeviceClass As String,   ' LPCSTR
    <MarshalAs(UnmanagedType.LPStr)> lpDeviceID As String,   ' LPCSTR
    dwSize As UInteger,   ' DWORD
    dwSecure As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPStr)> lpszDestAddress As String,   ' LPCSTR
    <MarshalAs(UnmanagedType.LPStr)> lpszAppName As String,   ' LPCSTR
    <MarshalAs(UnmanagedType.LPStr)> lpszCalledParty As String,   ' LPCSTR
    <MarshalAs(UnmanagedType.LPStr)> lpszComment As String   ' LPCSTR
) As Integer
End Function
' hwnd : HWND
' wRequestID : WPARAM
' lpszDeviceClass : LPCSTR
' lpDeviceID : LPCSTR
' dwSize : DWORD
' dwSecure : DWORD
' lpszDestAddress : LPCSTR
' lpszAppName : LPCSTR
' lpszCalledParty : LPCSTR
' lpszComment : LPCSTR
Declare PtrSafe Function tapiRequestMediaCallA Lib "tapi32" ( _
    ByVal hwnd As LongPtr, _
    ByVal wRequestID As LongPtr, _
    ByVal lpszDeviceClass As String, _
    ByVal lpDeviceID As String, _
    ByVal dwSize As Long, _
    ByVal dwSecure As Long, _
    ByVal lpszDestAddress As String, _
    ByVal lpszAppName As String, _
    ByVal lpszCalledParty As String, _
    ByVal lpszComment As String) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

tapiRequestMediaCallA = ctypes.windll.tapi32.tapiRequestMediaCallA
tapiRequestMediaCallA.restype = ctypes.c_int
tapiRequestMediaCallA.argtypes = [
    wintypes.HANDLE,  # hwnd : HWND
    ctypes.c_size_t,  # wRequestID : WPARAM
    wintypes.LPCSTR,  # lpszDeviceClass : LPCSTR
    wintypes.LPCSTR,  # lpDeviceID : LPCSTR
    wintypes.DWORD,  # dwSize : DWORD
    wintypes.DWORD,  # dwSecure : DWORD
    wintypes.LPCSTR,  # lpszDestAddress : LPCSTR
    wintypes.LPCSTR,  # lpszAppName : LPCSTR
    wintypes.LPCSTR,  # lpszCalledParty : LPCSTR
    wintypes.LPCSTR,  # lpszComment : LPCSTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('TAPI32.dll')
tapiRequestMediaCallA = Fiddle::Function.new(
  lib['tapiRequestMediaCallA'],
  [
    Fiddle::TYPE_VOIDP,  # hwnd : HWND
    Fiddle::TYPE_UINTPTR_T,  # wRequestID : WPARAM
    Fiddle::TYPE_VOIDP,  # lpszDeviceClass : LPCSTR
    Fiddle::TYPE_VOIDP,  # lpDeviceID : LPCSTR
    -Fiddle::TYPE_INT,  # dwSize : DWORD
    -Fiddle::TYPE_INT,  # dwSecure : DWORD
    Fiddle::TYPE_VOIDP,  # lpszDestAddress : LPCSTR
    Fiddle::TYPE_VOIDP,  # lpszAppName : LPCSTR
    Fiddle::TYPE_VOIDP,  # lpszCalledParty : LPCSTR
    Fiddle::TYPE_VOIDP,  # lpszComment : LPCSTR
  ],
  Fiddle::TYPE_INT)
#[link(name = "tapi32")]
extern "system" {
    fn tapiRequestMediaCallA(
        hwnd: *mut core::ffi::c_void,  // HWND
        wRequestID: usize,  // WPARAM
        lpszDeviceClass: *const u8,  // LPCSTR
        lpDeviceID: *const u8,  // LPCSTR
        dwSize: u32,  // DWORD
        dwSecure: u32,  // DWORD
        lpszDestAddress: *const u8,  // LPCSTR
        lpszAppName: *const u8,  // LPCSTR
        lpszCalledParty: *const u8,  // LPCSTR
        lpszComment: *const u8  // LPCSTR
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("TAPI32.dll", CharSet = CharSet.Ansi)]
public static extern int tapiRequestMediaCallA(IntPtr hwnd, UIntPtr wRequestID, [MarshalAs(UnmanagedType.LPStr)] string lpszDeviceClass, [MarshalAs(UnmanagedType.LPStr)] string lpDeviceID, uint dwSize, uint dwSecure, [MarshalAs(UnmanagedType.LPStr)] string lpszDestAddress, [MarshalAs(UnmanagedType.LPStr)] string lpszAppName, [MarshalAs(UnmanagedType.LPStr)] string lpszCalledParty, [MarshalAs(UnmanagedType.LPStr)] string lpszComment);
"@
$api = Add-Type -MemberDefinition $sig -Name 'TAPI32_tapiRequestMediaCallA' -Namespace Win32 -PassThru
# $api::tapiRequestMediaCallA(hwnd, wRequestID, lpszDeviceClass, lpDeviceID, dwSize, dwSecure, lpszDestAddress, lpszAppName, lpszCalledParty, lpszComment)
#uselib "TAPI32.dll"
#func global tapiRequestMediaCallA "tapiRequestMediaCallA" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; tapiRequestMediaCallA hwnd, wRequestID, lpszDeviceClass, lpDeviceID, dwSize, dwSecure, lpszDestAddress, lpszAppName, lpszCalledParty, lpszComment   ; 戻り値は stat
; hwnd : HWND -> "sptr"
; wRequestID : WPARAM -> "sptr"
; lpszDeviceClass : LPCSTR -> "sptr"
; lpDeviceID : LPCSTR -> "sptr"
; dwSize : DWORD -> "sptr"
; dwSecure : DWORD -> "sptr"
; lpszDestAddress : LPCSTR -> "sptr"
; lpszAppName : LPCSTR -> "sptr"
; lpszCalledParty : LPCSTR -> "sptr"
; lpszComment : LPCSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "TAPI32.dll"
#cfunc global tapiRequestMediaCallA "tapiRequestMediaCallA" sptr, sptr, str, str, int, int, str, str, str, str
; res = tapiRequestMediaCallA(hwnd, wRequestID, lpszDeviceClass, lpDeviceID, dwSize, dwSecure, lpszDestAddress, lpszAppName, lpszCalledParty, lpszComment)
; hwnd : HWND -> "sptr"
; wRequestID : WPARAM -> "sptr"
; lpszDeviceClass : LPCSTR -> "str"
; lpDeviceID : LPCSTR -> "str"
; dwSize : DWORD -> "int"
; dwSecure : DWORD -> "int"
; lpszDestAddress : LPCSTR -> "str"
; lpszAppName : LPCSTR -> "str"
; lpszCalledParty : LPCSTR -> "str"
; lpszComment : LPCSTR -> "str"
; INT tapiRequestMediaCallA(HWND hwnd, WPARAM wRequestID, LPCSTR lpszDeviceClass, LPCSTR lpDeviceID, DWORD dwSize, DWORD dwSecure, LPCSTR lpszDestAddress, LPCSTR lpszAppName, LPCSTR lpszCalledParty, LPCSTR lpszComment)
#uselib "TAPI32.dll"
#cfunc global tapiRequestMediaCallA "tapiRequestMediaCallA" intptr, intptr, str, str, int, int, str, str, str, str
; res = tapiRequestMediaCallA(hwnd, wRequestID, lpszDeviceClass, lpDeviceID, dwSize, dwSecure, lpszDestAddress, lpszAppName, lpszCalledParty, lpszComment)
; hwnd : HWND -> "intptr"
; wRequestID : WPARAM -> "intptr"
; lpszDeviceClass : LPCSTR -> "str"
; lpDeviceID : LPCSTR -> "str"
; dwSize : DWORD -> "int"
; dwSecure : DWORD -> "int"
; lpszDestAddress : LPCSTR -> "str"
; lpszAppName : LPCSTR -> "str"
; lpszCalledParty : LPCSTR -> "str"
; lpszComment : LPCSTR -> "str"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	tapi32 = windows.NewLazySystemDLL("TAPI32.dll")
	proctapiRequestMediaCallA = tapi32.NewProc("tapiRequestMediaCallA")
)

// hwnd (HWND), wRequestID (WPARAM), lpszDeviceClass (LPCSTR), lpDeviceID (LPCSTR), dwSize (DWORD), dwSecure (DWORD), lpszDestAddress (LPCSTR), lpszAppName (LPCSTR), lpszCalledParty (LPCSTR), lpszComment (LPCSTR)
r1, _, err := proctapiRequestMediaCallA.Call(
	uintptr(hwnd),
	uintptr(wRequestID),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(lpszDeviceClass))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(lpDeviceID))),
	uintptr(dwSize),
	uintptr(dwSecure),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(lpszDestAddress))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(lpszAppName))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(lpszCalledParty))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(lpszComment))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function tapiRequestMediaCallA(
  hwnd: THandle;   // HWND
  wRequestID: NativeUInt;   // WPARAM
  lpszDeviceClass: PAnsiChar;   // LPCSTR
  lpDeviceID: PAnsiChar;   // LPCSTR
  dwSize: DWORD;   // DWORD
  dwSecure: DWORD;   // DWORD
  lpszDestAddress: PAnsiChar;   // LPCSTR
  lpszAppName: PAnsiChar;   // LPCSTR
  lpszCalledParty: PAnsiChar;   // LPCSTR
  lpszComment: PAnsiChar   // LPCSTR
): Integer; stdcall;
  external 'TAPI32.dll' name 'tapiRequestMediaCallA';
result := DllCall("TAPI32\tapiRequestMediaCallA"
    , "Ptr", hwnd   ; HWND
    , "UPtr", wRequestID   ; WPARAM
    , "AStr", lpszDeviceClass   ; LPCSTR
    , "AStr", lpDeviceID   ; LPCSTR
    , "UInt", dwSize   ; DWORD
    , "UInt", dwSecure   ; DWORD
    , "AStr", lpszDestAddress   ; LPCSTR
    , "AStr", lpszAppName   ; LPCSTR
    , "AStr", lpszCalledParty   ; LPCSTR
    , "AStr", lpszComment   ; LPCSTR
    , "Int")   ; return: INT
●tapiRequestMediaCallA(hwnd, wRequestID, lpszDeviceClass, lpDeviceID, dwSize, dwSecure, lpszDestAddress, lpszAppName, lpszCalledParty, lpszComment) = DLL("TAPI32.dll", "int tapiRequestMediaCallA(void*, int, char*, char*, dword, dword, char*, char*, char*, char*)")
# 呼び出し: tapiRequestMediaCallA(hwnd, wRequestID, lpszDeviceClass, lpDeviceID, dwSize, dwSecure, lpszDestAddress, lpszAppName, lpszCalledParty, lpszComment)
# hwnd : HWND -> "void*"
# wRequestID : WPARAM -> "int"
# lpszDeviceClass : LPCSTR -> "char*"
# lpDeviceID : LPCSTR -> "char*"
# dwSize : DWORD -> "dword"
# dwSecure : DWORD -> "dword"
# lpszDestAddress : LPCSTR -> "char*"
# lpszAppName : LPCSTR -> "char*"
# lpszCalledParty : LPCSTR -> "char*"
# lpszComment : LPCSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "tapi32" fn tapiRequestMediaCallA(
    hwnd: ?*anyopaque, // HWND
    wRequestID: usize, // WPARAM
    lpszDeviceClass: [*c]const u8, // LPCSTR
    lpDeviceID: [*c]const u8, // LPCSTR
    dwSize: u32, // DWORD
    dwSecure: u32, // DWORD
    lpszDestAddress: [*c]const u8, // LPCSTR
    lpszAppName: [*c]const u8, // LPCSTR
    lpszCalledParty: [*c]const u8, // LPCSTR
    lpszComment: [*c]const u8 // LPCSTR
) callconv(std.os.windows.WINAPI) i32;
proc tapiRequestMediaCallA(
    hwnd: pointer,  # HWND
    wRequestID: uint,  # WPARAM
    lpszDeviceClass: cstring,  # LPCSTR
    lpDeviceID: cstring,  # LPCSTR
    dwSize: uint32,  # DWORD
    dwSecure: uint32,  # DWORD
    lpszDestAddress: cstring,  # LPCSTR
    lpszAppName: cstring,  # LPCSTR
    lpszCalledParty: cstring,  # LPCSTR
    lpszComment: cstring  # LPCSTR
): int32 {.importc: "tapiRequestMediaCallA", stdcall, dynlib: "TAPI32.dll".}
pragma(lib, "tapi32");
extern(Windows)
int tapiRequestMediaCallA(
    void* hwnd,   // HWND
    size_t wRequestID,   // WPARAM
    const(char)* lpszDeviceClass,   // LPCSTR
    const(char)* lpDeviceID,   // LPCSTR
    uint dwSize,   // DWORD
    uint dwSecure,   // DWORD
    const(char)* lpszDestAddress,   // LPCSTR
    const(char)* lpszAppName,   // LPCSTR
    const(char)* lpszCalledParty,   // LPCSTR
    const(char)* lpszComment   // LPCSTR
);
ccall((:tapiRequestMediaCallA, "TAPI32.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Csize_t, Cstring, Cstring, UInt32, UInt32, Cstring, Cstring, Cstring, Cstring),
      hwnd, wRequestID, lpszDeviceClass, lpDeviceID, dwSize, dwSecure, lpszDestAddress, lpszAppName, lpszCalledParty, lpszComment)
# hwnd : HWND -> Ptr{Cvoid}
# wRequestID : WPARAM -> Csize_t
# lpszDeviceClass : LPCSTR -> Cstring
# lpDeviceID : LPCSTR -> Cstring
# dwSize : DWORD -> UInt32
# dwSecure : DWORD -> UInt32
# lpszDestAddress : LPCSTR -> Cstring
# lpszAppName : LPCSTR -> Cstring
# lpszCalledParty : LPCSTR -> Cstring
# lpszComment : LPCSTR -> Cstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t tapiRequestMediaCallA(
    void* hwnd,
    uintptr_t wRequestID,
    const char* lpszDeviceClass,
    const char* lpDeviceID,
    uint32_t dwSize,
    uint32_t dwSecure,
    const char* lpszDestAddress,
    const char* lpszAppName,
    const char* lpszCalledParty,
    const char* lpszComment);
]]
local tapi32 = ffi.load("tapi32")
-- tapi32.tapiRequestMediaCallA(hwnd, wRequestID, lpszDeviceClass, lpDeviceID, dwSize, dwSecure, lpszDestAddress, lpszAppName, lpszCalledParty, lpszComment)
-- hwnd : HWND
-- wRequestID : WPARAM
-- lpszDeviceClass : LPCSTR
-- lpDeviceID : LPCSTR
-- dwSize : DWORD
-- dwSecure : DWORD
-- lpszDestAddress : LPCSTR
-- lpszAppName : LPCSTR
-- lpszCalledParty : LPCSTR
-- lpszComment : LPCSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('TAPI32.dll');
const tapiRequestMediaCallA = lib.func('__stdcall', 'tapiRequestMediaCallA', 'int32_t', ['void *', 'uintptr_t', 'str', 'str', 'uint32_t', 'uint32_t', 'str', 'str', 'str', 'str']);
// tapiRequestMediaCallA(hwnd, wRequestID, lpszDeviceClass, lpDeviceID, dwSize, dwSecure, lpszDestAddress, lpszAppName, lpszCalledParty, lpszComment)
// hwnd : HWND -> 'void *'
// wRequestID : WPARAM -> 'uintptr_t'
// lpszDeviceClass : LPCSTR -> 'str'
// lpDeviceID : LPCSTR -> 'str'
// dwSize : DWORD -> 'uint32_t'
// dwSecure : DWORD -> 'uint32_t'
// lpszDestAddress : LPCSTR -> 'str'
// lpszAppName : LPCSTR -> 'str'
// lpszCalledParty : LPCSTR -> 'str'
// lpszComment : LPCSTR -> 'str'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("TAPI32.dll", {
  tapiRequestMediaCallA: { parameters: ["pointer", "usize", "buffer", "buffer", "u32", "u32", "buffer", "buffer", "buffer", "buffer"], result: "i32" },
});
// lib.symbols.tapiRequestMediaCallA(hwnd, wRequestID, lpszDeviceClass, lpDeviceID, dwSize, dwSecure, lpszDestAddress, lpszAppName, lpszCalledParty, lpszComment)
// hwnd : HWND -> "pointer"
// wRequestID : WPARAM -> "usize"
// lpszDeviceClass : LPCSTR -> "buffer"
// lpDeviceID : LPCSTR -> "buffer"
// dwSize : DWORD -> "u32"
// dwSecure : DWORD -> "u32"
// lpszDestAddress : LPCSTR -> "buffer"
// lpszAppName : LPCSTR -> "buffer"
// lpszCalledParty : LPCSTR -> "buffer"
// lpszComment : LPCSTR -> "buffer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t tapiRequestMediaCallA(
    void* hwnd,
    size_t wRequestID,
    const char* lpszDeviceClass,
    const char* lpDeviceID,
    uint32_t dwSize,
    uint32_t dwSecure,
    const char* lpszDestAddress,
    const char* lpszAppName,
    const char* lpszCalledParty,
    const char* lpszComment);
C, "TAPI32.dll");
// $ffi->tapiRequestMediaCallA(hwnd, wRequestID, lpszDeviceClass, lpDeviceID, dwSize, dwSecure, lpszDestAddress, lpszAppName, lpszCalledParty, lpszComment);
// hwnd : HWND
// wRequestID : WPARAM
// lpszDeviceClass : LPCSTR
// lpDeviceID : LPCSTR
// dwSize : DWORD
// dwSecure : DWORD
// lpszDestAddress : LPCSTR
// lpszAppName : LPCSTR
// lpszCalledParty : LPCSTR
// lpszComment : LPCSTR
// 構造体/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.ASCII_OPTIONS);
    int tapiRequestMediaCallA(
        Pointer hwnd,   // HWND
        long wRequestID,   // WPARAM
        String lpszDeviceClass,   // LPCSTR
        String lpDeviceID,   // LPCSTR
        int dwSize,   // DWORD
        int dwSecure,   // DWORD
        String lpszDestAddress,   // LPCSTR
        String lpszAppName,   // LPCSTR
        String lpszCalledParty,   // LPCSTR
        String lpszComment   // LPCSTR
    );
}
@[Link("tapi32")]
lib LibTAPI32
  fun tapiRequestMediaCallA = tapiRequestMediaCallA(
    hwnd : Void*,   # HWND
    wRequestID : LibC::SizeT,   # WPARAM
    lpszDeviceClass : UInt8*,   # LPCSTR
    lpDeviceID : UInt8*,   # LPCSTR
    dwSize : UInt32,   # DWORD
    dwSecure : UInt32,   # DWORD
    lpszDestAddress : UInt8*,   # LPCSTR
    lpszAppName : UInt8*,   # LPCSTR
    lpszCalledParty : UInt8*,   # LPCSTR
    lpszComment : UInt8*   # LPCSTR
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef tapiRequestMediaCallANative = Int32 Function(Pointer<Void>, UintPtr, Pointer<Utf8>, Pointer<Utf8>, Uint32, Uint32, Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>);
typedef tapiRequestMediaCallADart = int Function(Pointer<Void>, int, Pointer<Utf8>, Pointer<Utf8>, int, int, Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>);
final tapiRequestMediaCallA = DynamicLibrary.open('TAPI32.dll')
    .lookupFunction<tapiRequestMediaCallANative, tapiRequestMediaCallADart>('tapiRequestMediaCallA');
// hwnd : HWND -> Pointer<Void>
// wRequestID : WPARAM -> UintPtr
// lpszDeviceClass : LPCSTR -> Pointer<Utf8>
// lpDeviceID : LPCSTR -> Pointer<Utf8>
// dwSize : DWORD -> Uint32
// dwSecure : DWORD -> Uint32
// lpszDestAddress : LPCSTR -> Pointer<Utf8>
// lpszAppName : LPCSTR -> Pointer<Utf8>
// lpszCalledParty : LPCSTR -> Pointer<Utf8>
// lpszComment : LPCSTR -> Pointer<Utf8>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function tapiRequestMediaCallA(
  hwnd: THandle;   // HWND
  wRequestID: NativeUInt;   // WPARAM
  lpszDeviceClass: PAnsiChar;   // LPCSTR
  lpDeviceID: PAnsiChar;   // LPCSTR
  dwSize: DWORD;   // DWORD
  dwSecure: DWORD;   // DWORD
  lpszDestAddress: PAnsiChar;   // LPCSTR
  lpszAppName: PAnsiChar;   // LPCSTR
  lpszCalledParty: PAnsiChar;   // LPCSTR
  lpszComment: PAnsiChar   // LPCSTR
): Integer; stdcall;
  external 'TAPI32.dll' name 'tapiRequestMediaCallA';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "tapiRequestMediaCallA"
  c_tapiRequestMediaCallA :: Ptr () -> CUIntPtr -> CString -> CString -> Word32 -> Word32 -> CString -> CString -> CString -> CString -> IO Int32
-- hwnd : HWND -> Ptr ()
-- wRequestID : WPARAM -> CUIntPtr
-- lpszDeviceClass : LPCSTR -> CString
-- lpDeviceID : LPCSTR -> CString
-- dwSize : DWORD -> Word32
-- dwSecure : DWORD -> Word32
-- lpszDestAddress : LPCSTR -> CString
-- lpszAppName : LPCSTR -> CString
-- lpszCalledParty : LPCSTR -> CString
-- lpszComment : LPCSTR -> CString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let tapirequestmediacalla =
  foreign "tapiRequestMediaCallA"
    ((ptr void) @-> size_t @-> string @-> string @-> uint32_t @-> uint32_t @-> string @-> string @-> string @-> string @-> returning int32_t)
(* hwnd : HWND -> (ptr void) *)
(* wRequestID : WPARAM -> size_t *)
(* lpszDeviceClass : LPCSTR -> string *)
(* lpDeviceID : LPCSTR -> string *)
(* dwSize : DWORD -> uint32_t *)
(* dwSecure : DWORD -> uint32_t *)
(* lpszDestAddress : LPCSTR -> string *)
(* lpszAppName : LPCSTR -> string *)
(* lpszCalledParty : LPCSTR -> string *)
(* lpszComment : LPCSTR -> string *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library tapi32 (t "TAPI32.dll"))
(cffi:use-foreign-library tapi32)

(cffi:defcfun ("tapiRequestMediaCallA" tapi-request-media-call-a :convention :stdcall) :int32
  (hwnd :pointer)   ; HWND
  (w-request-id :uint64)   ; WPARAM
  (lpsz-device-class :string)   ; LPCSTR
  (lp-device-id :string)   ; LPCSTR
  (dw-size :uint32)   ; DWORD
  (dw-secure :uint32)   ; DWORD
  (lpsz-dest-address :string)   ; LPCSTR
  (lpsz-app-name :string)   ; LPCSTR
  (lpsz-called-party :string)   ; LPCSTR
  (lpsz-comment :string))   ; LPCSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $tapiRequestMediaCallA = Win32::API::More->new('TAPI32',
    'int tapiRequestMediaCallA(HANDLE hwnd, WPARAM wRequestID, LPCSTR lpszDeviceClass, LPCSTR lpDeviceID, DWORD dwSize, DWORD dwSecure, LPCSTR lpszDestAddress, LPCSTR lpszAppName, LPCSTR lpszCalledParty, LPCSTR lpszComment)');
# my $ret = $tapiRequestMediaCallA->Call($hwnd, $wRequestID, $lpszDeviceClass, $lpDeviceID, $dwSize, $dwSecure, $lpszDestAddress, $lpszAppName, $lpszCalledParty, $lpszComment);
# hwnd : HWND -> HANDLE
# wRequestID : WPARAM -> WPARAM
# lpszDeviceClass : LPCSTR -> LPCSTR
# lpDeviceID : LPCSTR -> LPCSTR
# dwSize : DWORD -> DWORD
# dwSecure : DWORD -> DWORD
# lpszDestAddress : LPCSTR -> LPCSTR
# lpszAppName : LPCSTR -> LPCSTR
# lpszCalledParty : LPCSTR -> LPCSTR
# lpszComment : LPCSTR -> LPCSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

文字セット違い