ホーム › Devices.Tapi › lineGetIDW
lineGetIDW
関数回線等に関連するデバイス識別子を取得する(Unicode版)。
シグネチャ
// TAPI32.dll (Unicode / -W)
#include <windows.h>
INT lineGetIDW(
DWORD hLine,
DWORD dwAddressID,
DWORD hCall,
DWORD dwSelect,
VARSTRING* lpDeviceID,
LPCWSTR lpszDeviceClass
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hLine | DWORD | in | IDを取得する対象の開いた回線のハンドル。 |
| dwAddressID | DWORD | in | 回線上のアドレスを識別する0起点のアドレスID。 |
| hCall | DWORD | in | IDを取得する通話のハンドル。dwSelectで通話を選択する場合に指定する。 |
| dwSelect | DWORD | in | ID取得対象を回線・アドレス・通話のいずれにするかを示すLINECALLSELECT_定数。 |
| lpDeviceID | VARSTRING* | inout | デバイス識別情報を受け取るVARSTRING構造体へのポインタ。dwTotalSizeを事前設定する。 |
| lpszDeviceClass | LPCWSTR | in | 取得するIDのデバイスクラスを示すUnicode文字列。例として"tapi/line"や"comm"等を指定する。 |
戻り値の型: INT
各言語での呼び出し定義
// TAPI32.dll (Unicode / -W)
#include <windows.h>
INT lineGetIDW(
DWORD hLine,
DWORD dwAddressID,
DWORD hCall,
DWORD dwSelect,
VARSTRING* lpDeviceID,
LPCWSTR lpszDeviceClass
);[DllImport("TAPI32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int lineGetIDW(
uint hLine, // DWORD
uint dwAddressID, // DWORD
uint hCall, // DWORD
uint dwSelect, // DWORD
IntPtr lpDeviceID, // VARSTRING* in/out
[MarshalAs(UnmanagedType.LPWStr)] string lpszDeviceClass // LPCWSTR
);<DllImport("TAPI32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function lineGetIDW(
hLine As UInteger, ' DWORD
dwAddressID As UInteger, ' DWORD
hCall As UInteger, ' DWORD
dwSelect As UInteger, ' DWORD
lpDeviceID As IntPtr, ' VARSTRING* in/out
<MarshalAs(UnmanagedType.LPWStr)> lpszDeviceClass As String ' LPCWSTR
) As Integer
End Function' hLine : DWORD
' dwAddressID : DWORD
' hCall : DWORD
' dwSelect : DWORD
' lpDeviceID : VARSTRING* in/out
' lpszDeviceClass : LPCWSTR
Declare PtrSafe Function lineGetIDW Lib "tapi32" ( _
ByVal hLine As Long, _
ByVal dwAddressID As Long, _
ByVal hCall As Long, _
ByVal dwSelect As Long, _
ByVal lpDeviceID As LongPtr, _
ByVal lpszDeviceClass 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
lineGetIDW = ctypes.windll.tapi32.lineGetIDW
lineGetIDW.restype = ctypes.c_int
lineGetIDW.argtypes = [
wintypes.DWORD, # hLine : DWORD
wintypes.DWORD, # dwAddressID : DWORD
wintypes.DWORD, # hCall : DWORD
wintypes.DWORD, # dwSelect : DWORD
ctypes.c_void_p, # lpDeviceID : VARSTRING* in/out
wintypes.LPCWSTR, # lpszDeviceClass : LPCWSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('TAPI32.dll')
lineGetIDW = Fiddle::Function.new(
lib['lineGetIDW'],
[
-Fiddle::TYPE_INT, # hLine : DWORD
-Fiddle::TYPE_INT, # dwAddressID : DWORD
-Fiddle::TYPE_INT, # hCall : DWORD
-Fiddle::TYPE_INT, # dwSelect : DWORD
Fiddle::TYPE_VOIDP, # lpDeviceID : VARSTRING* in/out
Fiddle::TYPE_VOIDP, # lpszDeviceClass : LPCWSTR
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "tapi32")]
extern "system" {
fn lineGetIDW(
hLine: u32, // DWORD
dwAddressID: u32, // DWORD
hCall: u32, // DWORD
dwSelect: u32, // DWORD
lpDeviceID: *mut VARSTRING, // VARSTRING* in/out
lpszDeviceClass: *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 lineGetIDW(uint hLine, uint dwAddressID, uint hCall, uint dwSelect, IntPtr lpDeviceID, [MarshalAs(UnmanagedType.LPWStr)] string lpszDeviceClass);
"@
$api = Add-Type -MemberDefinition $sig -Name 'TAPI32_lineGetIDW' -Namespace Win32 -PassThru
# $api::lineGetIDW(hLine, dwAddressID, hCall, dwSelect, lpDeviceID, lpszDeviceClass)#uselib "TAPI32.dll"
#func global lineGetIDW "lineGetIDW" wptr, wptr, wptr, wptr, wptr, wptr
; lineGetIDW hLine, dwAddressID, hCall, dwSelect, varptr(lpDeviceID), lpszDeviceClass ; 戻り値は stat
; hLine : DWORD -> "wptr"
; dwAddressID : DWORD -> "wptr"
; hCall : DWORD -> "wptr"
; dwSelect : DWORD -> "wptr"
; lpDeviceID : VARSTRING* in/out -> "wptr"
; lpszDeviceClass : LPCWSTR -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "TAPI32.dll" #cfunc global lineGetIDW "lineGetIDW" int, int, int, int, var, wstr ; res = lineGetIDW(hLine, dwAddressID, hCall, dwSelect, lpDeviceID, lpszDeviceClass) ; hLine : DWORD -> "int" ; dwAddressID : DWORD -> "int" ; hCall : DWORD -> "int" ; dwSelect : DWORD -> "int" ; lpDeviceID : VARSTRING* in/out -> "var" ; lpszDeviceClass : LPCWSTR -> "wstr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "TAPI32.dll" #cfunc global lineGetIDW "lineGetIDW" int, int, int, int, sptr, wstr ; res = lineGetIDW(hLine, dwAddressID, hCall, dwSelect, varptr(lpDeviceID), lpszDeviceClass) ; hLine : DWORD -> "int" ; dwAddressID : DWORD -> "int" ; hCall : DWORD -> "int" ; dwSelect : DWORD -> "int" ; lpDeviceID : VARSTRING* in/out -> "sptr" ; lpszDeviceClass : LPCWSTR -> "wstr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT lineGetIDW(DWORD hLine, DWORD dwAddressID, DWORD hCall, DWORD dwSelect, VARSTRING* lpDeviceID, LPCWSTR lpszDeviceClass) #uselib "TAPI32.dll" #cfunc global lineGetIDW "lineGetIDW" int, int, int, int, var, wstr ; res = lineGetIDW(hLine, dwAddressID, hCall, dwSelect, lpDeviceID, lpszDeviceClass) ; hLine : DWORD -> "int" ; dwAddressID : DWORD -> "int" ; hCall : DWORD -> "int" ; dwSelect : DWORD -> "int" ; lpDeviceID : VARSTRING* in/out -> "var" ; lpszDeviceClass : LPCWSTR -> "wstr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT lineGetIDW(DWORD hLine, DWORD dwAddressID, DWORD hCall, DWORD dwSelect, VARSTRING* lpDeviceID, LPCWSTR lpszDeviceClass) #uselib "TAPI32.dll" #cfunc global lineGetIDW "lineGetIDW" int, int, int, int, intptr, wstr ; res = lineGetIDW(hLine, dwAddressID, hCall, dwSelect, varptr(lpDeviceID), lpszDeviceClass) ; hLine : DWORD -> "int" ; dwAddressID : DWORD -> "int" ; hCall : DWORD -> "int" ; dwSelect : DWORD -> "int" ; lpDeviceID : VARSTRING* in/out -> "intptr" ; lpszDeviceClass : LPCWSTR -> "wstr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
tapi32 = windows.NewLazySystemDLL("TAPI32.dll")
proclineGetIDW = tapi32.NewProc("lineGetIDW")
)
// hLine (DWORD), dwAddressID (DWORD), hCall (DWORD), dwSelect (DWORD), lpDeviceID (VARSTRING* in/out), lpszDeviceClass (LPCWSTR)
r1, _, err := proclineGetIDW.Call(
uintptr(hLine),
uintptr(dwAddressID),
uintptr(hCall),
uintptr(dwSelect),
uintptr(lpDeviceID),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszDeviceClass))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction lineGetIDW(
hLine: DWORD; // DWORD
dwAddressID: DWORD; // DWORD
hCall: DWORD; // DWORD
dwSelect: DWORD; // DWORD
lpDeviceID: Pointer; // VARSTRING* in/out
lpszDeviceClass: PWideChar // LPCWSTR
): Integer; stdcall;
external 'TAPI32.dll' name 'lineGetIDW';result := DllCall("TAPI32\lineGetIDW"
, "UInt", hLine ; DWORD
, "UInt", dwAddressID ; DWORD
, "UInt", hCall ; DWORD
, "UInt", dwSelect ; DWORD
, "Ptr", lpDeviceID ; VARSTRING* in/out
, "WStr", lpszDeviceClass ; LPCWSTR
, "Int") ; return: INT●lineGetIDW(hLine, dwAddressID, hCall, dwSelect, lpDeviceID, lpszDeviceClass) = DLL("TAPI32.dll", "int lineGetIDW(dword, dword, dword, dword, void*, char*)")
# 呼び出し: lineGetIDW(hLine, dwAddressID, hCall, dwSelect, lpDeviceID, lpszDeviceClass)
# hLine : DWORD -> "dword"
# dwAddressID : DWORD -> "dword"
# hCall : DWORD -> "dword"
# dwSelect : DWORD -> "dword"
# lpDeviceID : VARSTRING* in/out -> "void*"
# lpszDeviceClass : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。const std = @import("std");
extern "tapi32" fn lineGetIDW(
hLine: u32, // DWORD
dwAddressID: u32, // DWORD
hCall: u32, // DWORD
dwSelect: u32, // DWORD
lpDeviceID: [*c]VARSTRING, // VARSTRING* in/out
lpszDeviceClass: [*c]const u16 // LPCWSTR
) callconv(std.os.windows.WINAPI) i32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc lineGetIDW(
hLine: uint32, # DWORD
dwAddressID: uint32, # DWORD
hCall: uint32, # DWORD
dwSelect: uint32, # DWORD
lpDeviceID: ptr VARSTRING, # VARSTRING* in/out
lpszDeviceClass: WideCString # LPCWSTR
): int32 {.importc: "lineGetIDW", stdcall, dynlib: "TAPI32.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "tapi32");
extern(Windows)
int lineGetIDW(
uint hLine, // DWORD
uint dwAddressID, // DWORD
uint hCall, // DWORD
uint dwSelect, // DWORD
VARSTRING* lpDeviceID, // VARSTRING* in/out
const(wchar)* lpszDeviceClass // LPCWSTR
);ccall((:lineGetIDW, "TAPI32.dll"), stdcall, Int32,
(UInt32, UInt32, UInt32, UInt32, Ptr{VARSTRING}, Cwstring),
hLine, dwAddressID, hCall, dwSelect, lpDeviceID, lpszDeviceClass)
# hLine : DWORD -> UInt32
# dwAddressID : DWORD -> UInt32
# hCall : DWORD -> UInt32
# dwSelect : DWORD -> UInt32
# lpDeviceID : VARSTRING* in/out -> Ptr{VARSTRING}
# lpszDeviceClass : LPCWSTR -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
int32_t lineGetIDW(
uint32_t hLine,
uint32_t dwAddressID,
uint32_t hCall,
uint32_t dwSelect,
void* lpDeviceID,
const uint16_t* lpszDeviceClass);
]]
local tapi32 = ffi.load("tapi32")
-- tapi32.lineGetIDW(hLine, dwAddressID, hCall, dwSelect, lpDeviceID, lpszDeviceClass)
-- hLine : DWORD
-- dwAddressID : DWORD
-- hCall : DWORD
-- dwSelect : DWORD
-- lpDeviceID : VARSTRING* in/out
-- lpszDeviceClass : 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 lineGetIDW = lib.func('__stdcall', 'lineGetIDW', 'int32_t', ['uint32_t', 'uint32_t', 'uint32_t', 'uint32_t', 'void *', 'str16']);
// lineGetIDW(hLine, dwAddressID, hCall, dwSelect, lpDeviceID, lpszDeviceClass)
// hLine : DWORD -> 'uint32_t'
// dwAddressID : DWORD -> 'uint32_t'
// hCall : DWORD -> 'uint32_t'
// dwSelect : DWORD -> 'uint32_t'
// lpDeviceID : VARSTRING* in/out -> 'void *'
// lpszDeviceClass : LPCWSTR -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("TAPI32.dll", {
lineGetIDW: { parameters: ["u32", "u32", "u32", "u32", "pointer", "buffer"], result: "i32" },
});
// lib.symbols.lineGetIDW(hLine, dwAddressID, hCall, dwSelect, lpDeviceID, lpszDeviceClass)
// hLine : DWORD -> "u32"
// dwAddressID : DWORD -> "u32"
// hCall : DWORD -> "u32"
// dwSelect : DWORD -> "u32"
// lpDeviceID : VARSTRING* in/out -> "pointer"
// lpszDeviceClass : LPCWSTR -> "buffer"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t lineGetIDW(
uint32_t hLine,
uint32_t dwAddressID,
uint32_t hCall,
uint32_t dwSelect,
void* lpDeviceID,
const uint16_t* lpszDeviceClass);
C, "TAPI32.dll");
// $ffi->lineGetIDW(hLine, dwAddressID, hCall, dwSelect, lpDeviceID, lpszDeviceClass);
// hLine : DWORD
// dwAddressID : DWORD
// hCall : DWORD
// dwSelect : DWORD
// lpDeviceID : VARSTRING* in/out
// lpszDeviceClass : 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 lineGetIDW(
int hLine, // DWORD
int dwAddressID, // DWORD
int hCall, // DWORD
int dwSelect, // DWORD
Pointer lpDeviceID, // VARSTRING* in/out
WString lpszDeviceClass // LPCWSTR
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("tapi32")]
lib LibTAPI32
fun lineGetIDW = lineGetIDW(
hLine : UInt32, # DWORD
dwAddressID : UInt32, # DWORD
hCall : UInt32, # DWORD
dwSelect : UInt32, # DWORD
lpDeviceID : VARSTRING*, # VARSTRING* in/out
lpszDeviceClass : 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 lineGetIDWNative = Int32 Function(Uint32, Uint32, Uint32, Uint32, Pointer<Void>, Pointer<Utf16>);
typedef lineGetIDWDart = int Function(int, int, int, int, Pointer<Void>, Pointer<Utf16>);
final lineGetIDW = DynamicLibrary.open('TAPI32.dll')
.lookupFunction<lineGetIDWNative, lineGetIDWDart>('lineGetIDW');
// hLine : DWORD -> Uint32
// dwAddressID : DWORD -> Uint32
// hCall : DWORD -> Uint32
// dwSelect : DWORD -> Uint32
// lpDeviceID : VARSTRING* in/out -> Pointer<Void>
// lpszDeviceClass : LPCWSTR -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function lineGetIDW(
hLine: DWORD; // DWORD
dwAddressID: DWORD; // DWORD
hCall: DWORD; // DWORD
dwSelect: DWORD; // DWORD
lpDeviceID: Pointer; // VARSTRING* in/out
lpszDeviceClass: PWideChar // LPCWSTR
): Integer; stdcall;
external 'TAPI32.dll' name 'lineGetIDW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "lineGetIDW"
c_lineGetIDW :: Word32 -> Word32 -> Word32 -> Word32 -> Ptr () -> CWString -> IO Int32
-- hLine : DWORD -> Word32
-- dwAddressID : DWORD -> Word32
-- hCall : DWORD -> Word32
-- dwSelect : DWORD -> Word32
-- lpDeviceID : VARSTRING* in/out -> Ptr ()
-- lpszDeviceClass : LPCWSTR -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let linegetidw =
foreign "lineGetIDW"
(uint32_t @-> uint32_t @-> uint32_t @-> uint32_t @-> (ptr void) @-> (ptr uint16_t) @-> returning int32_t)
(* hLine : DWORD -> uint32_t *)
(* dwAddressID : DWORD -> uint32_t *)
(* hCall : DWORD -> uint32_t *)
(* dwSelect : DWORD -> uint32_t *)
(* lpDeviceID : VARSTRING* in/out -> (ptr void) *)
(* lpszDeviceClass : 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 ("lineGetIDW" line-get-idw :convention :stdcall) :int32
(h-line :uint32) ; DWORD
(dw-address-id :uint32) ; DWORD
(h-call :uint32) ; DWORD
(dw-select :uint32) ; DWORD
(lp-device-id :pointer) ; VARSTRING* in/out
(lpsz-device-class (:string :encoding :utf-16le))) ; LPCWSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $lineGetIDW = Win32::API::More->new('TAPI32',
'int lineGetIDW(DWORD hLine, DWORD dwAddressID, DWORD hCall, DWORD dwSelect, LPVOID lpDeviceID, LPCWSTR lpszDeviceClass)');
# my $ret = $lineGetIDW->Call($hLine, $dwAddressID, $hCall, $dwSelect, $lpDeviceID, $lpszDeviceClass);
# hLine : DWORD -> DWORD
# dwAddressID : DWORD -> DWORD
# hCall : DWORD -> DWORD
# dwSelect : DWORD -> DWORD
# lpDeviceID : VARSTRING* in/out -> LPVOID
# lpszDeviceClass : LPCWSTR -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
文字セット違い
- f lineGetIDA (ANSI版) — 回線等に関連するデバイス識別子を取得する(ANSI版)。
使用する型