ホーム › Devices.Tapi › lineCreateAgentW
lineCreateAgentW
関数新しいACDエージェントオブジェクトを作成する(Unicode版)。
シグネチャ
// TAPI32.dll (Unicode / -W)
#include <windows.h>
INT lineCreateAgentW(
DWORD hLine,
LPCWSTR lpszAgentID, // optional
LPCWSTR lpszAgentPIN, // optional
DWORD* lphAgent
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hLine | DWORD | in | 対象の回線デバイスハンドル。 |
| lpszAgentID | LPCWSTR | inoptional | 作成するエージェントの識別子(Unicode)へのポインタ。 |
| lpszAgentPIN | LPCWSTR | inoptional | エージェント認証用のPIN文字列(Unicode)へのポインタ。 |
| lphAgent | DWORD* | inout | 作成されたエージェントのハンドルを受け取る出力ポインタ。 |
戻り値の型: INT
各言語での呼び出し定義
// TAPI32.dll (Unicode / -W)
#include <windows.h>
INT lineCreateAgentW(
DWORD hLine,
LPCWSTR lpszAgentID, // optional
LPCWSTR lpszAgentPIN, // optional
DWORD* lphAgent
);[DllImport("TAPI32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int lineCreateAgentW(
uint hLine, // DWORD
[MarshalAs(UnmanagedType.LPWStr)] string lpszAgentID, // LPCWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] string lpszAgentPIN, // LPCWSTR optional
ref uint lphAgent // DWORD* in/out
);<DllImport("TAPI32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function lineCreateAgentW(
hLine As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPWStr)> lpszAgentID As String, ' LPCWSTR optional
<MarshalAs(UnmanagedType.LPWStr)> lpszAgentPIN As String, ' LPCWSTR optional
ByRef lphAgent As UInteger ' DWORD* in/out
) As Integer
End Function' hLine : DWORD
' lpszAgentID : LPCWSTR optional
' lpszAgentPIN : LPCWSTR optional
' lphAgent : DWORD* in/out
Declare PtrSafe Function lineCreateAgentW Lib "tapi32" ( _
ByVal hLine As Long, _
ByVal lpszAgentID As LongPtr, _
ByVal lpszAgentPIN As LongPtr, _
ByRef lphAgent 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
lineCreateAgentW = ctypes.windll.tapi32.lineCreateAgentW
lineCreateAgentW.restype = ctypes.c_int
lineCreateAgentW.argtypes = [
wintypes.DWORD, # hLine : DWORD
wintypes.LPCWSTR, # lpszAgentID : LPCWSTR optional
wintypes.LPCWSTR, # lpszAgentPIN : LPCWSTR optional
ctypes.POINTER(wintypes.DWORD), # lphAgent : DWORD* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('TAPI32.dll')
lineCreateAgentW = Fiddle::Function.new(
lib['lineCreateAgentW'],
[
-Fiddle::TYPE_INT, # hLine : DWORD
Fiddle::TYPE_VOIDP, # lpszAgentID : LPCWSTR optional
Fiddle::TYPE_VOIDP, # lpszAgentPIN : LPCWSTR optional
Fiddle::TYPE_VOIDP, # lphAgent : DWORD* in/out
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "tapi32")]
extern "system" {
fn lineCreateAgentW(
hLine: u32, // DWORD
lpszAgentID: *const u16, // LPCWSTR optional
lpszAgentPIN: *const u16, // LPCWSTR optional
lphAgent: *mut u32 // DWORD* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("TAPI32.dll", CharSet = CharSet.Unicode)]
public static extern int lineCreateAgentW(uint hLine, [MarshalAs(UnmanagedType.LPWStr)] string lpszAgentID, [MarshalAs(UnmanagedType.LPWStr)] string lpszAgentPIN, ref uint lphAgent);
"@
$api = Add-Type -MemberDefinition $sig -Name 'TAPI32_lineCreateAgentW' -Namespace Win32 -PassThru
# $api::lineCreateAgentW(hLine, lpszAgentID, lpszAgentPIN, lphAgent)#uselib "TAPI32.dll"
#func global lineCreateAgentW "lineCreateAgentW" wptr, wptr, wptr, wptr
; lineCreateAgentW hLine, lpszAgentID, lpszAgentPIN, varptr(lphAgent) ; 戻り値は stat
; hLine : DWORD -> "wptr"
; lpszAgentID : LPCWSTR optional -> "wptr"
; lpszAgentPIN : LPCWSTR optional -> "wptr"
; lphAgent : DWORD* in/out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "TAPI32.dll" #cfunc global lineCreateAgentW "lineCreateAgentW" int, wstr, wstr, var ; res = lineCreateAgentW(hLine, lpszAgentID, lpszAgentPIN, lphAgent) ; hLine : DWORD -> "int" ; lpszAgentID : LPCWSTR optional -> "wstr" ; lpszAgentPIN : LPCWSTR optional -> "wstr" ; lphAgent : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "TAPI32.dll" #cfunc global lineCreateAgentW "lineCreateAgentW" int, wstr, wstr, sptr ; res = lineCreateAgentW(hLine, lpszAgentID, lpszAgentPIN, varptr(lphAgent)) ; hLine : DWORD -> "int" ; lpszAgentID : LPCWSTR optional -> "wstr" ; lpszAgentPIN : LPCWSTR optional -> "wstr" ; lphAgent : DWORD* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT lineCreateAgentW(DWORD hLine, LPCWSTR lpszAgentID, LPCWSTR lpszAgentPIN, DWORD* lphAgent) #uselib "TAPI32.dll" #cfunc global lineCreateAgentW "lineCreateAgentW" int, wstr, wstr, var ; res = lineCreateAgentW(hLine, lpszAgentID, lpszAgentPIN, lphAgent) ; hLine : DWORD -> "int" ; lpszAgentID : LPCWSTR optional -> "wstr" ; lpszAgentPIN : LPCWSTR optional -> "wstr" ; lphAgent : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT lineCreateAgentW(DWORD hLine, LPCWSTR lpszAgentID, LPCWSTR lpszAgentPIN, DWORD* lphAgent) #uselib "TAPI32.dll" #cfunc global lineCreateAgentW "lineCreateAgentW" int, wstr, wstr, intptr ; res = lineCreateAgentW(hLine, lpszAgentID, lpszAgentPIN, varptr(lphAgent)) ; hLine : DWORD -> "int" ; lpszAgentID : LPCWSTR optional -> "wstr" ; lpszAgentPIN : LPCWSTR optional -> "wstr" ; lphAgent : DWORD* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
tapi32 = windows.NewLazySystemDLL("TAPI32.dll")
proclineCreateAgentW = tapi32.NewProc("lineCreateAgentW")
)
// hLine (DWORD), lpszAgentID (LPCWSTR optional), lpszAgentPIN (LPCWSTR optional), lphAgent (DWORD* in/out)
r1, _, err := proclineCreateAgentW.Call(
uintptr(hLine),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszAgentID))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszAgentPIN))),
uintptr(lphAgent),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction lineCreateAgentW(
hLine: DWORD; // DWORD
lpszAgentID: PWideChar; // LPCWSTR optional
lpszAgentPIN: PWideChar; // LPCWSTR optional
lphAgent: Pointer // DWORD* in/out
): Integer; stdcall;
external 'TAPI32.dll' name 'lineCreateAgentW';result := DllCall("TAPI32\lineCreateAgentW"
, "UInt", hLine ; DWORD
, "WStr", lpszAgentID ; LPCWSTR optional
, "WStr", lpszAgentPIN ; LPCWSTR optional
, "Ptr", lphAgent ; DWORD* in/out
, "Int") ; return: INT●lineCreateAgentW(hLine, lpszAgentID, lpszAgentPIN, lphAgent) = DLL("TAPI32.dll", "int lineCreateAgentW(dword, char*, char*, void*)")
# 呼び出し: lineCreateAgentW(hLine, lpszAgentID, lpszAgentPIN, lphAgent)
# hLine : DWORD -> "dword"
# lpszAgentID : LPCWSTR optional -> "char*"
# lpszAgentPIN : LPCWSTR optional -> "char*"
# lphAgent : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。const std = @import("std");
extern "tapi32" fn lineCreateAgentW(
hLine: u32, // DWORD
lpszAgentID: [*c]const u16, // LPCWSTR optional
lpszAgentPIN: [*c]const u16, // LPCWSTR optional
lphAgent: [*c]u32 // DWORD* in/out
) callconv(std.os.windows.WINAPI) i32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc lineCreateAgentW(
hLine: uint32, # DWORD
lpszAgentID: WideCString, # LPCWSTR optional
lpszAgentPIN: WideCString, # LPCWSTR optional
lphAgent: ptr uint32 # DWORD* in/out
): int32 {.importc: "lineCreateAgentW", stdcall, dynlib: "TAPI32.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "tapi32");
extern(Windows)
int lineCreateAgentW(
uint hLine, // DWORD
const(wchar)* lpszAgentID, // LPCWSTR optional
const(wchar)* lpszAgentPIN, // LPCWSTR optional
uint* lphAgent // DWORD* in/out
);ccall((:lineCreateAgentW, "TAPI32.dll"), stdcall, Int32,
(UInt32, Cwstring, Cwstring, Ptr{UInt32}),
hLine, lpszAgentID, lpszAgentPIN, lphAgent)
# hLine : DWORD -> UInt32
# lpszAgentID : LPCWSTR optional -> Cwstring
# lpszAgentPIN : LPCWSTR optional -> Cwstring
# lphAgent : DWORD* in/out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
int32_t lineCreateAgentW(
uint32_t hLine,
const uint16_t* lpszAgentID,
const uint16_t* lpszAgentPIN,
uint32_t* lphAgent);
]]
local tapi32 = ffi.load("tapi32")
-- tapi32.lineCreateAgentW(hLine, lpszAgentID, lpszAgentPIN, lphAgent)
-- hLine : DWORD
-- lpszAgentID : LPCWSTR optional
-- lpszAgentPIN : LPCWSTR optional
-- lphAgent : DWORD* in/out
-- 構造体/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 lineCreateAgentW = lib.func('__stdcall', 'lineCreateAgentW', 'int32_t', ['uint32_t', 'str16', 'str16', 'uint32_t *']);
// lineCreateAgentW(hLine, lpszAgentID, lpszAgentPIN, lphAgent)
// hLine : DWORD -> 'uint32_t'
// lpszAgentID : LPCWSTR optional -> 'str16'
// lpszAgentPIN : LPCWSTR optional -> 'str16'
// lphAgent : DWORD* in/out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("TAPI32.dll", {
lineCreateAgentW: { parameters: ["u32", "buffer", "buffer", "pointer"], result: "i32" },
});
// lib.symbols.lineCreateAgentW(hLine, lpszAgentID, lpszAgentPIN, lphAgent)
// hLine : DWORD -> "u32"
// lpszAgentID : LPCWSTR optional -> "buffer"
// lpszAgentPIN : LPCWSTR optional -> "buffer"
// lphAgent : DWORD* in/out -> "pointer"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t lineCreateAgentW(
uint32_t hLine,
const uint16_t* lpszAgentID,
const uint16_t* lpszAgentPIN,
uint32_t* lphAgent);
C, "TAPI32.dll");
// $ffi->lineCreateAgentW(hLine, lpszAgentID, lpszAgentPIN, lphAgent);
// hLine : DWORD
// lpszAgentID : LPCWSTR optional
// lpszAgentPIN : LPCWSTR optional
// lphAgent : DWORD* in/out
// 構造体/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 lineCreateAgentW(
int hLine, // DWORD
WString lpszAgentID, // LPCWSTR optional
WString lpszAgentPIN, // LPCWSTR optional
IntByReference lphAgent // DWORD* in/out
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("tapi32")]
lib LibTAPI32
fun lineCreateAgentW = lineCreateAgentW(
hLine : UInt32, # DWORD
lpszAgentID : UInt16*, # LPCWSTR optional
lpszAgentPIN : UInt16*, # LPCWSTR optional
lphAgent : UInt32* # DWORD* in/out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef lineCreateAgentWNative = Int32 Function(Uint32, Pointer<Utf16>, Pointer<Utf16>, Pointer<Uint32>);
typedef lineCreateAgentWDart = int Function(int, Pointer<Utf16>, Pointer<Utf16>, Pointer<Uint32>);
final lineCreateAgentW = DynamicLibrary.open('TAPI32.dll')
.lookupFunction<lineCreateAgentWNative, lineCreateAgentWDart>('lineCreateAgentW');
// hLine : DWORD -> Uint32
// lpszAgentID : LPCWSTR optional -> Pointer<Utf16>
// lpszAgentPIN : LPCWSTR optional -> Pointer<Utf16>
// lphAgent : DWORD* in/out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function lineCreateAgentW(
hLine: DWORD; // DWORD
lpszAgentID: PWideChar; // LPCWSTR optional
lpszAgentPIN: PWideChar; // LPCWSTR optional
lphAgent: Pointer // DWORD* in/out
): Integer; stdcall;
external 'TAPI32.dll' name 'lineCreateAgentW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "lineCreateAgentW"
c_lineCreateAgentW :: Word32 -> CWString -> CWString -> Ptr Word32 -> IO Int32
-- hLine : DWORD -> Word32
-- lpszAgentID : LPCWSTR optional -> CWString
-- lpszAgentPIN : LPCWSTR optional -> CWString
-- lphAgent : DWORD* in/out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let linecreateagentw =
foreign "lineCreateAgentW"
(uint32_t @-> (ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint32_t) @-> returning int32_t)
(* hLine : DWORD -> uint32_t *)
(* lpszAgentID : LPCWSTR optional -> (ptr uint16_t) *)
(* lpszAgentPIN : LPCWSTR optional -> (ptr uint16_t) *)
(* lphAgent : DWORD* in/out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library tapi32 (t "TAPI32.dll"))
(cffi:use-foreign-library tapi32)
(cffi:defcfun ("lineCreateAgentW" line-create-agent-w :convention :stdcall) :int32
(h-line :uint32) ; DWORD
(lpsz-agent-id (:string :encoding :utf-16le)) ; LPCWSTR optional
(lpsz-agent-pin (:string :encoding :utf-16le)) ; LPCWSTR optional
(lph-agent :pointer)) ; DWORD* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $lineCreateAgentW = Win32::API::More->new('TAPI32',
'int lineCreateAgentW(DWORD hLine, LPCWSTR lpszAgentID, LPCWSTR lpszAgentPIN, LPVOID lphAgent)');
# my $ret = $lineCreateAgentW->Call($hLine, $lpszAgentID, $lpszAgentPIN, $lphAgent);
# hLine : DWORD -> DWORD
# lpszAgentID : LPCWSTR optional -> LPCWSTR
# lpszAgentPIN : LPCWSTR optional -> LPCWSTR
# lphAgent : DWORD* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
文字セット違い
- f lineCreateAgentA (ANSI版) — 新しいACDエージェントオブジェクトを作成する(ANSI版)。