ホーム › Devices.Tapi › lineCreateAgentSessionA
lineCreateAgentSessionA
関数エージェントのセッションを作成しグループに関連付ける(ANSI版)。
シグネチャ
// TAPI32.dll (ANSI / -A)
#include <windows.h>
INT lineCreateAgentSessionA(
DWORD hLine,
DWORD hAgent,
LPCSTR lpszAgentPIN, // optional
DWORD dwWorkingAddressID,
GUID* lpGroupID,
DWORD* lphAgentSession
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hLine | DWORD | in | 対象の回線デバイスハンドル。 |
| hAgent | DWORD | in | セッションを作成するエージェントのハンドル。 |
| lpszAgentPIN | LPCSTR | inoptional | エージェント認証用のPIN文字列(ANSI)へのポインタ。 |
| dwWorkingAddressID | DWORD | in | 作業に使用するアドレスのIDを指定する。 |
| lpGroupID | GUID* | inout | 対象エージェントグループを示すGUIDへのポインタ。 |
| lphAgentSession | DWORD* | inout | 作成されたエージェントセッションのハンドルを受け取る出力ポインタ。 |
戻り値の型: INT
各言語での呼び出し定義
// TAPI32.dll (ANSI / -A)
#include <windows.h>
INT lineCreateAgentSessionA(
DWORD hLine,
DWORD hAgent,
LPCSTR lpszAgentPIN, // optional
DWORD dwWorkingAddressID,
GUID* lpGroupID,
DWORD* lphAgentSession
);[DllImport("TAPI32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern int lineCreateAgentSessionA(
uint hLine, // DWORD
uint hAgent, // DWORD
[MarshalAs(UnmanagedType.LPStr)] string lpszAgentPIN, // LPCSTR optional
uint dwWorkingAddressID, // DWORD
ref Guid lpGroupID, // GUID* in/out
ref uint lphAgentSession // DWORD* in/out
);<DllImport("TAPI32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function lineCreateAgentSessionA(
hLine As UInteger, ' DWORD
hAgent As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPStr)> lpszAgentPIN As String, ' LPCSTR 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 : LPCSTR optional
' dwWorkingAddressID : DWORD
' lpGroupID : GUID* in/out
' lphAgentSession : DWORD* in/out
Declare PtrSafe Function lineCreateAgentSessionA Lib "tapi32" ( _
ByVal hLine As Long, _
ByVal hAgent As Long, _
ByVal lpszAgentPIN As String, _
ByVal dwWorkingAddressID As Long, _
ByVal lpGroupID As LongPtr, _
ByRef lphAgentSession As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
lineCreateAgentSessionA = ctypes.windll.tapi32.lineCreateAgentSessionA
lineCreateAgentSessionA.restype = ctypes.c_int
lineCreateAgentSessionA.argtypes = [
wintypes.DWORD, # hLine : DWORD
wintypes.DWORD, # hAgent : DWORD
wintypes.LPCSTR, # lpszAgentPIN : LPCSTR 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')
lineCreateAgentSessionA = Fiddle::Function.new(
lib['lineCreateAgentSessionA'],
[
-Fiddle::TYPE_INT, # hLine : DWORD
-Fiddle::TYPE_INT, # hAgent : DWORD
Fiddle::TYPE_VOIDP, # lpszAgentPIN : LPCSTR optional
-Fiddle::TYPE_INT, # dwWorkingAddressID : DWORD
Fiddle::TYPE_VOIDP, # lpGroupID : GUID* in/out
Fiddle::TYPE_VOIDP, # lphAgentSession : DWORD* in/out
],
Fiddle::TYPE_INT)#[link(name = "tapi32")]
extern "system" {
fn lineCreateAgentSessionA(
hLine: u32, // DWORD
hAgent: u32, // DWORD
lpszAgentPIN: *const u8, // LPCSTR 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.Ansi)]
public static extern int lineCreateAgentSessionA(uint hLine, uint hAgent, [MarshalAs(UnmanagedType.LPStr)] string lpszAgentPIN, uint dwWorkingAddressID, ref Guid lpGroupID, ref uint lphAgentSession);
"@
$api = Add-Type -MemberDefinition $sig -Name 'TAPI32_lineCreateAgentSessionA' -Namespace Win32 -PassThru
# $api::lineCreateAgentSessionA(hLine, hAgent, lpszAgentPIN, dwWorkingAddressID, lpGroupID, lphAgentSession)#uselib "TAPI32.dll"
#func global lineCreateAgentSessionA "lineCreateAgentSessionA" sptr, sptr, sptr, sptr, sptr, sptr
; lineCreateAgentSessionA hLine, hAgent, lpszAgentPIN, dwWorkingAddressID, varptr(lpGroupID), varptr(lphAgentSession) ; 戻り値は stat
; hLine : DWORD -> "sptr"
; hAgent : DWORD -> "sptr"
; lpszAgentPIN : LPCSTR optional -> "sptr"
; dwWorkingAddressID : DWORD -> "sptr"
; lpGroupID : GUID* in/out -> "sptr"
; lphAgentSession : DWORD* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "TAPI32.dll" #cfunc global lineCreateAgentSessionA "lineCreateAgentSessionA" int, int, str, int, var, var ; res = lineCreateAgentSessionA(hLine, hAgent, lpszAgentPIN, dwWorkingAddressID, lpGroupID, lphAgentSession) ; hLine : DWORD -> "int" ; hAgent : DWORD -> "int" ; lpszAgentPIN : LPCSTR optional -> "str" ; dwWorkingAddressID : DWORD -> "int" ; lpGroupID : GUID* in/out -> "var" ; lphAgentSession : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "TAPI32.dll" #cfunc global lineCreateAgentSessionA "lineCreateAgentSessionA" int, int, str, int, sptr, sptr ; res = lineCreateAgentSessionA(hLine, hAgent, lpszAgentPIN, dwWorkingAddressID, varptr(lpGroupID), varptr(lphAgentSession)) ; hLine : DWORD -> "int" ; hAgent : DWORD -> "int" ; lpszAgentPIN : LPCSTR optional -> "str" ; dwWorkingAddressID : DWORD -> "int" ; lpGroupID : GUID* in/out -> "sptr" ; lphAgentSession : DWORD* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT lineCreateAgentSessionA(DWORD hLine, DWORD hAgent, LPCSTR lpszAgentPIN, DWORD dwWorkingAddressID, GUID* lpGroupID, DWORD* lphAgentSession) #uselib "TAPI32.dll" #cfunc global lineCreateAgentSessionA "lineCreateAgentSessionA" int, int, str, int, var, var ; res = lineCreateAgentSessionA(hLine, hAgent, lpszAgentPIN, dwWorkingAddressID, lpGroupID, lphAgentSession) ; hLine : DWORD -> "int" ; hAgent : DWORD -> "int" ; lpszAgentPIN : LPCSTR optional -> "str" ; dwWorkingAddressID : DWORD -> "int" ; lpGroupID : GUID* in/out -> "var" ; lphAgentSession : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT lineCreateAgentSessionA(DWORD hLine, DWORD hAgent, LPCSTR lpszAgentPIN, DWORD dwWorkingAddressID, GUID* lpGroupID, DWORD* lphAgentSession) #uselib "TAPI32.dll" #cfunc global lineCreateAgentSessionA "lineCreateAgentSessionA" int, int, str, int, intptr, intptr ; res = lineCreateAgentSessionA(hLine, hAgent, lpszAgentPIN, dwWorkingAddressID, varptr(lpGroupID), varptr(lphAgentSession)) ; hLine : DWORD -> "int" ; hAgent : DWORD -> "int" ; lpszAgentPIN : LPCSTR optional -> "str" ; dwWorkingAddressID : DWORD -> "int" ; lpGroupID : GUID* in/out -> "intptr" ; lphAgentSession : DWORD* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
tapi32 = windows.NewLazySystemDLL("TAPI32.dll")
proclineCreateAgentSessionA = tapi32.NewProc("lineCreateAgentSessionA")
)
// hLine (DWORD), hAgent (DWORD), lpszAgentPIN (LPCSTR optional), dwWorkingAddressID (DWORD), lpGroupID (GUID* in/out), lphAgentSession (DWORD* in/out)
r1, _, err := proclineCreateAgentSessionA.Call(
uintptr(hLine),
uintptr(hAgent),
uintptr(unsafe.Pointer(windows.BytePtrFromString(lpszAgentPIN))),
uintptr(dwWorkingAddressID),
uintptr(lpGroupID),
uintptr(lphAgentSession),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction lineCreateAgentSessionA(
hLine: DWORD; // DWORD
hAgent: DWORD; // DWORD
lpszAgentPIN: PAnsiChar; // LPCSTR optional
dwWorkingAddressID: DWORD; // DWORD
lpGroupID: PGUID; // GUID* in/out
lphAgentSession: Pointer // DWORD* in/out
): Integer; stdcall;
external 'TAPI32.dll' name 'lineCreateAgentSessionA';result := DllCall("TAPI32\lineCreateAgentSessionA"
, "UInt", hLine ; DWORD
, "UInt", hAgent ; DWORD
, "AStr", lpszAgentPIN ; LPCSTR optional
, "UInt", dwWorkingAddressID ; DWORD
, "Ptr", lpGroupID ; GUID* in/out
, "Ptr", lphAgentSession ; DWORD* in/out
, "Int") ; return: INT●lineCreateAgentSessionA(hLine, hAgent, lpszAgentPIN, dwWorkingAddressID, lpGroupID, lphAgentSession) = DLL("TAPI32.dll", "int lineCreateAgentSessionA(dword, dword, char*, dword, void*, void*)")
# 呼び出し: lineCreateAgentSessionA(hLine, hAgent, lpszAgentPIN, dwWorkingAddressID, lpGroupID, lphAgentSession)
# hLine : DWORD -> "dword"
# hAgent : DWORD -> "dword"
# lpszAgentPIN : LPCSTR optional -> "char*"
# dwWorkingAddressID : DWORD -> "dword"
# lpGroupID : GUID* in/out -> "void*"
# lphAgentSession : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "tapi32" fn lineCreateAgentSessionA(
hLine: u32, // DWORD
hAgent: u32, // DWORD
lpszAgentPIN: [*c]const u8, // LPCSTR optional
dwWorkingAddressID: u32, // DWORD
lpGroupID: [*c]GUID, // GUID* in/out
lphAgentSession: [*c]u32 // DWORD* in/out
) callconv(std.os.windows.WINAPI) i32;proc lineCreateAgentSessionA(
hLine: uint32, # DWORD
hAgent: uint32, # DWORD
lpszAgentPIN: cstring, # LPCSTR optional
dwWorkingAddressID: uint32, # DWORD
lpGroupID: ptr GUID, # GUID* in/out
lphAgentSession: ptr uint32 # DWORD* in/out
): int32 {.importc: "lineCreateAgentSessionA", stdcall, dynlib: "TAPI32.dll".}pragma(lib, "tapi32");
extern(Windows)
int lineCreateAgentSessionA(
uint hLine, // DWORD
uint hAgent, // DWORD
const(char)* lpszAgentPIN, // LPCSTR optional
uint dwWorkingAddressID, // DWORD
GUID* lpGroupID, // GUID* in/out
uint* lphAgentSession // DWORD* in/out
);ccall((:lineCreateAgentSessionA, "TAPI32.dll"), stdcall, Int32,
(UInt32, UInt32, Cstring, UInt32, Ptr{GUID}, Ptr{UInt32}),
hLine, hAgent, lpszAgentPIN, dwWorkingAddressID, lpGroupID, lphAgentSession)
# hLine : DWORD -> UInt32
# hAgent : DWORD -> UInt32
# lpszAgentPIN : LPCSTR optional -> Cstring
# dwWorkingAddressID : DWORD -> UInt32
# lpGroupID : GUID* in/out -> Ptr{GUID}
# lphAgentSession : DWORD* in/out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t lineCreateAgentSessionA(
uint32_t hLine,
uint32_t hAgent,
const char* lpszAgentPIN,
uint32_t dwWorkingAddressID,
void* lpGroupID,
uint32_t* lphAgentSession);
]]
local tapi32 = ffi.load("tapi32")
-- tapi32.lineCreateAgentSessionA(hLine, hAgent, lpszAgentPIN, dwWorkingAddressID, lpGroupID, lphAgentSession)
-- hLine : DWORD
-- hAgent : DWORD
-- lpszAgentPIN : LPCSTR optional
-- dwWorkingAddressID : DWORD
-- lpGroupID : GUID* in/out
-- lphAgentSession : DWORD* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('TAPI32.dll');
const lineCreateAgentSessionA = lib.func('__stdcall', 'lineCreateAgentSessionA', 'int32_t', ['uint32_t', 'uint32_t', 'str', 'uint32_t', 'void *', 'uint32_t *']);
// lineCreateAgentSessionA(hLine, hAgent, lpszAgentPIN, dwWorkingAddressID, lpGroupID, lphAgentSession)
// hLine : DWORD -> 'uint32_t'
// hAgent : DWORD -> 'uint32_t'
// lpszAgentPIN : LPCSTR optional -> 'str'
// 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", {
lineCreateAgentSessionA: { parameters: ["u32", "u32", "buffer", "u32", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.lineCreateAgentSessionA(hLine, hAgent, lpszAgentPIN, dwWorkingAddressID, lpGroupID, lphAgentSession)
// hLine : DWORD -> "u32"
// hAgent : DWORD -> "u32"
// lpszAgentPIN : LPCSTR optional -> "buffer"
// dwWorkingAddressID : DWORD -> "u32"
// lpGroupID : GUID* in/out -> "pointer"
// lphAgentSession : DWORD* in/out -> "pointer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t lineCreateAgentSessionA(
uint32_t hLine,
uint32_t hAgent,
const char* lpszAgentPIN,
uint32_t dwWorkingAddressID,
void* lpGroupID,
uint32_t* lphAgentSession);
C, "TAPI32.dll");
// $ffi->lineCreateAgentSessionA(hLine, hAgent, lpszAgentPIN, dwWorkingAddressID, lpGroupID, lphAgentSession);
// hLine : DWORD
// hAgent : DWORD
// lpszAgentPIN : LPCSTR 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.ASCII_OPTIONS);
int lineCreateAgentSessionA(
int hLine, // DWORD
int hAgent, // DWORD
String lpszAgentPIN, // LPCSTR optional
int dwWorkingAddressID, // DWORD
Pointer lpGroupID, // GUID* in/out
IntByReference lphAgentSession // DWORD* in/out
);
}@[Link("tapi32")]
lib LibTAPI32
fun lineCreateAgentSessionA = lineCreateAgentSessionA(
hLine : UInt32, # DWORD
hAgent : UInt32, # DWORD
lpszAgentPIN : UInt8*, # LPCSTR 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 lineCreateAgentSessionANative = Int32 Function(Uint32, Uint32, Pointer<Utf8>, Uint32, Pointer<Void>, Pointer<Uint32>);
typedef lineCreateAgentSessionADart = int Function(int, int, Pointer<Utf8>, int, Pointer<Void>, Pointer<Uint32>);
final lineCreateAgentSessionA = DynamicLibrary.open('TAPI32.dll')
.lookupFunction<lineCreateAgentSessionANative, lineCreateAgentSessionADart>('lineCreateAgentSessionA');
// hLine : DWORD -> Uint32
// hAgent : DWORD -> Uint32
// lpszAgentPIN : LPCSTR optional -> Pointer<Utf8>
// dwWorkingAddressID : DWORD -> Uint32
// lpGroupID : GUID* in/out -> Pointer<Void>
// lphAgentSession : DWORD* in/out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function lineCreateAgentSessionA(
hLine: DWORD; // DWORD
hAgent: DWORD; // DWORD
lpszAgentPIN: PAnsiChar; // LPCSTR optional
dwWorkingAddressID: DWORD; // DWORD
lpGroupID: PGUID; // GUID* in/out
lphAgentSession: Pointer // DWORD* in/out
): Integer; stdcall;
external 'TAPI32.dll' name 'lineCreateAgentSessionA';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "lineCreateAgentSessionA"
c_lineCreateAgentSessionA :: Word32 -> Word32 -> CString -> Word32 -> Ptr () -> Ptr Word32 -> IO Int32
-- hLine : DWORD -> Word32
-- hAgent : DWORD -> Word32
-- lpszAgentPIN : LPCSTR optional -> CString
-- 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 linecreateagentsessiona =
foreign "lineCreateAgentSessionA"
(uint32_t @-> uint32_t @-> string @-> uint32_t @-> (ptr void) @-> (ptr uint32_t) @-> returning int32_t)
(* hLine : DWORD -> uint32_t *)
(* hAgent : DWORD -> uint32_t *)
(* lpszAgentPIN : LPCSTR optional -> string *)
(* 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 ("lineCreateAgentSessionA" line-create-agent-session-a :convention :stdcall) :int32
(h-line :uint32) ; DWORD
(h-agent :uint32) ; DWORD
(lpsz-agent-pin :string) ; LPCSTR 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 $lineCreateAgentSessionA = Win32::API::More->new('TAPI32',
'int lineCreateAgentSessionA(DWORD hLine, DWORD hAgent, LPCSTR lpszAgentPIN, DWORD dwWorkingAddressID, LPVOID lpGroupID, LPVOID lphAgentSession)');
# my $ret = $lineCreateAgentSessionA->Call($hLine, $hAgent, $lpszAgentPIN, $dwWorkingAddressID, $lpGroupID, $lphAgentSession);
# hLine : DWORD -> DWORD
# hAgent : DWORD -> DWORD
# lpszAgentPIN : LPCSTR optional -> LPCSTR
# dwWorkingAddressID : DWORD -> DWORD
# lpGroupID : GUID* in/out -> LPVOID
# lphAgentSession : DWORD* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
文字セット違い
- f lineCreateAgentSessionW (Unicode版) — エージェントのセッションを作成しグループに関連付ける(Unicode版)。