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

lineCreateAgentSessionW

関数
エージェントのセッションを作成しグループに関連付ける(Unicode版)。
DLLTAPI32.dll文字セットUnicode (-W)呼出規約winapi

シグネチャ

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

INT lineCreateAgentSessionW(
    DWORD hLine,
    DWORD hAgent,
    LPCWSTR lpszAgentPIN,   // optional
    DWORD dwWorkingAddressID,
    GUID* lpGroupID,
    DWORD* lphAgentSession
);

パラメーター

名前方向説明
hLineDWORDin対象の回線デバイスハンドル。
hAgentDWORDinセッションを作成するエージェントのハンドル。
lpszAgentPINLPCWSTRinoptionalエージェント認証用のPIN文字列(Unicode)へのポインタ。
dwWorkingAddressIDDWORDin作業に使用するアドレスのIDを指定する。
lpGroupIDGUID*inout対象エージェントグループを示すGUIDへのポインタ。
lphAgentSessionDWORD*inout作成されたエージェントセッションのハンドルを受け取る出力ポインタ。

戻り値の型: INT

各言語での呼び出し定義

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

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

lineCreateAgentSessionW = ctypes.windll.tapi32.lineCreateAgentSessionW
lineCreateAgentSessionW.restype = ctypes.c_int
lineCreateAgentSessionW.argtypes = [
    wintypes.DWORD,  # hLine : DWORD
    wintypes.DWORD,  # hAgent : DWORD
    wintypes.LPCWSTR,  # lpszAgentPIN : LPCWSTR optional
    wintypes.DWORD,  # dwWorkingAddressID : DWORD
    ctypes.c_void_p,  # lpGroupID : GUID* in/out
    ctypes.POINTER(wintypes.DWORD),  # lphAgentSession : DWORD* in/out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	tapi32 = windows.NewLazySystemDLL("TAPI32.dll")
	proclineCreateAgentSessionW = tapi32.NewProc("lineCreateAgentSessionW")
)

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

foreign import stdcall safe "lineCreateAgentSessionW"
  c_lineCreateAgentSessionW :: Word32 -> Word32 -> CWString -> Word32 -> Ptr () -> Ptr Word32 -> IO Int32
-- hLine : DWORD -> Word32
-- hAgent : DWORD -> Word32
-- lpszAgentPIN : LPCWSTR optional -> CWString
-- dwWorkingAddressID : DWORD -> Word32
-- lpGroupID : GUID* in/out -> Ptr ()
-- lphAgentSession : DWORD* in/out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

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

関連項目

文字セット違い