ホーム › Devices.Tapi › phoneOpen
phoneOpen
関数指定した電話デバイスを開いてハンドルを取得する。
シグネチャ
// TAPI32.dll
#include <windows.h>
INT phoneOpen(
DWORD hPhoneApp,
DWORD dwDeviceID,
DWORD* lphPhone,
DWORD dwAPIVersion,
DWORD dwExtVersion,
UINT_PTR dwCallbackInstance,
DWORD dwPrivilege
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hPhoneApp | DWORD | in | phoneInitializeで取得したアプリケーションの使用ハンドル。 |
| dwDeviceID | DWORD | in | オープンする電話デバイスの識別子。0以上の連番で指定する。 |
| lphPhone | DWORD* | inout | オープンした電話デバイスのハンドルを格納する出力先ポインタ。 |
| dwAPIVersion | DWORD | in | ネゴシエート済みのAPIバージョン番号。 |
| dwExtVersion | DWORD | in | ネゴシエート済みの拡張バージョン番号。未使用時は0。 |
| dwCallbackInstance | UINT_PTR | in | コールバックに渡されるアプリ定義のインスタンスデータ。 |
| dwPrivilege | DWORD | in | 要求する権限(PHONEPRIVILEGE_OWNER/MONITOR)を示すフラグ。 |
戻り値の型: INT
各言語での呼び出し定義
// TAPI32.dll
#include <windows.h>
INT phoneOpen(
DWORD hPhoneApp,
DWORD dwDeviceID,
DWORD* lphPhone,
DWORD dwAPIVersion,
DWORD dwExtVersion,
UINT_PTR dwCallbackInstance,
DWORD dwPrivilege
);[DllImport("TAPI32.dll", ExactSpelling = true)]
static extern int phoneOpen(
uint hPhoneApp, // DWORD
uint dwDeviceID, // DWORD
ref uint lphPhone, // DWORD* in/out
uint dwAPIVersion, // DWORD
uint dwExtVersion, // DWORD
UIntPtr dwCallbackInstance, // UINT_PTR
uint dwPrivilege // DWORD
);<DllImport("TAPI32.dll", ExactSpelling:=True)>
Public Shared Function phoneOpen(
hPhoneApp As UInteger, ' DWORD
dwDeviceID As UInteger, ' DWORD
ByRef lphPhone As UInteger, ' DWORD* in/out
dwAPIVersion As UInteger, ' DWORD
dwExtVersion As UInteger, ' DWORD
dwCallbackInstance As UIntPtr, ' UINT_PTR
dwPrivilege As UInteger ' DWORD
) As Integer
End Function' hPhoneApp : DWORD
' dwDeviceID : DWORD
' lphPhone : DWORD* in/out
' dwAPIVersion : DWORD
' dwExtVersion : DWORD
' dwCallbackInstance : UINT_PTR
' dwPrivilege : DWORD
Declare PtrSafe Function phoneOpen Lib "tapi32" ( _
ByVal hPhoneApp As Long, _
ByVal dwDeviceID As Long, _
ByRef lphPhone As Long, _
ByVal dwAPIVersion As Long, _
ByVal dwExtVersion As Long, _
ByVal dwCallbackInstance As LongPtr, _
ByVal dwPrivilege As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
phoneOpen = ctypes.windll.tapi32.phoneOpen
phoneOpen.restype = ctypes.c_int
phoneOpen.argtypes = [
wintypes.DWORD, # hPhoneApp : DWORD
wintypes.DWORD, # dwDeviceID : DWORD
ctypes.POINTER(wintypes.DWORD), # lphPhone : DWORD* in/out
wintypes.DWORD, # dwAPIVersion : DWORD
wintypes.DWORD, # dwExtVersion : DWORD
ctypes.c_size_t, # dwCallbackInstance : UINT_PTR
wintypes.DWORD, # dwPrivilege : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('TAPI32.dll')
phoneOpen = Fiddle::Function.new(
lib['phoneOpen'],
[
-Fiddle::TYPE_INT, # hPhoneApp : DWORD
-Fiddle::TYPE_INT, # dwDeviceID : DWORD
Fiddle::TYPE_VOIDP, # lphPhone : DWORD* in/out
-Fiddle::TYPE_INT, # dwAPIVersion : DWORD
-Fiddle::TYPE_INT, # dwExtVersion : DWORD
Fiddle::TYPE_UINTPTR_T, # dwCallbackInstance : UINT_PTR
-Fiddle::TYPE_INT, # dwPrivilege : DWORD
],
Fiddle::TYPE_INT)#[link(name = "tapi32")]
extern "system" {
fn phoneOpen(
hPhoneApp: u32, // DWORD
dwDeviceID: u32, // DWORD
lphPhone: *mut u32, // DWORD* in/out
dwAPIVersion: u32, // DWORD
dwExtVersion: u32, // DWORD
dwCallbackInstance: usize, // UINT_PTR
dwPrivilege: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("TAPI32.dll")]
public static extern int phoneOpen(uint hPhoneApp, uint dwDeviceID, ref uint lphPhone, uint dwAPIVersion, uint dwExtVersion, UIntPtr dwCallbackInstance, uint dwPrivilege);
"@
$api = Add-Type -MemberDefinition $sig -Name 'TAPI32_phoneOpen' -Namespace Win32 -PassThru
# $api::phoneOpen(hPhoneApp, dwDeviceID, lphPhone, dwAPIVersion, dwExtVersion, dwCallbackInstance, dwPrivilege)#uselib "TAPI32.dll"
#func global phoneOpen "phoneOpen" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; phoneOpen hPhoneApp, dwDeviceID, varptr(lphPhone), dwAPIVersion, dwExtVersion, dwCallbackInstance, dwPrivilege ; 戻り値は stat
; hPhoneApp : DWORD -> "sptr"
; dwDeviceID : DWORD -> "sptr"
; lphPhone : DWORD* in/out -> "sptr"
; dwAPIVersion : DWORD -> "sptr"
; dwExtVersion : DWORD -> "sptr"
; dwCallbackInstance : UINT_PTR -> "sptr"
; dwPrivilege : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "TAPI32.dll" #cfunc global phoneOpen "phoneOpen" int, int, var, int, int, sptr, int ; res = phoneOpen(hPhoneApp, dwDeviceID, lphPhone, dwAPIVersion, dwExtVersion, dwCallbackInstance, dwPrivilege) ; hPhoneApp : DWORD -> "int" ; dwDeviceID : DWORD -> "int" ; lphPhone : DWORD* in/out -> "var" ; dwAPIVersion : DWORD -> "int" ; dwExtVersion : DWORD -> "int" ; dwCallbackInstance : UINT_PTR -> "sptr" ; dwPrivilege : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "TAPI32.dll" #cfunc global phoneOpen "phoneOpen" int, int, sptr, int, int, sptr, int ; res = phoneOpen(hPhoneApp, dwDeviceID, varptr(lphPhone), dwAPIVersion, dwExtVersion, dwCallbackInstance, dwPrivilege) ; hPhoneApp : DWORD -> "int" ; dwDeviceID : DWORD -> "int" ; lphPhone : DWORD* in/out -> "sptr" ; dwAPIVersion : DWORD -> "int" ; dwExtVersion : DWORD -> "int" ; dwCallbackInstance : UINT_PTR -> "sptr" ; dwPrivilege : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT phoneOpen(DWORD hPhoneApp, DWORD dwDeviceID, DWORD* lphPhone, DWORD dwAPIVersion, DWORD dwExtVersion, UINT_PTR dwCallbackInstance, DWORD dwPrivilege) #uselib "TAPI32.dll" #cfunc global phoneOpen "phoneOpen" int, int, var, int, int, intptr, int ; res = phoneOpen(hPhoneApp, dwDeviceID, lphPhone, dwAPIVersion, dwExtVersion, dwCallbackInstance, dwPrivilege) ; hPhoneApp : DWORD -> "int" ; dwDeviceID : DWORD -> "int" ; lphPhone : DWORD* in/out -> "var" ; dwAPIVersion : DWORD -> "int" ; dwExtVersion : DWORD -> "int" ; dwCallbackInstance : UINT_PTR -> "intptr" ; dwPrivilege : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT phoneOpen(DWORD hPhoneApp, DWORD dwDeviceID, DWORD* lphPhone, DWORD dwAPIVersion, DWORD dwExtVersion, UINT_PTR dwCallbackInstance, DWORD dwPrivilege) #uselib "TAPI32.dll" #cfunc global phoneOpen "phoneOpen" int, int, intptr, int, int, intptr, int ; res = phoneOpen(hPhoneApp, dwDeviceID, varptr(lphPhone), dwAPIVersion, dwExtVersion, dwCallbackInstance, dwPrivilege) ; hPhoneApp : DWORD -> "int" ; dwDeviceID : DWORD -> "int" ; lphPhone : DWORD* in/out -> "intptr" ; dwAPIVersion : DWORD -> "int" ; dwExtVersion : DWORD -> "int" ; dwCallbackInstance : UINT_PTR -> "intptr" ; dwPrivilege : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
tapi32 = windows.NewLazySystemDLL("TAPI32.dll")
procphoneOpen = tapi32.NewProc("phoneOpen")
)
// hPhoneApp (DWORD), dwDeviceID (DWORD), lphPhone (DWORD* in/out), dwAPIVersion (DWORD), dwExtVersion (DWORD), dwCallbackInstance (UINT_PTR), dwPrivilege (DWORD)
r1, _, err := procphoneOpen.Call(
uintptr(hPhoneApp),
uintptr(dwDeviceID),
uintptr(lphPhone),
uintptr(dwAPIVersion),
uintptr(dwExtVersion),
uintptr(dwCallbackInstance),
uintptr(dwPrivilege),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction phoneOpen(
hPhoneApp: DWORD; // DWORD
dwDeviceID: DWORD; // DWORD
lphPhone: Pointer; // DWORD* in/out
dwAPIVersion: DWORD; // DWORD
dwExtVersion: DWORD; // DWORD
dwCallbackInstance: NativeUInt; // UINT_PTR
dwPrivilege: DWORD // DWORD
): Integer; stdcall;
external 'TAPI32.dll' name 'phoneOpen';result := DllCall("TAPI32\phoneOpen"
, "UInt", hPhoneApp ; DWORD
, "UInt", dwDeviceID ; DWORD
, "Ptr", lphPhone ; DWORD* in/out
, "UInt", dwAPIVersion ; DWORD
, "UInt", dwExtVersion ; DWORD
, "UPtr", dwCallbackInstance ; UINT_PTR
, "UInt", dwPrivilege ; DWORD
, "Int") ; return: INT●phoneOpen(hPhoneApp, dwDeviceID, lphPhone, dwAPIVersion, dwExtVersion, dwCallbackInstance, dwPrivilege) = DLL("TAPI32.dll", "int phoneOpen(dword, dword, void*, dword, dword, int, dword)")
# 呼び出し: phoneOpen(hPhoneApp, dwDeviceID, lphPhone, dwAPIVersion, dwExtVersion, dwCallbackInstance, dwPrivilege)
# hPhoneApp : DWORD -> "dword"
# dwDeviceID : DWORD -> "dword"
# lphPhone : DWORD* in/out -> "void*"
# dwAPIVersion : DWORD -> "dword"
# dwExtVersion : DWORD -> "dword"
# dwCallbackInstance : UINT_PTR -> "int"
# dwPrivilege : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "tapi32" fn phoneOpen(
hPhoneApp: u32, // DWORD
dwDeviceID: u32, // DWORD
lphPhone: [*c]u32, // DWORD* in/out
dwAPIVersion: u32, // DWORD
dwExtVersion: u32, // DWORD
dwCallbackInstance: usize, // UINT_PTR
dwPrivilege: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;proc phoneOpen(
hPhoneApp: uint32, # DWORD
dwDeviceID: uint32, # DWORD
lphPhone: ptr uint32, # DWORD* in/out
dwAPIVersion: uint32, # DWORD
dwExtVersion: uint32, # DWORD
dwCallbackInstance: uint, # UINT_PTR
dwPrivilege: uint32 # DWORD
): int32 {.importc: "phoneOpen", stdcall, dynlib: "TAPI32.dll".}pragma(lib, "tapi32");
extern(Windows)
int phoneOpen(
uint hPhoneApp, // DWORD
uint dwDeviceID, // DWORD
uint* lphPhone, // DWORD* in/out
uint dwAPIVersion, // DWORD
uint dwExtVersion, // DWORD
size_t dwCallbackInstance, // UINT_PTR
uint dwPrivilege // DWORD
);ccall((:phoneOpen, "TAPI32.dll"), stdcall, Int32,
(UInt32, UInt32, Ptr{UInt32}, UInt32, UInt32, Csize_t, UInt32),
hPhoneApp, dwDeviceID, lphPhone, dwAPIVersion, dwExtVersion, dwCallbackInstance, dwPrivilege)
# hPhoneApp : DWORD -> UInt32
# dwDeviceID : DWORD -> UInt32
# lphPhone : DWORD* in/out -> Ptr{UInt32}
# dwAPIVersion : DWORD -> UInt32
# dwExtVersion : DWORD -> UInt32
# dwCallbackInstance : UINT_PTR -> Csize_t
# dwPrivilege : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t phoneOpen(
uint32_t hPhoneApp,
uint32_t dwDeviceID,
uint32_t* lphPhone,
uint32_t dwAPIVersion,
uint32_t dwExtVersion,
uintptr_t dwCallbackInstance,
uint32_t dwPrivilege);
]]
local tapi32 = ffi.load("tapi32")
-- tapi32.phoneOpen(hPhoneApp, dwDeviceID, lphPhone, dwAPIVersion, dwExtVersion, dwCallbackInstance, dwPrivilege)
-- hPhoneApp : DWORD
-- dwDeviceID : DWORD
-- lphPhone : DWORD* in/out
-- dwAPIVersion : DWORD
-- dwExtVersion : DWORD
-- dwCallbackInstance : UINT_PTR
-- dwPrivilege : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('TAPI32.dll');
const phoneOpen = lib.func('__stdcall', 'phoneOpen', 'int32_t', ['uint32_t', 'uint32_t', 'uint32_t *', 'uint32_t', 'uint32_t', 'uintptr_t', 'uint32_t']);
// phoneOpen(hPhoneApp, dwDeviceID, lphPhone, dwAPIVersion, dwExtVersion, dwCallbackInstance, dwPrivilege)
// hPhoneApp : DWORD -> 'uint32_t'
// dwDeviceID : DWORD -> 'uint32_t'
// lphPhone : DWORD* in/out -> 'uint32_t *'
// dwAPIVersion : DWORD -> 'uint32_t'
// dwExtVersion : DWORD -> 'uint32_t'
// dwCallbackInstance : UINT_PTR -> 'uintptr_t'
// dwPrivilege : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("TAPI32.dll", {
phoneOpen: { parameters: ["u32", "u32", "pointer", "u32", "u32", "usize", "u32"], result: "i32" },
});
// lib.symbols.phoneOpen(hPhoneApp, dwDeviceID, lphPhone, dwAPIVersion, dwExtVersion, dwCallbackInstance, dwPrivilege)
// hPhoneApp : DWORD -> "u32"
// dwDeviceID : DWORD -> "u32"
// lphPhone : DWORD* in/out -> "pointer"
// dwAPIVersion : DWORD -> "u32"
// dwExtVersion : DWORD -> "u32"
// dwCallbackInstance : UINT_PTR -> "usize"
// dwPrivilege : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t phoneOpen(
uint32_t hPhoneApp,
uint32_t dwDeviceID,
uint32_t* lphPhone,
uint32_t dwAPIVersion,
uint32_t dwExtVersion,
size_t dwCallbackInstance,
uint32_t dwPrivilege);
C, "TAPI32.dll");
// $ffi->phoneOpen(hPhoneApp, dwDeviceID, lphPhone, dwAPIVersion, dwExtVersion, dwCallbackInstance, dwPrivilege);
// hPhoneApp : DWORD
// dwDeviceID : DWORD
// lphPhone : DWORD* in/out
// dwAPIVersion : DWORD
// dwExtVersion : DWORD
// dwCallbackInstance : UINT_PTR
// dwPrivilege : DWORD
// 構造体/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);
int phoneOpen(
int hPhoneApp, // DWORD
int dwDeviceID, // DWORD
IntByReference lphPhone, // DWORD* in/out
int dwAPIVersion, // DWORD
int dwExtVersion, // DWORD
long dwCallbackInstance, // UINT_PTR
int dwPrivilege // DWORD
);
}@[Link("tapi32")]
lib LibTAPI32
fun phoneOpen = phoneOpen(
hPhoneApp : UInt32, # DWORD
dwDeviceID : UInt32, # DWORD
lphPhone : UInt32*, # DWORD* in/out
dwAPIVersion : UInt32, # DWORD
dwExtVersion : UInt32, # DWORD
dwCallbackInstance : LibC::SizeT, # UINT_PTR
dwPrivilege : UInt32 # DWORD
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef phoneOpenNative = Int32 Function(Uint32, Uint32, Pointer<Uint32>, Uint32, Uint32, UintPtr, Uint32);
typedef phoneOpenDart = int Function(int, int, Pointer<Uint32>, int, int, int, int);
final phoneOpen = DynamicLibrary.open('TAPI32.dll')
.lookupFunction<phoneOpenNative, phoneOpenDart>('phoneOpen');
// hPhoneApp : DWORD -> Uint32
// dwDeviceID : DWORD -> Uint32
// lphPhone : DWORD* in/out -> Pointer<Uint32>
// dwAPIVersion : DWORD -> Uint32
// dwExtVersion : DWORD -> Uint32
// dwCallbackInstance : UINT_PTR -> UintPtr
// dwPrivilege : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function phoneOpen(
hPhoneApp: DWORD; // DWORD
dwDeviceID: DWORD; // DWORD
lphPhone: Pointer; // DWORD* in/out
dwAPIVersion: DWORD; // DWORD
dwExtVersion: DWORD; // DWORD
dwCallbackInstance: NativeUInt; // UINT_PTR
dwPrivilege: DWORD // DWORD
): Integer; stdcall;
external 'TAPI32.dll' name 'phoneOpen';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "phoneOpen"
c_phoneOpen :: Word32 -> Word32 -> Ptr Word32 -> Word32 -> Word32 -> CUIntPtr -> Word32 -> IO Int32
-- hPhoneApp : DWORD -> Word32
-- dwDeviceID : DWORD -> Word32
-- lphPhone : DWORD* in/out -> Ptr Word32
-- dwAPIVersion : DWORD -> Word32
-- dwExtVersion : DWORD -> Word32
-- dwCallbackInstance : UINT_PTR -> CUIntPtr
-- dwPrivilege : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let phoneopen =
foreign "phoneOpen"
(uint32_t @-> uint32_t @-> (ptr uint32_t) @-> uint32_t @-> uint32_t @-> size_t @-> uint32_t @-> returning int32_t)
(* hPhoneApp : DWORD -> uint32_t *)
(* dwDeviceID : DWORD -> uint32_t *)
(* lphPhone : DWORD* in/out -> (ptr uint32_t) *)
(* dwAPIVersion : DWORD -> uint32_t *)
(* dwExtVersion : DWORD -> uint32_t *)
(* dwCallbackInstance : UINT_PTR -> size_t *)
(* dwPrivilege : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library tapi32 (t "TAPI32.dll"))
(cffi:use-foreign-library tapi32)
(cffi:defcfun ("phoneOpen" phone-open :convention :stdcall) :int32
(h-phone-app :uint32) ; DWORD
(dw-device-id :uint32) ; DWORD
(lph-phone :pointer) ; DWORD* in/out
(dw-apiversion :uint32) ; DWORD
(dw-ext-version :uint32) ; DWORD
(dw-callback-instance :uint64) ; UINT_PTR
(dw-privilege :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $phoneOpen = Win32::API::More->new('TAPI32',
'int phoneOpen(DWORD hPhoneApp, DWORD dwDeviceID, LPVOID lphPhone, DWORD dwAPIVersion, DWORD dwExtVersion, WPARAM dwCallbackInstance, DWORD dwPrivilege)');
# my $ret = $phoneOpen->Call($hPhoneApp, $dwDeviceID, $lphPhone, $dwAPIVersion, $dwExtVersion, $dwCallbackInstance, $dwPrivilege);
# hPhoneApp : DWORD -> DWORD
# dwDeviceID : DWORD -> DWORD
# lphPhone : DWORD* in/out -> LPVOID
# dwAPIVersion : DWORD -> DWORD
# dwExtVersion : DWORD -> DWORD
# dwCallbackInstance : UINT_PTR -> WPARAM
# dwPrivilege : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。