ホーム › Networking.WinInet › HttpIsHostHstsEnabled
HttpIsHostHstsEnabled
関数指定URLのホストでHSTSが有効かを判定する。
シグネチャ
// WININET.dll
#include <windows.h>
DWORD HttpIsHostHstsEnabled(
LPCWSTR pcwszUrl,
BOOL* pfIsHsts
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pcwszUrl | LPCWSTR | in | HSTS有効性を判定する対象URLを指すワイド文字列。 |
| pfIsHsts | BOOL* | out | 対象ホストでHSTSが有効かを示すBOOL値を受け取るポインター。 |
戻り値の型: DWORD
各言語での呼び出し定義
// WININET.dll
#include <windows.h>
DWORD HttpIsHostHstsEnabled(
LPCWSTR pcwszUrl,
BOOL* pfIsHsts
);[DllImport("WININET.dll", ExactSpelling = true)]
static extern uint HttpIsHostHstsEnabled(
[MarshalAs(UnmanagedType.LPWStr)] string pcwszUrl, // LPCWSTR
out bool pfIsHsts // BOOL* out
);<DllImport("WININET.dll", ExactSpelling:=True)>
Public Shared Function HttpIsHostHstsEnabled(
<MarshalAs(UnmanagedType.LPWStr)> pcwszUrl As String, ' LPCWSTR
<Out> ByRef pfIsHsts As Boolean ' BOOL* out
) As UInteger
End Function' pcwszUrl : LPCWSTR
' pfIsHsts : BOOL* out
Declare PtrSafe Function HttpIsHostHstsEnabled Lib "wininet" ( _
ByVal pcwszUrl As LongPtr, _
ByRef pfIsHsts As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
HttpIsHostHstsEnabled = ctypes.windll.wininet.HttpIsHostHstsEnabled
HttpIsHostHstsEnabled.restype = wintypes.DWORD
HttpIsHostHstsEnabled.argtypes = [
wintypes.LPCWSTR, # pcwszUrl : LPCWSTR
ctypes.c_void_p, # pfIsHsts : BOOL* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WININET.dll')
HttpIsHostHstsEnabled = Fiddle::Function.new(
lib['HttpIsHostHstsEnabled'],
[
Fiddle::TYPE_VOIDP, # pcwszUrl : LPCWSTR
Fiddle::TYPE_VOIDP, # pfIsHsts : BOOL* out
],
-Fiddle::TYPE_INT)#[link(name = "wininet")]
extern "system" {
fn HttpIsHostHstsEnabled(
pcwszUrl: *const u16, // LPCWSTR
pfIsHsts: *mut i32 // BOOL* out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("WININET.dll")]
public static extern uint HttpIsHostHstsEnabled([MarshalAs(UnmanagedType.LPWStr)] string pcwszUrl, out bool pfIsHsts);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WININET_HttpIsHostHstsEnabled' -Namespace Win32 -PassThru
# $api::HttpIsHostHstsEnabled(pcwszUrl, pfIsHsts)#uselib "WININET.dll"
#func global HttpIsHostHstsEnabled "HttpIsHostHstsEnabled" sptr, sptr
; HttpIsHostHstsEnabled pcwszUrl, varptr(pfIsHsts) ; 戻り値は stat
; pcwszUrl : LPCWSTR -> "sptr"
; pfIsHsts : BOOL* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "WININET.dll" #cfunc global HttpIsHostHstsEnabled "HttpIsHostHstsEnabled" wstr, var ; res = HttpIsHostHstsEnabled(pcwszUrl, pfIsHsts) ; pcwszUrl : LPCWSTR -> "wstr" ; pfIsHsts : BOOL* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "WININET.dll" #cfunc global HttpIsHostHstsEnabled "HttpIsHostHstsEnabled" wstr, sptr ; res = HttpIsHostHstsEnabled(pcwszUrl, varptr(pfIsHsts)) ; pcwszUrl : LPCWSTR -> "wstr" ; pfIsHsts : BOOL* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD HttpIsHostHstsEnabled(LPCWSTR pcwszUrl, BOOL* pfIsHsts) #uselib "WININET.dll" #cfunc global HttpIsHostHstsEnabled "HttpIsHostHstsEnabled" wstr, var ; res = HttpIsHostHstsEnabled(pcwszUrl, pfIsHsts) ; pcwszUrl : LPCWSTR -> "wstr" ; pfIsHsts : BOOL* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD HttpIsHostHstsEnabled(LPCWSTR pcwszUrl, BOOL* pfIsHsts) #uselib "WININET.dll" #cfunc global HttpIsHostHstsEnabled "HttpIsHostHstsEnabled" wstr, intptr ; res = HttpIsHostHstsEnabled(pcwszUrl, varptr(pfIsHsts)) ; pcwszUrl : LPCWSTR -> "wstr" ; pfIsHsts : BOOL* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wininet = windows.NewLazySystemDLL("WININET.dll")
procHttpIsHostHstsEnabled = wininet.NewProc("HttpIsHostHstsEnabled")
)
// pcwszUrl (LPCWSTR), pfIsHsts (BOOL* out)
r1, _, err := procHttpIsHostHstsEnabled.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pcwszUrl))),
uintptr(pfIsHsts),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction HttpIsHostHstsEnabled(
pcwszUrl: PWideChar; // LPCWSTR
pfIsHsts: Pointer // BOOL* out
): DWORD; stdcall;
external 'WININET.dll' name 'HttpIsHostHstsEnabled';result := DllCall("WININET\HttpIsHostHstsEnabled"
, "WStr", pcwszUrl ; LPCWSTR
, "Ptr", pfIsHsts ; BOOL* out
, "UInt") ; return: DWORD●HttpIsHostHstsEnabled(pcwszUrl, pfIsHsts) = DLL("WININET.dll", "dword HttpIsHostHstsEnabled(char*, void*)")
# 呼び出し: HttpIsHostHstsEnabled(pcwszUrl, pfIsHsts)
# pcwszUrl : LPCWSTR -> "char*"
# pfIsHsts : BOOL* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "wininet" fn HttpIsHostHstsEnabled(
pcwszUrl: [*c]const u16, // LPCWSTR
pfIsHsts: [*c]i32 // BOOL* out
) callconv(std.os.windows.WINAPI) u32;proc HttpIsHostHstsEnabled(
pcwszUrl: WideCString, # LPCWSTR
pfIsHsts: ptr int32 # BOOL* out
): uint32 {.importc: "HttpIsHostHstsEnabled", stdcall, dynlib: "WININET.dll".}pragma(lib, "wininet");
extern(Windows)
uint HttpIsHostHstsEnabled(
const(wchar)* pcwszUrl, // LPCWSTR
int* pfIsHsts // BOOL* out
);ccall((:HttpIsHostHstsEnabled, "WININET.dll"), stdcall, UInt32,
(Cwstring, Ptr{Int32}),
pcwszUrl, pfIsHsts)
# pcwszUrl : LPCWSTR -> Cwstring
# pfIsHsts : BOOL* out -> Ptr{Int32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t HttpIsHostHstsEnabled(
const uint16_t* pcwszUrl,
int32_t* pfIsHsts);
]]
local wininet = ffi.load("wininet")
-- wininet.HttpIsHostHstsEnabled(pcwszUrl, pfIsHsts)
-- pcwszUrl : LPCWSTR
-- pfIsHsts : BOOL* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('WININET.dll');
const HttpIsHostHstsEnabled = lib.func('__stdcall', 'HttpIsHostHstsEnabled', 'uint32_t', ['str16', 'int32_t *']);
// HttpIsHostHstsEnabled(pcwszUrl, pfIsHsts)
// pcwszUrl : LPCWSTR -> 'str16'
// pfIsHsts : BOOL* out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("WININET.dll", {
HttpIsHostHstsEnabled: { parameters: ["buffer", "pointer"], result: "u32" },
});
// lib.symbols.HttpIsHostHstsEnabled(pcwszUrl, pfIsHsts)
// pcwszUrl : LPCWSTR -> "buffer"
// pfIsHsts : BOOL* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t HttpIsHostHstsEnabled(
const uint16_t* pcwszUrl,
int32_t* pfIsHsts);
C, "WININET.dll");
// $ffi->HttpIsHostHstsEnabled(pcwszUrl, pfIsHsts);
// pcwszUrl : LPCWSTR
// pfIsHsts : BOOL* 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 Wininet extends StdCallLibrary {
Wininet INSTANCE = Native.load("wininet", Wininet.class);
int HttpIsHostHstsEnabled(
WString pcwszUrl, // LPCWSTR
IntByReference pfIsHsts // BOOL* out
);
}@[Link("wininet")]
lib LibWININET
fun HttpIsHostHstsEnabled = HttpIsHostHstsEnabled(
pcwszUrl : UInt16*, # LPCWSTR
pfIsHsts : Int32* # BOOL* out
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef HttpIsHostHstsEnabledNative = Uint32 Function(Pointer<Utf16>, Pointer<Int32>);
typedef HttpIsHostHstsEnabledDart = int Function(Pointer<Utf16>, Pointer<Int32>);
final HttpIsHostHstsEnabled = DynamicLibrary.open('WININET.dll')
.lookupFunction<HttpIsHostHstsEnabledNative, HttpIsHostHstsEnabledDart>('HttpIsHostHstsEnabled');
// pcwszUrl : LPCWSTR -> Pointer<Utf16>
// pfIsHsts : BOOL* out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function HttpIsHostHstsEnabled(
pcwszUrl: PWideChar; // LPCWSTR
pfIsHsts: Pointer // BOOL* out
): DWORD; stdcall;
external 'WININET.dll' name 'HttpIsHostHstsEnabled';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "HttpIsHostHstsEnabled"
c_HttpIsHostHstsEnabled :: CWString -> Ptr CInt -> IO Word32
-- pcwszUrl : LPCWSTR -> CWString
-- pfIsHsts : BOOL* out -> Ptr CInt
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let httpishosthstsenabled =
foreign "HttpIsHostHstsEnabled"
((ptr uint16_t) @-> (ptr int32_t) @-> returning uint32_t)
(* pcwszUrl : LPCWSTR -> (ptr uint16_t) *)
(* pfIsHsts : BOOL* out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library wininet (t "WININET.dll"))
(cffi:use-foreign-library wininet)
(cffi:defcfun ("HttpIsHostHstsEnabled" http-is-host-hsts-enabled :convention :stdcall) :uint32
(pcwsz-url (:string :encoding :utf-16le)) ; LPCWSTR
(pf-is-hsts :pointer)) ; BOOL* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $HttpIsHostHstsEnabled = Win32::API::More->new('WININET',
'DWORD HttpIsHostHstsEnabled(LPCWSTR pcwszUrl, LPVOID pfIsHsts)');
# my $ret = $HttpIsHostHstsEnabled->Call($pcwszUrl, $pfIsHsts);
# pcwszUrl : LPCWSTR -> LPCWSTR
# pfIsHsts : BOOL* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。