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

tapiGetLocationInfoW

関数
所在地情報を取得する関数のUnicode版。
DLLTAPI32.dll文字セットUnicode (-W)呼出規約winapi

シグネチャ

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

INT tapiGetLocationInfoW(
    LPWSTR lpszCountryCodeW,
    LPWSTR lpszCityCodeW
);

パラメーター

名前方向
lpszCountryCodeWLPWSTRout
lpszCityCodeWLPWSTRout

戻り値の型: INT

各言語での呼び出し定義

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

INT tapiGetLocationInfoW(
    LPWSTR lpszCountryCodeW,
    LPWSTR lpszCityCodeW
);
[DllImport("TAPI32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int tapiGetLocationInfoW(
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpszCountryCodeW,   // LPWSTR out
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpszCityCodeW   // LPWSTR out
);
<DllImport("TAPI32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function tapiGetLocationInfoW(
    <MarshalAs(UnmanagedType.LPWStr)> lpszCountryCodeW As System.Text.StringBuilder,   ' LPWSTR out
    <MarshalAs(UnmanagedType.LPWStr)> lpszCityCodeW As System.Text.StringBuilder   ' LPWSTR out
) As Integer
End Function
' lpszCountryCodeW : LPWSTR out
' lpszCityCodeW : LPWSTR out
Declare PtrSafe Function tapiGetLocationInfoW Lib "tapi32" ( _
    ByVal lpszCountryCodeW As LongPtr, _
    ByVal lpszCityCodeW As LongPtr) 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

tapiGetLocationInfoW = ctypes.windll.tapi32.tapiGetLocationInfoW
tapiGetLocationInfoW.restype = ctypes.c_int
tapiGetLocationInfoW.argtypes = [
    wintypes.LPWSTR,  # lpszCountryCodeW : LPWSTR out
    wintypes.LPWSTR,  # lpszCityCodeW : LPWSTR out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	tapi32 = windows.NewLazySystemDLL("TAPI32.dll")
	proctapiGetLocationInfoW = tapi32.NewProc("tapiGetLocationInfoW")
)

// lpszCountryCodeW (LPWSTR out), lpszCityCodeW (LPWSTR out)
r1, _, err := proctapiGetLocationInfoW.Call(
	uintptr(lpszCountryCodeW),
	uintptr(lpszCityCodeW),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function tapiGetLocationInfoW(
  lpszCountryCodeW: PWideChar;   // LPWSTR out
  lpszCityCodeW: PWideChar   // LPWSTR out
): Integer; stdcall;
  external 'TAPI32.dll' name 'tapiGetLocationInfoW';
result := DllCall("TAPI32\tapiGetLocationInfoW"
    , "Ptr", lpszCountryCodeW   ; LPWSTR out
    , "Ptr", lpszCityCodeW   ; LPWSTR out
    , "Int")   ; return: INT
●tapiGetLocationInfoW(lpszCountryCodeW, lpszCityCodeW) = DLL("TAPI32.dll", "int tapiGetLocationInfoW(char*, char*)")
# 呼び出し: tapiGetLocationInfoW(lpszCountryCodeW, lpszCityCodeW)
# lpszCountryCodeW : LPWSTR out -> "char*"
# lpszCityCodeW : LPWSTR out -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。