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

lineGetAddressIDW

関数
アドレス文字列から対応するアドレスIDを取得する(Unicode版)。
DLLTAPI32.dll文字セットUnicode (-W)呼出規約winapi

シグネチャ

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

INT lineGetAddressIDW(
    DWORD hLine,
    DWORD* lpdwAddressID,
    DWORD dwAddressMode,
    LPCWSTR lpsAddress,
    DWORD dwSize
);

パラメーター

名前方向説明
hLineDWORDin対象の回線デバイスハンドル。
lpdwAddressIDDWORD*inout取得したアドレスIDを受け取る出力ポインタ。
dwAddressModeDWORDinlpsAddressの解釈方法を示すフラグ(LINEADDRESSMODE_ADDRESSID等)。
lpsAddressLPCWSTRin変換元となるアドレス文字列(Unicode)へのポインタ。
dwSizeDWORDinlpsAddressのサイズをバイト単位で指定する。

戻り値の型: INT

各言語での呼び出し定義

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

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

lineGetAddressIDW = ctypes.windll.tapi32.lineGetAddressIDW
lineGetAddressIDW.restype = ctypes.c_int
lineGetAddressIDW.argtypes = [
    wintypes.DWORD,  # hLine : DWORD
    ctypes.POINTER(wintypes.DWORD),  # lpdwAddressID : DWORD* in/out
    wintypes.DWORD,  # dwAddressMode : DWORD
    wintypes.LPCWSTR,  # lpsAddress : LPCWSTR
    wintypes.DWORD,  # dwSize : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('TAPI32.dll')
lineGetAddressIDW = Fiddle::Function.new(
  lib['lineGetAddressIDW'],
  [
    -Fiddle::TYPE_INT,  # hLine : DWORD
    Fiddle::TYPE_VOIDP,  # lpdwAddressID : DWORD* in/out
    -Fiddle::TYPE_INT,  # dwAddressMode : DWORD
    Fiddle::TYPE_VOIDP,  # lpsAddress : LPCWSTR
    -Fiddle::TYPE_INT,  # dwSize : DWORD
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "tapi32")]
extern "system" {
    fn lineGetAddressIDW(
        hLine: u32,  // DWORD
        lpdwAddressID: *mut u32,  // DWORD* in/out
        dwAddressMode: u32,  // DWORD
        lpsAddress: *const u16,  // LPCWSTR
        dwSize: u32  // DWORD
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("TAPI32.dll", CharSet = CharSet.Unicode)]
public static extern int lineGetAddressIDW(uint hLine, ref uint lpdwAddressID, uint dwAddressMode, [MarshalAs(UnmanagedType.LPWStr)] string lpsAddress, uint dwSize);
"@
$api = Add-Type -MemberDefinition $sig -Name 'TAPI32_lineGetAddressIDW' -Namespace Win32 -PassThru
# $api::lineGetAddressIDW(hLine, lpdwAddressID, dwAddressMode, lpsAddress, dwSize)
#uselib "TAPI32.dll"
#func global lineGetAddressIDW "lineGetAddressIDW" wptr, wptr, wptr, wptr, wptr
; lineGetAddressIDW hLine, varptr(lpdwAddressID), dwAddressMode, lpsAddress, dwSize   ; 戻り値は stat
; hLine : DWORD -> "wptr"
; lpdwAddressID : DWORD* in/out -> "wptr"
; dwAddressMode : DWORD -> "wptr"
; lpsAddress : LPCWSTR -> "wptr"
; dwSize : DWORD -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "TAPI32.dll"
#cfunc global lineGetAddressIDW "lineGetAddressIDW" int, var, int, wstr, int
; res = lineGetAddressIDW(hLine, lpdwAddressID, dwAddressMode, lpsAddress, dwSize)
; hLine : DWORD -> "int"
; lpdwAddressID : DWORD* in/out -> "var"
; dwAddressMode : DWORD -> "int"
; lpsAddress : LPCWSTR -> "wstr"
; dwSize : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; INT lineGetAddressIDW(DWORD hLine, DWORD* lpdwAddressID, DWORD dwAddressMode, LPCWSTR lpsAddress, DWORD dwSize)
#uselib "TAPI32.dll"
#cfunc global lineGetAddressIDW "lineGetAddressIDW" int, var, int, wstr, int
; res = lineGetAddressIDW(hLine, lpdwAddressID, dwAddressMode, lpsAddress, dwSize)
; hLine : DWORD -> "int"
; lpdwAddressID : DWORD* in/out -> "var"
; dwAddressMode : DWORD -> "int"
; lpsAddress : LPCWSTR -> "wstr"
; dwSize : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	tapi32 = windows.NewLazySystemDLL("TAPI32.dll")
	proclineGetAddressIDW = tapi32.NewProc("lineGetAddressIDW")
)

// hLine (DWORD), lpdwAddressID (DWORD* in/out), dwAddressMode (DWORD), lpsAddress (LPCWSTR), dwSize (DWORD)
r1, _, err := proclineGetAddressIDW.Call(
	uintptr(hLine),
	uintptr(lpdwAddressID),
	uintptr(dwAddressMode),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpsAddress))),
	uintptr(dwSize),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function lineGetAddressIDW(
  hLine: DWORD;   // DWORD
  lpdwAddressID: Pointer;   // DWORD* in/out
  dwAddressMode: DWORD;   // DWORD
  lpsAddress: PWideChar;   // LPCWSTR
  dwSize: DWORD   // DWORD
): Integer; stdcall;
  external 'TAPI32.dll' name 'lineGetAddressIDW';
