ホーム › Devices.Tapi › lineRedirectW
lineRedirectW
関数着信中の通話を指定アドレスへリダイレクトする(Unicode版)。
シグネチャ
// TAPI32.dll (Unicode / -W)
#include <windows.h>
INT lineRedirectW(
DWORD hCall,
LPCWSTR lpszDestAddress,
DWORD dwCountryCode
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hCall | DWORD | in | 転送(リダイレクト)する対象の鳴動中通話のハンドル。 |
| lpszDestAddress | LPCWSTR | in | 転送先アドレス(電話番号等)を示すUnicode文字列。 |
| dwCountryCode | DWORD | in | 転送先の国番号。トーン選択等に用い、0で既定値を使用する。 |
戻り値の型: INT
各言語での呼び出し定義
// TAPI32.dll (Unicode / -W)
#include <windows.h>
INT lineRedirectW(
DWORD hCall,
LPCWSTR lpszDestAddress,
DWORD dwCountryCode
);[DllImport("TAPI32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int lineRedirectW(
uint hCall, // DWORD
[MarshalAs(UnmanagedType.LPWStr)] string lpszDestAddress, // LPCWSTR
uint dwCountryCode // DWORD
);<DllImport("TAPI32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function lineRedirectW(
hCall As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPWStr)> lpszDestAddress As String, ' LPCWSTR
dwCountryCode As UInteger ' DWORD
) As Integer
End Function' hCall : DWORD
' lpszDestAddress : LPCWSTR
' dwCountryCode : DWORD
Declare PtrSafe Function lineRedirectW Lib "tapi32" ( _
ByVal hCall As Long, _
ByVal lpszDestAddress As LongPtr, _
ByVal dwCountryCode As Long) 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
lineRedirectW = ctypes.windll.tapi32.lineRedirectW
lineRedirectW.restype = ctypes.c_int
lineRedirectW.argtypes = [
wintypes.DWORD, # hCall : DWORD
wintypes.LPCWSTR, # lpszDestAddress : LPCWSTR
wintypes.DWORD, # dwCountryCode : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('TAPI32.dll')
lineRedirectW = Fiddle::Function.new(
lib['lineRedirectW'],
[
-Fiddle::TYPE_INT, # hCall : DWORD
Fiddle::TYPE_VOIDP, # lpszDestAddress : LPCWSTR
-Fiddle::TYPE_INT, # dwCountryCode : DWORD
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "tapi32")]
extern "system" {
fn lineRedirectW(
hCall: u32, // DWORD
lpszDestAddress: *const u16, // LPCWSTR
dwCountryCode: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("TAPI32.dll", CharSet = CharSet.Unicode)]
public static extern int lineRedirectW(uint hCall, [MarshalAs(UnmanagedType.LPWStr)] string lpszDestAddress, uint dwCountryCode);
"@
$api = Add-Type -MemberDefinition $sig -Name 'TAPI32_lineRedirectW' -Namespace Win32 -PassThru
# $api::lineRedirectW(hCall, lpszDestAddress, dwCountryCode)#uselib "TAPI32.dll"
#func global lineRedirectW "lineRedirectW" wptr, wptr, wptr
; lineRedirectW hCall, lpszDestAddress, dwCountryCode ; 戻り値は stat
; hCall : DWORD -> "wptr"
; lpszDestAddress : LPCWSTR -> "wptr"
; dwCountryCode : DWORD -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "TAPI32.dll"
#cfunc global lineRedirectW "lineRedirectW" int, wstr, int
; res = lineRedirectW(hCall, lpszDestAddress, dwCountryCode)
; hCall : DWORD -> "int"
; lpszDestAddress : LPCWSTR -> "wstr"
; dwCountryCode : DWORD -> "int"; INT lineRedirectW(DWORD hCall, LPCWSTR lpszDestAddress, DWORD dwCountryCode)
#uselib "TAPI32.dll"
#cfunc global lineRedirectW "lineRedirectW" int, wstr, int
; res = lineRedirectW(hCall, lpszDestAddress, dwCountryCode)
; hCall : DWORD -> "int"
; lpszDestAddress : LPCWSTR -> "wstr"
; dwCountryCode : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
tapi32 = windows.NewLazySystemDLL("TAPI32.dll")
proclineRedirectW = tapi32.NewProc("lineRedirectW")
)
// hCall (DWORD), lpszDestAddress (LPCWSTR), dwCountryCode (DWORD)
r1, _, err := proclineRedirectW.Call(
uintptr(hCall),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszDestAddress))),
uintptr(dwCountryCode),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction lineRedirectW(
hCall: DWORD; // DWORD
lpszDestAddress: PWideChar; // LPCWSTR
dwCountryCode: DWORD // DWORD
): Integer; stdcall;
external 'TAPI32.dll' name 'lineRedirectW';result := DllCall("TAPI32\lineRedirectW"
, "UInt", hCall ; DWORD
, "WStr", lpszDestAddress ; LPCWSTR
, "UInt", dwCountryCode ; DWORD
, "Int") ; return: INT●lineRedirectW(hCall, lpszDestAddress, dwCountryCode) = DLL("TAPI32.dll", "int lineRedirectW(dword, char*, dword)")
# 呼び出し: lineRedirectW(hCall, lpszDestAddress, dwCountryCode)
# hCall : DWORD -> "dword"
# lpszDestAddress : LPCWSTR -> "char*"
# dwCountryCode : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。const std = @import("std");
extern "tapi32" fn lineRedirectW(
hCall: u32, // DWORD
lpszDestAddress: [*c]const u16, // LPCWSTR
dwCountryCode: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc lineRedirectW(
hCall: uint32, # DWORD
lpszDestAddress: WideCString, # LPCWSTR
dwCountryCode: uint32 # DWORD
): int32 {.importc: "lineRedirectW", stdcall, dynlib: "TAPI32.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "tapi32");
extern(Windows)
int lineRedirectW(
uint hCall, // DWORD
const(wchar)* lpszDestAddress, // LPCWSTR
uint dwCountryCode // DWORD
);ccall((:lineRedirectW, "TAPI32.dll"), stdcall, Int32,
(UInt32, Cwstring, UInt32),
hCall, lpszDestAddress, dwCountryCode)
# hCall : DWORD -> UInt32
# lpszDestAddress : LPCWSTR -> Cwstring
# dwCountryCode : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
int32_t lineRedirectW(
uint32_t hCall,
const uint16_t* lpszDestAddress,
uint32_t dwCountryCode);
]]
local tapi32 = ffi.load("tapi32")
-- tapi32.lineRedirectW(hCall, lpszDestAddress, dwCountryCode)
-- hCall : DWORD
-- lpszDestAddress : LPCWSTR
-- dwCountryCode : DWORD
-- 構造体/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 lineRedirectW = lib.func('__stdcall', 'lineRedirectW', 'int32_t', ['uint32_t', 'str16', 'uint32_t']);
// lineRedirectW(hCall, lpszDestAddress, dwCountryCode)
// hCall : DWORD -> 'uint32_t'
// lpszDestAddress : LPCWSTR -> 'str16'
// dwCountryCode : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("TAPI32.dll", {
lineRedirectW: { parameters: ["u32", "buffer", "u32"], result: "i32" },
});
// lib.symbols.lineRedirectW(hCall, lpszDestAddress, dwCountryCode)
// hCall : DWORD -> "u32"
// lpszDestAddress : LPCWSTR -> "buffer"
// dwCountryCode : DWORD -> "u32"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t lineRedirectW(
uint32_t hCall,
const uint16_t* lpszDestAddress,
uint32_t dwCountryCode);
C, "TAPI32.dll");
// $ffi->lineRedirectW(hCall, lpszDestAddress, dwCountryCode);
// hCall : DWORD
// lpszDestAddress : LPCWSTR
// dwCountryCode : 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, W32APIOptions.UNICODE_OPTIONS);
int lineRedirectW(
int hCall, // DWORD
WString lpszDestAddress, // LPCWSTR
int dwCountryCode // DWORD
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("tapi32")]
lib LibTAPI32
fun lineRedirectW = lineRedirectW(
hCall : UInt32, # DWORD
lpszDestAddress : UInt16*, # LPCWSTR
dwCountryCode : 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 lineRedirectWNative = Int32 Function(Uint32, Pointer<Utf16>, Uint32);
typedef lineRedirectWDart = int Function(int, Pointer<Utf16>, int);
final lineRedirectW = DynamicLibrary.open('TAPI32.dll')
.lookupFunction<lineRedirectWNative, lineRedirectWDart>('lineRedirectW');
// hCall : DWORD -> Uint32
// lpszDestAddress : LPCWSTR -> Pointer<Utf16>
// dwCountryCode : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function lineRedirectW(
hCall: DWORD; // DWORD
lpszDestAddress: PWideChar; // LPCWSTR
dwCountryCode: DWORD // DWORD
): Integer; stdcall;
external 'TAPI32.dll' name 'lineRedirectW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "lineRedirectW"
c_lineRedirectW :: Word32 -> CWString -> Word32 -> IO Int32
-- hCall : DWORD -> Word32
-- lpszDestAddress : LPCWSTR -> CWString
-- dwCountryCode : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let lineredirectw =
foreign "lineRedirectW"
(uint32_t @-> (ptr uint16_t) @-> uint32_t @-> returning int32_t)
(* hCall : DWORD -> uint32_t *)
(* lpszDestAddress : LPCWSTR -> (ptr uint16_t) *)
(* dwCountryCode : 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 ("lineRedirectW" line-redirect-w :convention :stdcall) :int32
(h-call :uint32) ; DWORD
(lpsz-dest-address (:string :encoding :utf-16le)) ; LPCWSTR
(dw-country-code :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $lineRedirectW = Win32::API::More->new('TAPI32',
'int lineRedirectW(DWORD hCall, LPCWSTR lpszDestAddress, DWORD dwCountryCode)');
# my $ret = $lineRedirectW->Call($hCall, $lpszDestAddress, $dwCountryCode);
# hCall : DWORD -> DWORD
# lpszDestAddress : LPCWSTR -> LPCWSTR
# dwCountryCode : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
文字セット違い
- f lineRedirectA (ANSI版) — 着信中の通話を指定アドレスへリダイレクトする(ANSI版)。