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