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

linePickupW

関数
他で保留・着信中の通話を取得して応答する(Unicode版)。
DLLTAPI32.dll文字セットUnicode (-W)呼出規約winapi

シグネチャ

// TAPI32.dll  (Unicode / -W)
#include <windows.h>

INT linePickupW(
    DWORD hLine,
    DWORD dwAddressID,
    DWORD* lphCall,
    LPCWSTR lpszDestAddress,
    LPCWSTR lpszGroupID
);

パラメーター

名前方向説明
hLineDWORDin通話を取り上げる対象の開いた回線のハンドル。
dwAddressIDDWORDin取り上げに使用する0起点のアドレスID。
lphCallDWORD*inout取り上げた通話のハンドルを受け取るDWORDへのポインタ。
lpszDestAddressLPCWSTRin取り上げ対象の鳴動中アドレスを示すUnicode文字列。NULL可。
lpszGroupIDLPCWSTRinピックアップグループのIDを示すUnicode文字列。NULL可。

戻り値の型: INT

各言語での呼び出し定義

// TAPI32.dll  (Unicode / -W)
#include <windows.h>

INT linePickupW(
    DWORD hLine,
    DWORD dwAddressID,
    DWORD* lphCall,
    LPCWSTR lpszDestAddress,
    LPCWSTR lpszGroupID
);
[DllImport("TAPI32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int linePickupW(
    uint hLine,   // DWORD
    uint dwAddressID,   // DWORD
    ref uint lphCall,   // DWORD* in/out
    [MarshalAs(UnmanagedType.LPWStr)] string lpszDestAddress,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string lpszGroupID   // LPCWSTR
);
<DllImport("TAPI32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function linePickupW(
    hLine As UInteger,   ' DWORD
    dwAddressID As UInteger,   ' DWORD
    ByRef lphCall As UInteger,   ' DWORD* in/out
    <MarshalAs(UnmanagedType.LPWStr)> lpszDestAddress As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> lpszGroupID As String   ' LPCWSTR
) As Integer
End Function
' hLine : DWORD
' dwAddressID : DWORD
' lphCall : DWORD* in/out
' lpszDestAddress : LPCWSTR
' lpszGroupID : LPCWSTR
Declare PtrSafe Function linePickupW Lib "tapi32" ( _
    ByVal hLine As Long, _
    ByVal dwAddressID As Long, _
    ByRef lphCall As Long, _
    ByVal lpszDestAddress As LongPtr, _
    ByVal lpszGroupID 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

linePickupW = ctypes.windll.tapi32.linePickupW
linePickupW.restype = ctypes.c_int
linePickupW.argtypes = [
    wintypes.DWORD,  # hLine : DWORD
    wintypes.DWORD,  # dwAddressID : DWORD
    ctypes.POINTER(wintypes.DWORD),  # lphCall : DWORD* in/out
    wintypes.LPCWSTR,  # lpszDestAddress : LPCWSTR
    wintypes.LPCWSTR,  # lpszGroupID : LPCWSTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('TAPI32.dll')
linePickupW = Fiddle::Function.new(
  lib['linePickupW'],
  [
    -Fiddle::TYPE_INT,  # hLine : DWORD
    -Fiddle::TYPE_INT,  # dwAddressID : DWORD
    Fiddle::TYPE_VOIDP,  # lphCall : DWORD* in/out
    Fiddle::TYPE_VOIDP,  # lpszDestAddress : LPCWSTR
    Fiddle::TYPE_VOIDP,  # lpszGroupID : LPCWSTR
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "tapi32")]
extern "system" {
    fn linePickupW(
        hLine: u32,  // DWORD
        dwAddressID: u32,  // DWORD
        lphCall: *mut u32,  // DWORD* in/out
        lpszDestAddress: *const u16,  // LPCWSTR
        lpszGroupID: *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 linePickupW(uint hLine, uint dwAddressID, ref uint lphCall, [MarshalAs(UnmanagedType.LPWStr)] string lpszDestAddress, [MarshalAs(UnmanagedType.LPWStr)] string lpszGroupID);
"@
$api = Add-Type -MemberDefinition $sig -Name 'TAPI32_linePickupW' -Namespace Win32 -PassThru
# $api::linePickupW(hLine, dwAddressID, lphCall, lpszDestAddress, lpszGroupID)
#uselib "TAPI32.dll"
#func global linePickupW "linePickupW" wptr, wptr, wptr, wptr, wptr
; linePickupW hLine, dwAddressID, varptr(lphCall), lpszDestAddress, lpszGroupID   ; 戻り値は stat
; hLine : DWORD -> "wptr"
; dwAddressID : DWORD -> "wptr"
; lphCall : DWORD* in/out -> "wptr"
; lpszDestAddress : LPCWSTR -> "wptr"
; lpszGroupID : LPCWSTR -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "TAPI32.dll"
#cfunc global linePickupW "linePickupW" int, int, var, wstr, wstr
; res = linePickupW(hLine, dwAddressID, lphCall, lpszDestAddress, lpszGroupID)
; hLine : DWORD -> "int"
; dwAddressID : DWORD -> "int"
; lphCall : DWORD* in/out -> "var"
; lpszDestAddress : LPCWSTR -> "wstr"
; lpszGroupID : LPCWSTR -> "wstr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; INT linePickupW(DWORD hLine, DWORD dwAddressID, DWORD* lphCall, LPCWSTR lpszDestAddress, LPCWSTR lpszGroupID)
#uselib "TAPI32.dll"
#cfunc global linePickupW "linePickupW" int, int, var, wstr, wstr
; res = linePickupW(hLine, dwAddressID, lphCall, lpszDestAddress, lpszGroupID)
; hLine : DWORD -> "int"
; dwAddressID : DWORD -> "int"
; lphCall : DWORD* in/out -> "var"
; lpszDestAddress : LPCWSTR -> "wstr"
; lpszGroupID : LPCWSTR -> "wstr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	tapi32 = windows.NewLazySystemDLL("TAPI32.dll")
	proclinePickupW = tapi32.NewProc("linePickupW")
)

// hLine (DWORD), dwAddressID (DWORD), lphCall (DWORD* in/out), lpszDestAddress (LPCWSTR), lpszGroupID (LPCWSTR)
r1, _, err := proclinePickupW.Call(
	uintptr(hLine),
	uintptr(dwAddressID),
	uintptr(lphCall),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszDestAddress))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszGroupID))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function linePickupW(
  hLine: DWORD;   // DWORD
  dwAddressID: DWORD;   // DWORD
  lphCall: Pointer;   // DWORD* in/out
  lpszDestAddress: PWideChar;   // LPCWSTR
  lpszGroupID: PWideChar   // LPCWSTR
): Integer; stdcall;
  external 'TAPI32.dll' name 'linePickupW';
result := DllCall("TAPI32\linePickupW"
    , "UInt", hLine   ; DWORD
    , "UInt", dwAddressID   ; DWORD
    , "Ptr", lphCall   ; DWORD* in/out
    , "WStr", lpszDestAddress   ; LPCWSTR
    , "WStr", lpszGroupID   ; LPCWSTR
    , "Int")   ; return: INT
●linePickupW(hLine, dwAddressID, lphCall, lpszDestAddress, lpszGroupID) = DLL("TAPI32.dll", "int linePickupW(dword, dword, void*, char*, char*)")
# 呼び出し: linePickupW(hLine, dwAddressID, lphCall, lpszDestAddress, lpszGroupID)
# hLine : DWORD -> "dword"
# dwAddressID : DWORD -> "dword"
# lphCall : DWORD* in/out -> "void*"
# lpszDestAddress : LPCWSTR -> "char*"
# lpszGroupID : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。
const std = @import("std");

extern "tapi32" fn linePickupW(
    hLine: u32, // DWORD
    dwAddressID: u32, // DWORD
    lphCall: [*c]u32, // DWORD* in/out
    lpszDestAddress: [*c]const u16, // LPCWSTR
    lpszGroupID: [*c]const u16 // LPCWSTR
) callconv(std.os.windows.WINAPI) i32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。
proc linePickupW(
    hLine: uint32,  # DWORD
    dwAddressID: uint32,  # DWORD
    lphCall: ptr uint32,  # DWORD* in/out
    lpszDestAddress: WideCString,  # LPCWSTR
    lpszGroupID: WideCString  # LPCWSTR
): int32 {.importc: "linePickupW", stdcall, dynlib: "TAPI32.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。
pragma(lib, "tapi32");
extern(Windows)
int linePickupW(
    uint hLine,   // DWORD
    uint dwAddressID,   // DWORD
    uint* lphCall,   // DWORD* in/out
    const(wchar)* lpszDestAddress,   // LPCWSTR
    const(wchar)* lpszGroupID   // LPCWSTR
);
ccall((:linePickupW, "TAPI32.dll"), stdcall, Int32,
      (UInt32, UInt32, Ptr{UInt32}, Cwstring, Cwstring),
      hLine, dwAddressID, lphCall, lpszDestAddress, lpszGroupID)
# hLine : DWORD -> UInt32
# dwAddressID : DWORD -> UInt32
# lphCall : DWORD* in/out -> Ptr{UInt32}
# lpszDestAddress : LPCWSTR -> Cwstring
# lpszGroupID : LPCWSTR -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。
local ffi = require("ffi")
ffi.cdef[[
int32_t linePickupW(
    uint32_t hLine,
    uint32_t dwAddressID,
    uint32_t* lphCall,
    const uint16_t* lpszDestAddress,
    const uint16_t* lpszGroupID);
]]
local tapi32 = ffi.load("tapi32")
-- tapi32.linePickupW(hLine, dwAddressID, lphCall, lpszDestAddress, lpszGroupID)
-- hLine : DWORD
-- dwAddressID : DWORD
-- lphCall : DWORD* in/out
-- lpszDestAddress : LPCWSTR
-- lpszGroupID : 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 linePickupW = lib.func('__stdcall', 'linePickupW', 'int32_t', ['uint32_t', 'uint32_t', 'uint32_t *', 'str16', 'str16']);
// linePickupW(hLine, dwAddressID, lphCall, lpszDestAddress, lpszGroupID)
// hLine : DWORD -> 'uint32_t'
// dwAddressID : DWORD -> 'uint32_t'
// lphCall : DWORD* in/out -> 'uint32_t *'
// lpszDestAddress : LPCWSTR -> 'str16'
// lpszGroupID : LPCWSTR -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("TAPI32.dll", {
  linePickupW: { parameters: ["u32", "u32", "pointer", "buffer", "buffer"], result: "i32" },
});
// lib.symbols.linePickupW(hLine, dwAddressID, lphCall, lpszDestAddress, lpszGroupID)
// hLine : DWORD -> "u32"
// dwAddressID : DWORD -> "u32"
// lphCall : DWORD* in/out -> "pointer"
// lpszDestAddress : LPCWSTR -> "buffer"
// lpszGroupID : LPCWSTR -> "buffer"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t linePickupW(
    uint32_t hLine,
    uint32_t dwAddressID,
    uint32_t* lphCall,
    const uint16_t* lpszDestAddress,
    const uint16_t* lpszGroupID);