result := DllCall("TAPI32\lineGetAddressIDW"
    , "UInt", hLine   ; DWORD
    , "Ptr", lpdwAddressID   ; DWORD* in/out
    , "UInt", dwAddressMode   ; DWORD
    , "WStr", lpsAddress   ; LPCWSTR
    , "UInt", dwSize   ; DWORD
    , "Int")   ; return: INT
●lineGetAddressIDW(hLine, lpdwAddressID, dwAddressMode, lpsAddress, dwSize) = DLL("TAPI32.dll", "int lineGetAddressIDW(dword, void*, dword, char*, dword)")
# 呼び出し: lineGetAddressIDW(hLine, lpdwAddressID, dwAddressMode, lpsAddress, dwSize)
# hLine : DWORD -> "dword"
# lpdwAddressID : DWORD* in/out -> "void*"
# dwAddressMode : DWORD -> "dword"
# lpsAddress : LPCWSTR -> "char*"
# dwSize : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。
const std = @import("std");

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

foreign import stdcall safe "lineGetAddressIDW"
  c_lineGetAddressIDW :: Word32 -> Ptr Word32 -> Word32 -> CWString -> Word32 -> IO Int32
-- hLine : DWORD -> Word32
-- lpdwAddressID : DWORD* in/out -> Ptr Word32
-- dwAddressMode : DWORD -> Word32
-- lpsAddress : LPCWSTR -> CWString
-- dwSize : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let linegetaddressidw =
  foreign "lineGetAddressIDW"
    (uint32_t @-> (ptr uint32_t) @-> uint32_t @-> (ptr uint16_t) @-> uint32_t @-> returning int32_t)
(* hLine : DWORD -> uint32_t *)
(* lpdwAddressID : DWORD* in/out -> (ptr uint32_t) *)
(* dwAddressMode : DWORD -> uint32_t *)
(* lpsAddress : LPCWSTR -> (ptr uint16_t) *)
(* dwSize : 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 ("lineGetAddressIDW" line-get-address-idw :convention :stdcall) :int32
  (h-line :uint32)   ; DWORD
  (lpdw-address-id :pointer)   ; DWORD* in/out
  (dw-address-mode :uint32)   ; DWORD
  (lps-address (:string :encoding :utf-16le))   ; LPCWSTR
  (dw-size :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $lineGetAddressIDW = Win32::API::More->new('TAPI32',
    'int lineGetAddressIDW(DWORD hLine, LPVOID lpdwAddressID, DWORD dwAddressMode, LPCWSTR lpsAddress, DWORD dwSize)');
# my $ret = $lineGetAddressIDW->Call($hLine, $lpdwAddressID, $dwAddressMode, $lpsAddress, $dwSize);
# hLine : DWORD -> DWORD
# lpdwAddressID : DWORD* in/out -> LPVOID
# dwAddressMode : DWORD -> DWORD
# lpsAddress : LPCWSTR -> LPCWSTR
# dwSize : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。

関連項目

文字セット違い