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文字列化するセキュリティプロトコル識別子(SSL/TLSのバージョン等)。
lpstrLPSTRoutoptionalプロトコル名の文字列を受け取るANSIバッファ。
lpdwstrLengthDWORD*inoutlpstrバッファのサイズ(文字数)を入出力するポインター。
dwReservedDWORDoptional将来の拡張用の予約引数。0を指定する。

戻り値の型: 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 <MarshalAs(UnmanagedType.Bool)> 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)。
const std = @import("std");

extern "wininet" fn InternetSecurityProtocolToStringA(
    dwProtocol: u32, // DWORD
    lpstr: [*c]u8, // LPSTR optional, out
    lpdwstrLength: [*c]u32, // DWORD* in/out
    dwReserved: u32 // DWORD optional
) callconv(std.os.windows.WINAPI) i32;
proc InternetSecurityProtocolToStringA(
    dwProtocol: uint32,  # DWORD
    lpstr: ptr char,  # LPSTR optional, out
    lpdwstrLength: ptr uint32,  # DWORD* in/out
    dwReserved: uint32  # DWORD optional
): int32 {.importc: "InternetSecurityProtocolToStringA", stdcall, dynlib: "WININET.dll".}
pragma(lib, "wininet");
extern(Windows)
int InternetSecurityProtocolToStringA(
    uint dwProtocol,   // DWORD
    char* lpstr,   // LPSTR optional, out
    uint* lpdwstrLength,   // DWORD* in/out
    uint dwReserved   // DWORD optional
);
ccall((:InternetSecurityProtocolToStringA, "WININET.dll"), stdcall, Int32,
      (UInt32, Ptr{UInt8}, Ptr{UInt32}, UInt32),
      dwProtocol, lpstr, lpdwstrLength, dwReserved)
# dwProtocol : DWORD -> UInt32
# lpstr : LPSTR optional, out -> Ptr{UInt8}
# lpdwstrLength : DWORD* in/out -> Ptr{UInt32}
# dwReserved : DWORD optional -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t InternetSecurityProtocolToStringA(
    uint32_t dwProtocol,
    char* lpstr,
    uint32_t* lpdwstrLength,
    uint32_t dwReserved);
]]
local wininet = ffi.load("wininet")
-- wininet.InternetSecurityProtocolToStringA(dwProtocol, lpstr, lpdwstrLength, dwReserved)
-- dwProtocol : DWORD
-- lpstr : LPSTR optional, out
-- lpdwstrLength : DWORD* in/out
-- dwReserved : DWORD optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('WININET.dll');
const InternetSecurityProtocolToStringA = lib.func('__stdcall', 'InternetSecurityProtocolToStringA', 'int32_t', ['uint32_t', 'char *', 'uint32_t *', 'uint32_t']);
// InternetSecurityProtocolToStringA(dwProtocol, lpstr, lpdwstrLength, dwReserved)
// dwProtocol : DWORD -> 'uint32_t'
// lpstr : LPSTR optional, out -> 'char *'
// lpdwstrLength : DWORD* in/out -> 'uint32_t *'
// dwReserved : DWORD optional -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("WININET.dll", {
  InternetSecurityProtocolToStringA: { parameters: ["u32", "buffer", "pointer", "u32"], result: "i32" },
});
// lib.symbols.InternetSecurityProtocolToStringA(dwProtocol, lpstr, lpdwstrLength, dwReserved)
// dwProtocol : DWORD -> "u32"
// lpstr : LPSTR optional, out -> "buffer"
// lpdwstrLength : DWORD* in/out -> "pointer"
// dwReserved : DWORD optional -> "u32"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t InternetSecurityProtocolToStringA(
    uint32_t dwProtocol,
    char* lpstr,
    uint32_t* lpdwstrLength,
    uint32_t dwReserved);
C, "WININET.dll");
// $ffi->InternetSecurityProtocolToStringA(dwProtocol, lpstr, lpdwstrLength, dwReserved);
// dwProtocol : DWORD
// lpstr : LPSTR optional, out
// lpdwstrLength : DWORD* in/out
// dwReserved : DWORD optional
// 構造体/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 Wininet extends StdCallLibrary {
    Wininet INSTANCE = Native.load("wininet", Wininet.class, W32APIOptions.ASCII_OPTIONS);
    boolean InternetSecurityProtocolToStringA(
        int dwProtocol,   // DWORD
        byte[] lpstr,   // LPSTR optional, out
        IntByReference lpdwstrLength,   // DWORD* in/out
        int dwReserved   // DWORD optional
    );
}
@[Link("wininet")]
lib LibWININET
  fun InternetSecurityProtocolToStringA = InternetSecurityProtocolToStringA(
    dwProtocol : UInt32,   # DWORD
    lpstr : UInt8*,   # LPSTR optional, out
    lpdwstrLength : UInt32*,   # DWORD* in/out
    dwReserved : UInt32   # DWORD optional
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef InternetSecurityProtocolToStringANative = Int32 Function(Uint32, Pointer<Utf8>, Pointer<Uint32>, Uint32);
typedef InternetSecurityProtocolToStringADart = int Function(int, Pointer<Utf8>, Pointer<Uint32>, int);
final InternetSecurityProtocolToStringA = DynamicLibrary.open('WININET.dll')
    .lookupFunction<InternetSecurityProtocolToStringANative, InternetSecurityProtocolToStringADart>('InternetSecurityProtocolToStringA');
// dwProtocol : DWORD -> Uint32
// lpstr : LPSTR optional, out -> Pointer<Utf8>
// lpdwstrLength : DWORD* in/out -> Pointer<Uint32>
// dwReserved : DWORD optional -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
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';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "InternetSecurityProtocolToStringA"
  c_InternetSecurityProtocolToStringA :: Word32 -> CString -> Ptr Word32 -> Word32 -> IO CInt
-- dwProtocol : DWORD -> Word32
-- lpstr : LPSTR optional, out -> CString
-- lpdwstrLength : DWORD* in/out -> Ptr Word32
-- dwReserved : DWORD optional -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let internetsecurityprotocoltostringa =
  foreign "InternetSecurityProtocolToStringA"
    (uint32_t @-> string @-> (ptr uint32_t) @-> uint32_t @-> returning int32_t)
(* dwProtocol : DWORD -> uint32_t *)
(* lpstr : LPSTR optional, out -> string *)
(* lpdwstrLength : DWORD* in/out -> (ptr uint32_t) *)
(* dwReserved : DWORD optional -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library wininet (t "WININET.dll"))
(cffi:use-foreign-library wininet)

(cffi:defcfun ("InternetSecurityProtocolToStringA" internet-security-protocol-to-string-a :convention :stdcall) :int32
  (dw-protocol :uint32)   ; DWORD
  (lpstr :pointer)   ; LPSTR optional, out
  (lpdwstr-length :pointer)   ; DWORD* in/out
  (dw-reserved :uint32))   ; DWORD optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $InternetSecurityProtocolToStringA = Win32::API::More->new('WININET',
    'BOOL InternetSecurityProtocolToStringA(DWORD dwProtocol, LPSTR lpstr, LPVOID lpdwstrLength, DWORD dwReserved)');
# my $ret = $InternetSecurityProtocolToStringA->Call($dwProtocol, $lpstr, $lpdwstrLength, $dwReserved);
# dwProtocol : DWORD -> DWORD
# lpstr : LPSTR optional, out -> LPSTR
# lpdwstrLength : DWORD* in/out -> LPVOID
# dwReserved : DWORD optional -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

文字セット違い