C, "TAPI32.dll");
// $ffi->linePickupW(hLine, dwAddressID, lphCall, lpszDestAddress, lpszGroupID);
// hLine : DWORD
// dwAddressID : DWORD
// lphCall : DWORD* in/out
// lpszDestAddress : LPCWSTR
// lpszGroupID : 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 linePickupW(
        int hLine,   // DWORD
        int dwAddressID,   // DWORD
        IntByReference lphCall,   // DWORD* in/out
        WString lpszDestAddress,   // LPCWSTR
        WString lpszGroupID   // LPCWSTR
    );
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。
@[Link("tapi32")]
lib LibTAPI32
  fun linePickupW = linePickupW(
    hLine : UInt32,   # DWORD
    dwAddressID : UInt32,   # DWORD
    lphCall : UInt32*,   # DWORD* in/out
    lpszDestAddress : UInt16*,   # LPCWSTR
    lpszGroupID : 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 linePickupWNative = Int32 Function(Uint32, Uint32, Pointer<Uint32>, Pointer<Utf16>, Pointer<Utf16>);
typedef linePickupWDart = int Function(int, int, Pointer<Uint32>, Pointer<Utf16>, Pointer<Utf16>);
final linePickupW = DynamicLibrary.open('TAPI32.dll')
    .lookupFunction<linePickupWNative, linePickupWDart>('linePickupW');
// hLine : DWORD -> Uint32
// dwAddressID : DWORD -> Uint32
// lphCall : DWORD* in/out -> Pointer<Uint32>
// lpszDestAddress : LPCWSTR -> Pointer<Utf16>
// lpszGroupID : LPCWSTR -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function linePickupW(
  hLine: DWORD;   // DWORD
  dwAddressID: DWORD;   // DWORD
  lphCall: Pointer;   // DWORD* in/out
  lpszDestAddress: PWideChar;   // LPCWSTR
  lpszGroupID: PWideChar   // LPCWSTR
): Integer; stdcall;
  external 'TAPI32.dll' name 'linePickupW';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "linePickupW"
  c_linePickupW :: Word32 -> Word32 -> Ptr Word32 -> CWString -> CWString -> IO Int32
