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

InternetSecurityProtocolToStringA

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

シグネチャ

// WININET.dll  (ANSI / -A)
#include <windows.h>

BOOL InternetSecurityProtocolToStringA(
    DWORD dwProtocol,
    LPSTR lpstr,   // optional
    DWORD* lpdwstrLength,
    DWORD dwReserved   // optional
);

パラメーター

名前方向
dwProtocolDWORDin
lpstrLPSTRoutoptional
lpdwstrLengthDWORD*inout
dwReservedDWORDoptional

戻り値の型: BOOL

各言語での呼び出し定義

// WININET.dll  (ANSI / -A)
#include <windows.h>

BOOL InternetSecurityProtocolToStringA(
    DWORD dwProtocol,
    LPSTR lpstr,   // optional
    DWORD* lpdwstrLength,
    DWORD dwReserved   // optional
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WININET.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern bool InternetSecurityProtocolToStringA(
    uint dwProtocol,   // DWORD
    [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder lpstr,   // LPSTR optional, out
    ref uint lpdwstrLength,   // DWORD* in/out
    uint dwReserved   // DWORD optional
);
<DllImport("WININET.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function InternetSecurityProtocolToStringA(
    dwProtocol As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPStr)> lpstr As System.Text.StringBuilder,   ' LPSTR optional, out
    ByRef lpdwstrLength As UInteger,   ' DWORD* in/out
    dwReserved As UInteger   ' DWORD optional
) As Boolean
End Function
' dwProtocol : DWORD
' lpstr : LPSTR optional, out
' lpdwstrLength : DWORD* in/out
' dwReserved : DWORD optional
Declare PtrSafe Function InternetSecurityProtocolToStringA Lib "wininet" ( _
    ByVal dwProtocol As Long, _
    ByVal lpstr As String, _
    ByRef lpdwstrLength As Long, _
    ByVal dwReserved As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

InternetSecurityProtocolToStringA = ctypes.windll.wininet.InternetSecurityProtocolToStringA
InternetSecurityProtocolToStringA.restype = wintypes.BOOL
InternetSecurityProtocolToStringA.argtypes = [
    wintypes.DWORD,  # dwProtocol : DWORD
    wintypes.LPSTR,  # lpstr : LPSTR 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')
InternetSecurityProtocolToStringA = Fiddle::Function.new(
  lib['InternetSecurityProtocolToStringA'],
  [
    -Fiddle::TYPE_INT,  # dwProtocol : DWORD
    Fiddle::TYPE_VOIDP,  # lpstr : LPSTR optional, out
    Fiddle::TYPE_VOIDP,  # lpdwstrLength : DWORD* in/out
    -Fiddle::TYPE_INT,  # dwReserved : DWORD optional
  ],
  Fiddle::TYPE_INT)
#[link(name = "wininet")]
extern "system" {
    fn InternetSecurityProtocolToStringA(
        dwProtocol: u32,  // DWORD
        lpstr: *mut u8,  // LPSTR 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.Ansi)]
public static extern bool InternetSecurityProtocolToStringA(uint dwProtocol, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder lpstr, ref uint lpdwstrLength, uint dwReserved);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WININET_InternetSecurityProtocolToStringA' -Namespace Win32 -PassThru
# $api::InternetSecurityProtocolToStringA(dwProtocol, lpstr, lpdwstrLength, dwReserved)
#uselib "WININET.dll"
#func global InternetSecurityProtocolToStringA "InternetSecurityProtocolToStringA" sptr, sptr, sptr, sptr
; InternetSecurityProtocolToStringA dwProtocol, varptr(lpstr), varptr(lpdwstrLength), dwReserved   ; 戻り値は stat
; dwProtocol : DWORD -> "sptr"
; lpstr : LPSTR optional, out -> "sptr"
; lpdwstrLength : DWORD* in/out -> "sptr"
; dwReserved : DWORD optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "WININET.dll"
#cfunc global InternetSecurityProtocolToStringA "InternetSecurityProtocolToStringA" int, var, var, int
; res = InternetSecurityProtocolToStringA(dwProtocol, lpstr, lpdwstrLength, dwReserved)
; dwProtocol : DWORD -> "int"
; lpstr : LPSTR optional, out -> "var"
; lpdwstrLength : DWORD* in/out -> "var"
; dwReserved : DWORD optional -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL InternetSecurityProtocolToStringA(DWORD dwProtocol, LPSTR lpstr, DWORD* lpdwstrLength, DWORD dwReserved)
#uselib "WININET.dll"
#cfunc global InternetSecurityProtocolToStringA "InternetSecurityProtocolToStringA" int, var, var, int
; res = InternetSecurityProtocolToStringA(dwProtocol, lpstr, lpdwstrLength, dwReserved)
; dwProtocol : DWORD -> "int"
; lpstr : LPSTR 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")
	procInternetSecurityProtocolToStringA = wininet.NewProc("InternetSecurityProtocolToStringA")
)

// dwProtocol (DWORD), lpstr (LPSTR optional, out), lpdwstrLength (DWORD* in/out), dwReserved (DWORD optional)
r1, _, err := procInternetSecurityProtocolToStringA.Call(
	uintptr(dwProtocol),
	uintptr(lpstr),
	uintptr(lpdwstrLength),
	uintptr(dwReserved),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function InternetSecurityProtocolToStringA(
  dwProtocol: DWORD;   // DWORD
  lpstr: PAnsiChar;   // LPSTR optional, out
  lpdwstrLength: Pointer;   // DWORD* in/out
  dwReserved: DWORD   // DWORD optional
): BOOL; stdcall;
  external 'WININET.dll' name 'InternetSecurityProtocolToStringA';
result := DllCall("WININET\InternetSecurityProtocolToStringA"
    , "UInt", dwProtocol   ; DWORD
    , "Ptr", lpstr   ; LPSTR optional, out
    , "Ptr", lpdwstrLength   ; DWORD* in/out
    , "UInt", dwReserved   ; DWORD optional
    , "Int")   ; return: BOOL
●InternetSecurityProtocolToStringA(dwProtocol, lpstr, lpdwstrLength, dwReserved) = DLL("WININET.dll", "bool InternetSecurityProtocolToStringA(dword, char*, void*, dword)")
# 呼び出し: InternetSecurityProtocolToStringA(dwProtocol, lpstr, lpdwstrLength, dwReserved)
# dwProtocol : DWORD -> "dword"
# lpstr : LPSTR optional, out -> "char*"
# lpdwstrLength : DWORD* in/out -> "void*"
# dwReserved : DWORD optional -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。