ホーム › Devices.Tapi › tapiGetLocationInfo
tapiGetLocationInfo
関数現在の所在地の国コードと市外局番を取得する。
シグネチャ
// TAPI32.dll (ANSI / -A)
#include <windows.h>
INT tapiGetLocationInfo(
LPSTR lpszCountryCode,
LPSTR lpszCityCode
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| lpszCountryCode | LPSTR | out |
| lpszCityCode | LPSTR | out |
戻り値の型: INT
各言語での呼び出し定義
// TAPI32.dll (ANSI / -A)
#include <windows.h>
INT tapiGetLocationInfo(
LPSTR lpszCountryCode,
LPSTR lpszCityCode
);[DllImport("TAPI32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern int tapiGetLocationInfo(
[MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder lpszCountryCode, // LPSTR out
[MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder lpszCityCode // LPSTR out
);<DllImport("TAPI32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function tapiGetLocationInfo(
<MarshalAs(UnmanagedType.LPStr)> lpszCountryCode As System.Text.StringBuilder, ' LPSTR out
<MarshalAs(UnmanagedType.LPStr)> lpszCityCode As System.Text.StringBuilder ' LPSTR out
) As Integer
End Function' lpszCountryCode : LPSTR out
' lpszCityCode : LPSTR out
Declare PtrSafe Function tapiGetLocationInfo Lib "tapi32" ( _
ByVal lpszCountryCode As String, _
ByVal lpszCityCode As String) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
tapiGetLocationInfo = ctypes.windll.tapi32.tapiGetLocationInfo
tapiGetLocationInfo.restype = ctypes.c_int
tapiGetLocationInfo.argtypes = [
wintypes.LPSTR, # lpszCountryCode : LPSTR out
wintypes.LPSTR, # lpszCityCode : LPSTR out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('TAPI32.dll')
tapiGetLocationInfo = Fiddle::Function.new(
lib['tapiGetLocationInfo'],
[
Fiddle::TYPE_VOIDP, # lpszCountryCode : LPSTR out
Fiddle::TYPE_VOIDP, # lpszCityCode : LPSTR out
],
Fiddle::TYPE_INT)#[link(name = "tapi32")]
extern "system" {
fn tapiGetLocationInfo(
lpszCountryCode: *mut u8, // LPSTR out
lpszCityCode: *mut u8 // LPSTR out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("TAPI32.dll", CharSet = CharSet.Ansi)]
public static extern int tapiGetLocationInfo([MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder lpszCountryCode, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder lpszCityCode);
"@
$api = Add-Type -MemberDefinition $sig -Name 'TAPI32_tapiGetLocationInfo' -Namespace Win32 -PassThru
# $api::tapiGetLocationInfo(lpszCountryCode, lpszCityCode)#uselib "TAPI32.dll"
#func global tapiGetLocationInfo "tapiGetLocationInfo" sptr, sptr
; tapiGetLocationInfo varptr(lpszCountryCode), varptr(lpszCityCode) ; 戻り値は stat
; lpszCountryCode : LPSTR out -> "sptr"
; lpszCityCode : LPSTR out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "TAPI32.dll" #cfunc global tapiGetLocationInfo "tapiGetLocationInfo" var, var ; res = tapiGetLocationInfo(lpszCountryCode, lpszCityCode) ; lpszCountryCode : LPSTR out -> "var" ; lpszCityCode : LPSTR out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "TAPI32.dll" #cfunc global tapiGetLocationInfo "tapiGetLocationInfo" sptr, sptr ; res = tapiGetLocationInfo(varptr(lpszCountryCode), varptr(lpszCityCode)) ; lpszCountryCode : LPSTR out -> "sptr" ; lpszCityCode : LPSTR out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT tapiGetLocationInfo(LPSTR lpszCountryCode, LPSTR lpszCityCode) #uselib "TAPI32.dll" #cfunc global tapiGetLocationInfo "tapiGetLocationInfo" var, var ; res = tapiGetLocationInfo(lpszCountryCode, lpszCityCode) ; lpszCountryCode : LPSTR out -> "var" ; lpszCityCode : LPSTR out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT tapiGetLocationInfo(LPSTR lpszCountryCode, LPSTR lpszCityCode) #uselib "TAPI32.dll" #cfunc global tapiGetLocationInfo "tapiGetLocationInfo" intptr, intptr ; res = tapiGetLocationInfo(varptr(lpszCountryCode), varptr(lpszCityCode)) ; lpszCountryCode : LPSTR out -> "intptr" ; lpszCityCode : LPSTR out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
tapi32 = windows.NewLazySystemDLL("TAPI32.dll")
proctapiGetLocationInfo = tapi32.NewProc("tapiGetLocationInfo")
)
// lpszCountryCode (LPSTR out), lpszCityCode (LPSTR out)
r1, _, err := proctapiGetLocationInfo.Call(
uintptr(lpszCountryCode),
uintptr(lpszCityCode),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction tapiGetLocationInfo(
lpszCountryCode: PAnsiChar; // LPSTR out
lpszCityCode: PAnsiChar // LPSTR out
): Integer; stdcall;
external 'TAPI32.dll' name 'tapiGetLocationInfo';result := DllCall("TAPI32\tapiGetLocationInfo"
, "Ptr", lpszCountryCode ; LPSTR out
, "Ptr", lpszCityCode ; LPSTR out
, "Int") ; return: INT●tapiGetLocationInfo(lpszCountryCode, lpszCityCode) = DLL("TAPI32.dll", "int tapiGetLocationInfo(char*, char*)")
# 呼び出し: tapiGetLocationInfo(lpszCountryCode, lpszCityCode)
# lpszCountryCode : LPSTR out -> "char*"
# lpszCityCode : LPSTR out -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。