-- hLine : DWORD -> Word32
-- dwAddressID : DWORD -> Word32
-- lphCall : DWORD* in/out -> Ptr Word32
-- lpszDestAddress : LPCWSTR -> CWString
-- lpszGroupID : LPCWSTR -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let linepickupw =
  foreign "linePickupW"
    (uint32_t @-> uint32_t @-> (ptr uint32_t) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> returning int32_t)
(* hLine : DWORD -> uint32_t *)
(* dwAddressID : DWORD -> uint32_t *)
(* lphCall : DWORD* in/out -> (ptr uint32_t) *)
(* lpszDestAddress : LPCWSTR -> (ptr uint16_t) *)
(* lpszGroupID : 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 ("linePickupW" line-pickup-w :convention :stdcall) :int32
  (h-line :uint32)   ; DWORD
  (dw-address-id :uint32)   ; DWORD
  (lph-call :pointer)   ; DWORD* in/out
  (lpsz-dest-address (:string :encoding :utf-16le))   ; LPCWSTR
  (lpsz-group-id (:string :encoding :utf-16le)))   ; LPCWSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $linePickupW = Win32::API::More->new('TAPI32',
    'int linePickupW(DWORD hLine, DWORD dwAddressID, LPVOID lphCall, LPCWSTR lpszDestAddress, LPCWSTR lpszGroupID)');
# my $ret = $linePickupW->Call($hLine, $dwAddressID, $lphCall, $lpszDestAddress, $lpszGroupID);
# hLine : DWORD -> DWORD
# dwAddressID : DWORD -> DWORD
# lphCall : DWORD* in/out -> LPVOID
# lpszDestAddress : LPCWSTR -> LPCWSTR
# lpszGroupID : LPCWSTR -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。

関連項目

文字セット違い