Win32 API 日本語リファレンス
ホームNetworking.WinInet › InternetSecurityProtocolToStringW

InternetSecurityProtocolToStringW

関数
セキュリティプロトコル値を文字列名に変換する(Unicode版)。
DLLWININET.dll文字セットUnicode (-W)呼出規約winapi

シグネチャ

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

BOOL InternetSecurityProtocolToStringW(
    DWORD dwProtocol,
    LPWSTR lpstr,   // optional
    DWORD* lpdwstrLength,
    DWORD dwReserved   // optional
);

パラメーター

名前方向
dwProtocolDWORDin
lpstrLPWSTRoutoptional
lpdwstrLengthDWORD*inout
dwReservedDWORDoptional

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL InternetSecurityProtocolToStringW(
    DWORD dwProtocol,
    LPWSTR lpstr,   // optional
    DWORD* lpdwstrLength,
    DWORD dwReserved   // optional
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WININET.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern bool InternetSecurityProtocolToStringW(
    uint dwProtocol,   // DWORD
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpstr,   // LPWSTR optional, out
    ref uint lpdwstrLength,   // DWORD* in/out
    uint dwReserved   // DWORD optional
);
<DllImport("WININET.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function InternetSecurityProtocolToStringW(
    dwProtocol As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPWStr)> lpstr As System.Text.StringBuilder,   ' LPWSTR optional, out
    ByRef lpdwstrLength As UInteger,   ' DWORD* in/out
    dwReserved As UInteger   ' DWORD optional
) As Boolean
End Function
' dwProtocol : DWORD
' lpstr : LPWSTR optional, out
' lpdwstrLength : DWORD* in/out
' dwReserved : DWORD optional
Declare PtrSafe Function InternetSecurityProtocolToStringW Lib "wininet" ( _
    ByVal dwProtocol As Long, _
    ByVal lpstr As LongPtr, _
    ByRef lpdwstrLength As Long, _
    ByVal dwReserved 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

InternetSecurityProtocolToStringW = ctypes.windll.wininet.InternetSecurityProtocolToStringW
InternetSecurityProtocolToStringW.restype = wintypes.BOOL
InternetSecurityProtocolToStringW.argtypes = [
    wintypes.DWORD,  # dwProtocol : DWORD
    wintypes.LPWSTR,  # lpstr : LPWSTR optional, out
    ctypes.POINTER(wintypes.DWORD),  # lpdwstrLength : DWORD* in/out
    wintypes.DWORD,  # dwReserved : DWORD optional
]
require 'fiddle'
require 'fiddle/import'

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

var (
	wininet = windows.NewLazySystemDLL("WININET.dll")
	procInternetSecurityProtocolToStringW = wininet.NewProc("InternetSecurityProtocolToStringW")
)

// dwProtocol (DWORD), lpstr (LPWSTR optional, out), lpdwstrLength (DWORD* in/out), dwReserved (DWORD optional)
r1, _, err := procInternetSecurityProtocolToStringW.Call(
	uintptr(dwProtocol),
	uintptr(lpstr),
	uintptr(lpdwstrLength),
	uintptr(dwReserved),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function InternetSecurityProtocolToStringW(
  dwProtocol: DWORD;   // DWORD
  lpstr: PWideChar;   // LPWSTR optional, out
  lpdwstrLength: Pointer;   // DWORD* in/out
  dwReserved: DWORD   // DWORD optional
): BOOL; stdcall;
  external 'WININET.dll' name 'InternetSecurityProtocolToStringW';
result := DllCall("WININET\InternetSecurityProtocolToStringW"
    , "UInt", dwProtocol   ; DWORD
    , "Ptr", lpstr   ; LPWSTR optional, out
    , "Ptr", lpdwstrLength   ; DWORD* in/out
    , "UInt", dwReserved   ; DWORD optional
    , "Int")   ; return: BOOL
●InternetSecurityProtocolToStringW(dwProtocol, lpstr, lpdwstrLength, dwReserved) = DLL("WININET.dll", "bool InternetSecurityProtocolToStringW(dword, char*, void*, dword)")
# 呼び出し: InternetSecurityProtocolToStringW(dwProtocol, lpstr, lpdwstrLength, dwReserved)
# dwProtocol : DWORD -> "dword"
# lpstr : LPWSTR optional, out -> "char*"
# lpdwstrLength : DWORD* in/out -> "void*"
# dwReserved : DWORD optional -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。