ホーム › NetworkManagement.Rras › RasGetCountryInfoW
RasGetCountryInfoW
関数RASダイヤル用の国・地域情報を取得する(Unicode版)。
シグネチャ
// RASAPI32.dll (Unicode / -W)
#include <windows.h>
DWORD RasGetCountryInfoW(
RASCTRYINFO* param0, // optional
DWORD* param1
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| param0 | RASCTRYINFO* | inoutoptional | 国別ダイヤル情報を受け取るRASCTRYINFO構造体へのポインタ。先頭で対象の国/地域IDを指定する。 |
| param1 | DWORD* | inout | 入出力でバッファサイズ(バイト)を保持する変数へのポインタ。不足時は必要サイズが返る。 |
戻り値の型: DWORD
各言語での呼び出し定義
// RASAPI32.dll (Unicode / -W)
#include <windows.h>
DWORD RasGetCountryInfoW(
RASCTRYINFO* param0, // optional
DWORD* param1
);[DllImport("RASAPI32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint RasGetCountryInfoW(
IntPtr param0, // RASCTRYINFO* optional, in/out
ref uint param1 // DWORD* in/out
);<DllImport("RASAPI32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function RasGetCountryInfoW(
param0 As IntPtr, ' RASCTRYINFO* optional, in/out
ByRef param1 As UInteger ' DWORD* in/out
) As UInteger
End Function' param0 : RASCTRYINFO* optional, in/out
' param1 : DWORD* in/out
Declare PtrSafe Function RasGetCountryInfoW Lib "rasapi32" ( _
ByVal param0 As LongPtr, _
ByRef param1 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
RasGetCountryInfoW = ctypes.windll.rasapi32.RasGetCountryInfoW
RasGetCountryInfoW.restype = wintypes.DWORD
RasGetCountryInfoW.argtypes = [
ctypes.c_void_p, # param0 : RASCTRYINFO* optional, in/out
ctypes.POINTER(wintypes.DWORD), # param1 : DWORD* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('RASAPI32.dll')
RasGetCountryInfoW = Fiddle::Function.new(
lib['RasGetCountryInfoW'],
[
Fiddle::TYPE_VOIDP, # param0 : RASCTRYINFO* optional, in/out
Fiddle::TYPE_VOIDP, # param1 : DWORD* in/out
],
-Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "rasapi32")]
extern "system" {
fn RasGetCountryInfoW(
param0: *mut RASCTRYINFO, // RASCTRYINFO* optional, in/out
param1: *mut u32 // DWORD* in/out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("RASAPI32.dll", CharSet = CharSet.Unicode)]
public static extern uint RasGetCountryInfoW(IntPtr param0, ref uint param1);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RASAPI32_RasGetCountryInfoW' -Namespace Win32 -PassThru
# $api::RasGetCountryInfoW(param0, param1)#uselib "RASAPI32.dll"
#func global RasGetCountryInfoW "RasGetCountryInfoW" wptr, wptr
; RasGetCountryInfoW varptr(param0), varptr(param1) ; 戻り値は stat
; param0 : RASCTRYINFO* optional, in/out -> "wptr"
; param1 : DWORD* in/out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "RASAPI32.dll" #cfunc global RasGetCountryInfoW "RasGetCountryInfoW" var, var ; res = RasGetCountryInfoW(param0, param1) ; param0 : RASCTRYINFO* optional, in/out -> "var" ; param1 : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "RASAPI32.dll" #cfunc global RasGetCountryInfoW "RasGetCountryInfoW" sptr, sptr ; res = RasGetCountryInfoW(varptr(param0), varptr(param1)) ; param0 : RASCTRYINFO* optional, in/out -> "sptr" ; param1 : DWORD* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD RasGetCountryInfoW(RASCTRYINFO* param0, DWORD* param1) #uselib "RASAPI32.dll" #cfunc global RasGetCountryInfoW "RasGetCountryInfoW" var, var ; res = RasGetCountryInfoW(param0, param1) ; param0 : RASCTRYINFO* optional, in/out -> "var" ; param1 : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD RasGetCountryInfoW(RASCTRYINFO* param0, DWORD* param1) #uselib "RASAPI32.dll" #cfunc global RasGetCountryInfoW "RasGetCountryInfoW" intptr, intptr ; res = RasGetCountryInfoW(varptr(param0), varptr(param1)) ; param0 : RASCTRYINFO* optional, in/out -> "intptr" ; param1 : DWORD* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
rasapi32 = windows.NewLazySystemDLL("RASAPI32.dll")
procRasGetCountryInfoW = rasapi32.NewProc("RasGetCountryInfoW")
)
// param0 (RASCTRYINFO* optional, in/out), param1 (DWORD* in/out)
r1, _, err := procRasGetCountryInfoW.Call(
uintptr(param0),
uintptr(param1),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction RasGetCountryInfoW(
param0: Pointer; // RASCTRYINFO* optional, in/out
param1: Pointer // DWORD* in/out
): DWORD; stdcall;
external 'RASAPI32.dll' name 'RasGetCountryInfoW';result := DllCall("RASAPI32\RasGetCountryInfoW"
, "Ptr", param0 ; RASCTRYINFO* optional, in/out
, "Ptr", param1 ; DWORD* in/out
, "UInt") ; return: DWORD●RasGetCountryInfoW(param0, param1) = DLL("RASAPI32.dll", "dword RasGetCountryInfoW(void*, void*)")
# 呼び出し: RasGetCountryInfoW(param0, param1)
# param0 : RASCTRYINFO* optional, in/out -> "void*"
# param1 : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。const std = @import("std");
extern "rasapi32" fn RasGetCountryInfoW(
param0: [*c]RASCTRYINFO, // RASCTRYINFO* optional, in/out
param1: [*c]u32 // DWORD* in/out
) callconv(std.os.windows.WINAPI) u32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc RasGetCountryInfoW(
param0: ptr RASCTRYINFO, # RASCTRYINFO* optional, in/out
param1: ptr uint32 # DWORD* in/out
): uint32 {.importc: "RasGetCountryInfoW", stdcall, dynlib: "RASAPI32.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "rasapi32");
extern(Windows)
uint RasGetCountryInfoW(
RASCTRYINFO* param0, // RASCTRYINFO* optional, in/out
uint* param1 // DWORD* in/out
);ccall((:RasGetCountryInfoW, "RASAPI32.dll"), stdcall, UInt32,
(Ptr{RASCTRYINFO}, Ptr{UInt32}),
param0, param1)
# param0 : RASCTRYINFO* optional, in/out -> Ptr{RASCTRYINFO}
# param1 : DWORD* in/out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
uint32_t RasGetCountryInfoW(
void* param0,
uint32_t* param1);
]]
local rasapi32 = ffi.load("rasapi32")
-- rasapi32.RasGetCountryInfoW(param0, param1)
-- param0 : RASCTRYINFO* optional, in/out
-- param1 : DWORD* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。const koffi = require('koffi');
const lib = koffi.load('RASAPI32.dll');
const RasGetCountryInfoW = lib.func('__stdcall', 'RasGetCountryInfoW', 'uint32_t', ['void *', 'uint32_t *']);
// RasGetCountryInfoW(param0, param1)
// param0 : RASCTRYINFO* optional, in/out -> 'void *'
// param1 : DWORD* in/out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("RASAPI32.dll", {
RasGetCountryInfoW: { parameters: ["pointer", "pointer"], result: "u32" },
});
// lib.symbols.RasGetCountryInfoW(param0, param1)
// param0 : RASCTRYINFO* optional, in/out -> "pointer"
// param1 : DWORD* in/out -> "pointer"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t RasGetCountryInfoW(
void* param0,
uint32_t* param1);
C, "RASAPI32.dll");
// $ffi->RasGetCountryInfoW(param0, param1);
// param0 : RASCTRYINFO* optional, in/out
// param1 : 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 Rasapi32 extends StdCallLibrary {
Rasapi32 INSTANCE = Native.load("rasapi32", Rasapi32.class, W32APIOptions.UNICODE_OPTIONS);
int RasGetCountryInfoW(
Pointer param0, // RASCTRYINFO* optional, in/out
IntByReference param1 // DWORD* in/out
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("rasapi32")]
lib LibRASAPI32
fun RasGetCountryInfoW = RasGetCountryInfoW(
param0 : RASCTRYINFO*, # RASCTRYINFO* optional, in/out
param1 : UInt32* # DWORD* in/out
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef RasGetCountryInfoWNative = Uint32 Function(Pointer<Void>, Pointer<Uint32>);
typedef RasGetCountryInfoWDart = int Function(Pointer<Void>, Pointer<Uint32>);
final RasGetCountryInfoW = DynamicLibrary.open('RASAPI32.dll')
.lookupFunction<RasGetCountryInfoWNative, RasGetCountryInfoWDart>('RasGetCountryInfoW');
// param0 : RASCTRYINFO* optional, in/out -> Pointer<Void>
// param1 : DWORD* in/out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function RasGetCountryInfoW(
param0: Pointer; // RASCTRYINFO* optional, in/out
param1: Pointer // DWORD* in/out
): DWORD; stdcall;
external 'RASAPI32.dll' name 'RasGetCountryInfoW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "RasGetCountryInfoW"
c_RasGetCountryInfoW :: Ptr () -> Ptr Word32 -> IO Word32
-- param0 : RASCTRYINFO* optional, in/out -> Ptr ()
-- param1 : DWORD* in/out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let rasgetcountryinfow =
foreign "RasGetCountryInfoW"
((ptr void) @-> (ptr uint32_t) @-> returning uint32_t)
(* param0 : RASCTRYINFO* optional, in/out -> (ptr void) *)
(* param1 : DWORD* in/out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library rasapi32 (t "RASAPI32.dll"))
(cffi:use-foreign-library rasapi32)
(cffi:defcfun ("RasGetCountryInfoW" ras-get-country-info-w :convention :stdcall) :uint32
(param0 :pointer) ; RASCTRYINFO* optional, in/out
(param1 :pointer)) ; DWORD* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $RasGetCountryInfoW = Win32::API::More->new('RASAPI32',
'DWORD RasGetCountryInfoW(LPVOID param0, LPVOID param1)');
# my $ret = $RasGetCountryInfoW->Call($param0, $param1);
# param0 : RASCTRYINFO* optional, in/out -> LPVOID
# param1 : DWORD* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
文字セット違い
- f RasGetCountryInfoA (ANSI版) — RASダイヤル用の国・地域情報を取得する(ANSI版)。
使用する型