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

HttpQueryServiceConfiguration

関数
HTTPサービスの構成設定を取得する。
DLLHTTPAPI.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

// HTTPAPI.dll
#include <windows.h>

DWORD HttpQueryServiceConfiguration(
    HANDLE ServiceHandle,   // optional
    HTTP_SERVICE_CONFIG_ID ConfigId,
    void* pInput,   // optional
    DWORD InputLength,
    void* pOutput,   // optional
    DWORD OutputLength,
    DWORD* pReturnLength,   // optional
    OVERLAPPED* pOverlapped   // optional
);

パラメーター

名前方向説明
ServiceHandleHANDLEoptional予約済み。ゼロを指定する必要があります。
ConfigIdHTTP_SERVICE_CONFIG_IDin

構成レコードのクエリ種別。このパラメーターは、 HTTP_SERVICE_CONFIG_ID 列挙体の次の値のいずれかです。

ConfigId の値 意味
HttpServiceConfigIPListenList
IP リッスン リストをクエリします。
HttpServiceConfigSSLCertInfo
特定の証明書レコードについて SSL ストアをクエリします。
HttpServiceConfigUrlAclInfo
URL 予約情報をクエリします。
HttpServiceConfigTimeout
HTTP Server API 全体の接続タイムアウトをクエリします。

Windows Vista 以降: この列挙体がサポートされます。

HttpServiceConfigSslSniCertInfo
特定の証明書レコードについて SSL Server Name Indication (SNI) ストアをクエリします。

Windows 8 以降: この列挙値がサポートされます。

HttpServiceConfigSslCcsCertInfo
ポート上の SSL Centralized Certificate Store (CCS) レコードについて SSL 構成をクエリします。ポートは、pInputConfigInfo パラメーターに渡す HTTP_SERVICE_CONFIG_SSL_CCS_QUERY 構造体の KeyDesc メンバーで指定します。

Windows 8 以降: この列挙値がサポートされます。

pInputvoid*inoptional

クエリをさらに定義する内容を持つ構造体へのポインター。型は、次の表に従って ConfigId と対応します。

ConfigId の値 意味
HttpServiceConfigIPListenList
入力データはありません。NULL を設定します。
HttpServiceConfigSSLCertInfo

HTTP_SERVICE_CONFIG_SSL_QUERY 構造体。

HttpServiceConfigUrlAclInfo

HTTP_SERVICE_CONFIG_URLACL_QUERY 構造体。

HttpServiceConfigTimeout

HTTP_SERVICE_CONFIG_TIMEOUT_KEY 構造体。

Windows Vista 以降: この構造体がサポートされます。

HttpServiceConfigSslSniCertInfo

HTTP_SERVICE_CONFIG_SSL_SNI_QUERY 構造体。

Windows 8 以降: この構造体がサポートされます。

HttpServiceConfigSslCcsCertInfo

HTTP_SERVICE_CONFIG_SSL_CCS_QUERY 構造体。

Windows 8 以降: この構造体がサポートされます。

詳細については、該当するクエリ構造体を参照してください。

InputLengthDWORDinpInputConfigInfo バッファーのサイズ (バイト単位)。
pOutputvoid*outoptional

クエリ結果が返されるバッファーへのポインター。このバッファーの型は ConfigId と対応します。

ConfigId の値 意味
HttpServiceConfigIPListenList

HTTP_SERVICE_CONFIG_IP_LISTEN_QUERY 構造体。

HttpServiceConfigSSLCertInfo

HTTP_SERVICE_CONFIG_SSL_SET 構造体。

HttpServiceConfigUrlAclInfo

HTTP_SERVICE_CONFIG_URLACL_SET 構造体。

HttpServiceConfigTimeout

HTTP_SERVICE_CONFIG_TIMEOUT_PARAM データ型。

Windows Vista 以降: この構造体がサポートされます。

HttpServiceConfigSslSniCertInfo

HTTP_SERVICE_CONFIG_SSL_SNI_SET 構造体。

Windows 8 以降: この構造体がサポートされます。

HttpServiceConfigSslCcsCertInfo

HTTP_SERVICE_CONFIG_SSL_CCS_SET 構造体。

Windows 8 以降: この構造体がサポートされます。

OutputLengthDWORDinpOutputConfigInfo バッファーのサイズ (バイト単位)。
pReturnLengthDWORD*outoptional出力バッファーに書き込まれるバイト数を受け取る変数へのポインター。出力バッファーが小さすぎる場合、呼び出しは戻り値 ERROR_INSUFFICIENT_BUFFER で失敗します。pReturnLength が指す値を使用して、呼び出しが成功するためにバッファーに必要な最小の長さを判断できます。
pOverlappedOVERLAPPED*optional非同期操作のために予約されており、NULL を設定する必要があります。

戻り値の型: DWORD

公式ドキュメント

1 つ以上の HTTP Server API 構成レコードを取得します。

戻り値

関数が成功した場合、戻り値は NO_ERROR です。

関数が失敗した場合、戻り値は次のいずれかのエラー コードです。

意味
ERROR_INVALID_PARAMETER
いずれかのパラメーターが無効です。
ERROR_INSUFFICIENT_BUFFER
pOutputConfigInfo が指すバッファーが小さすぎて出力データを受け取れません。終了時に pReturnLength が指すサイズ以上のバッファーで関数を再度呼び出してください。
ERROR_MORE_DATA
pOutputConfigInfo が指すバッファーが小さすぎて出力データを受け取れません。終了時に pReturnLength が指すサイズ以上のバッファーで関数を再度呼び出してください。
ERROR_NO_MORE_ITEMS
指定した条件に一致する、返すべき項目がこれ以上ありません。
その他
WinError.h で定義されたシステム エラー コード
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

// HTTPAPI.dll
#include <windows.h>

DWORD HttpQueryServiceConfiguration(
    HANDLE ServiceHandle,   // optional
    HTTP_SERVICE_CONFIG_ID ConfigId,
    void* pInput,   // optional
    DWORD InputLength,
    void* pOutput,   // optional
    DWORD OutputLength,
    DWORD* pReturnLength,   // optional
    OVERLAPPED* pOverlapped   // optional
);
[DllImport("HTTPAPI.dll", ExactSpelling = true)]
static extern uint HttpQueryServiceConfiguration(
    IntPtr ServiceHandle,   // HANDLE optional
    int ConfigId,   // HTTP_SERVICE_CONFIG_ID
    IntPtr pInput,   // void* optional
    uint InputLength,   // DWORD
    IntPtr pOutput,   // void* optional, out
    uint OutputLength,   // DWORD
    IntPtr pReturnLength,   // DWORD* optional, out
    IntPtr pOverlapped   // OVERLAPPED* optional
);
<DllImport("HTTPAPI.dll", ExactSpelling:=True)>
Public Shared Function HttpQueryServiceConfiguration(
    ServiceHandle As IntPtr,   ' HANDLE optional
    ConfigId As Integer,   ' HTTP_SERVICE_CONFIG_ID
    pInput As IntPtr,   ' void* optional
    InputLength As UInteger,   ' DWORD
    pOutput As IntPtr,   ' void* optional, out
    OutputLength As UInteger,   ' DWORD
    pReturnLength As IntPtr,   ' DWORD* optional, out
    pOverlapped As IntPtr   ' OVERLAPPED* optional
) As UInteger
End Function
' ServiceHandle : HANDLE optional
' ConfigId : HTTP_SERVICE_CONFIG_ID
' pInput : void* optional
' InputLength : DWORD
' pOutput : void* optional, out
' OutputLength : DWORD
' pReturnLength : DWORD* optional, out
' pOverlapped : OVERLAPPED* optional
Declare PtrSafe Function HttpQueryServiceConfiguration Lib "httpapi" ( _
    ByVal ServiceHandle As LongPtr, _
    ByVal ConfigId As Long, _
    ByVal pInput As LongPtr, _
    ByVal InputLength As Long, _
    ByVal pOutput As LongPtr, _
    ByVal OutputLength As Long, _
    ByVal pReturnLength As LongPtr, _
    ByVal pOverlapped As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

HttpQueryServiceConfiguration = ctypes.windll.httpapi.HttpQueryServiceConfiguration
HttpQueryServiceConfiguration.restype = wintypes.DWORD
HttpQueryServiceConfiguration.argtypes = [
    wintypes.HANDLE,  # ServiceHandle : HANDLE optional
    ctypes.c_int,  # ConfigId : HTTP_SERVICE_CONFIG_ID
    ctypes.POINTER(None),  # pInput : void* optional
    wintypes.DWORD,  # InputLength : DWORD
    ctypes.POINTER(None),  # pOutput : void* optional, out
    wintypes.DWORD,  # OutputLength : DWORD
    ctypes.POINTER(wintypes.DWORD),  # pReturnLength : DWORD* optional, out
    ctypes.c_void_p,  # pOverlapped : OVERLAPPED* optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('HTTPAPI.dll')
HttpQueryServiceConfiguration = Fiddle::Function.new(
  lib['HttpQueryServiceConfiguration'],
  [
    Fiddle::TYPE_VOIDP,  # ServiceHandle : HANDLE optional
    Fiddle::TYPE_INT,  # ConfigId : HTTP_SERVICE_CONFIG_ID
    Fiddle::TYPE_VOIDP,  # pInput : void* optional
    -Fiddle::TYPE_INT,  # InputLength : DWORD
    Fiddle::TYPE_VOIDP,  # pOutput : void* optional, out
    -Fiddle::TYPE_INT,  # OutputLength : DWORD
    Fiddle::TYPE_VOIDP,  # pReturnLength : DWORD* optional, out
    Fiddle::TYPE_VOIDP,  # pOverlapped : OVERLAPPED* optional
  ],
  -Fiddle::TYPE_INT)
#[link(name = "httpapi")]
extern "system" {
    fn HttpQueryServiceConfiguration(
        ServiceHandle: *mut core::ffi::c_void,  // HANDLE optional
        ConfigId: i32,  // HTTP_SERVICE_CONFIG_ID
        pInput: *mut (),  // void* optional
        InputLength: u32,  // DWORD
        pOutput: *mut (),  // void* optional, out
        OutputLength: u32,  // DWORD
        pReturnLength: *mut u32,  // DWORD* optional, out
        pOverlapped: *mut OVERLAPPED  // OVERLAPPED* optional
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("HTTPAPI.dll")]
public static extern uint HttpQueryServiceConfiguration(IntPtr ServiceHandle, int ConfigId, IntPtr pInput, uint InputLength, IntPtr pOutput, uint OutputLength, IntPtr pReturnLength, IntPtr pOverlapped);
"@
$api = Add-Type -MemberDefinition $sig -Name 'HTTPAPI_HttpQueryServiceConfiguration' -Namespace Win32 -PassThru
# $api::HttpQueryServiceConfiguration(ServiceHandle, ConfigId, pInput, InputLength, pOutput, OutputLength, pReturnLength, pOverlapped)
#uselib "HTTPAPI.dll"
#func global HttpQueryServiceConfiguration "HttpQueryServiceConfiguration" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; HttpQueryServiceConfiguration ServiceHandle, ConfigId, pInput, InputLength, pOutput, OutputLength, varptr(pReturnLength), varptr(pOverlapped)   ; 戻り値は stat
; ServiceHandle : HANDLE optional -> "sptr"
; ConfigId : HTTP_SERVICE_CONFIG_ID -> "sptr"
; pInput : void* optional -> "sptr"
; InputLength : DWORD -> "sptr"
; pOutput : void* optional, out -> "sptr"
; OutputLength : DWORD -> "sptr"
; pReturnLength : DWORD* optional, out -> "sptr"
; pOverlapped : OVERLAPPED* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "HTTPAPI.dll"
#cfunc global HttpQueryServiceConfiguration "HttpQueryServiceConfiguration" sptr, int, sptr, int, sptr, int, var, var
; res = HttpQueryServiceConfiguration(ServiceHandle, ConfigId, pInput, InputLength, pOutput, OutputLength, pReturnLength, pOverlapped)
; ServiceHandle : HANDLE optional -> "sptr"
; ConfigId : HTTP_SERVICE_CONFIG_ID -> "int"
; pInput : void* optional -> "sptr"
; InputLength : DWORD -> "int"
; pOutput : void* optional, out -> "sptr"
; OutputLength : DWORD -> "int"
; pReturnLength : DWORD* optional, out -> "var"
; pOverlapped : OVERLAPPED* optional -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD HttpQueryServiceConfiguration(HANDLE ServiceHandle, HTTP_SERVICE_CONFIG_ID ConfigId, void* pInput, DWORD InputLength, void* pOutput, DWORD OutputLength, DWORD* pReturnLength, OVERLAPPED* pOverlapped)
#uselib "HTTPAPI.dll"
#cfunc global HttpQueryServiceConfiguration "HttpQueryServiceConfiguration" intptr, int, intptr, int, intptr, int, var, var
; res = HttpQueryServiceConfiguration(ServiceHandle, ConfigId, pInput, InputLength, pOutput, OutputLength, pReturnLength, pOverlapped)
; ServiceHandle : HANDLE optional -> "intptr"
; ConfigId : HTTP_SERVICE_CONFIG_ID -> "int"
; pInput : void* optional -> "intptr"
; InputLength : DWORD -> "int"
; pOutput : void* optional, out -> "intptr"
; OutputLength : DWORD -> "int"
; pReturnLength : DWORD* optional, out -> "var"
; pOverlapped : OVERLAPPED* optional -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	httpapi = windows.NewLazySystemDLL("HTTPAPI.dll")
	procHttpQueryServiceConfiguration = httpapi.NewProc("HttpQueryServiceConfiguration")
)

// ServiceHandle (HANDLE optional), ConfigId (HTTP_SERVICE_CONFIG_ID), pInput (void* optional), InputLength (DWORD), pOutput (void* optional, out), OutputLength (DWORD), pReturnLength (DWORD* optional, out), pOverlapped (OVERLAPPED* optional)
r1, _, err := procHttpQueryServiceConfiguration.Call(
	uintptr(ServiceHandle),
	uintptr(ConfigId),
	uintptr(pInput),
	uintptr(InputLength),
	uintptr(pOutput),
	uintptr(OutputLength),
	uintptr(pReturnLength),
	uintptr(pOverlapped),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function HttpQueryServiceConfiguration(
  ServiceHandle: THandle;   // HANDLE optional
  ConfigId: Integer;   // HTTP_SERVICE_CONFIG_ID
  pInput: Pointer;   // void* optional
  InputLength: DWORD;   // DWORD
  pOutput: Pointer;   // void* optional, out
  OutputLength: DWORD;   // DWORD
  pReturnLength: Pointer;   // DWORD* optional, out
  pOverlapped: Pointer   // OVERLAPPED* optional
): DWORD; stdcall;
  external 'HTTPAPI.dll' name 'HttpQueryServiceConfiguration';
result := DllCall("HTTPAPI\HttpQueryServiceConfiguration"
    , "Ptr", ServiceHandle   ; HANDLE optional
    , "Int", ConfigId   ; HTTP_SERVICE_CONFIG_ID
    , "Ptr", pInput   ; void* optional
    , "UInt", InputLength   ; DWORD
    , "Ptr", pOutput   ; void* optional, out
    , "UInt", OutputLength   ; DWORD
    , "Ptr", pReturnLength   ; DWORD* optional, out
    , "Ptr", pOverlapped   ; OVERLAPPED* optional
    , "UInt")   ; return: DWORD
●HttpQueryServiceConfiguration(ServiceHandle, ConfigId, pInput, InputLength, pOutput, OutputLength, pReturnLength, pOverlapped) = DLL("HTTPAPI.dll", "dword HttpQueryServiceConfiguration(void*, int, void*, dword, void*, dword, void*, void*)")
# 呼び出し: HttpQueryServiceConfiguration(ServiceHandle, ConfigId, pInput, InputLength, pOutput, OutputLength, pReturnLength, pOverlapped)
# ServiceHandle : HANDLE optional -> "void*"
# ConfigId : HTTP_SERVICE_CONFIG_ID -> "int"
# pInput : void* optional -> "void*"
# InputLength : DWORD -> "dword"
# pOutput : void* optional, out -> "void*"
# OutputLength : DWORD -> "dword"
# pReturnLength : DWORD* optional, out -> "void*"
# pOverlapped : OVERLAPPED* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "httpapi" fn HttpQueryServiceConfiguration(
    ServiceHandle: ?*anyopaque, // HANDLE optional
    ConfigId: i32, // HTTP_SERVICE_CONFIG_ID
    pInput: ?*anyopaque, // void* optional
    InputLength: u32, // DWORD
    pOutput: ?*anyopaque, // void* optional, out
    OutputLength: u32, // DWORD
    pReturnLength: [*c]u32, // DWORD* optional, out
    pOverlapped: [*c]OVERLAPPED // OVERLAPPED* optional
) callconv(std.os.windows.WINAPI) u32;
proc HttpQueryServiceConfiguration(
    ServiceHandle: pointer,  # HANDLE optional
    ConfigId: int32,  # HTTP_SERVICE_CONFIG_ID
    pInput: pointer,  # void* optional
    InputLength: uint32,  # DWORD
    pOutput: pointer,  # void* optional, out
    OutputLength: uint32,  # DWORD
    pReturnLength: ptr uint32,  # DWORD* optional, out
    pOverlapped: ptr OVERLAPPED  # OVERLAPPED* optional
): uint32 {.importc: "HttpQueryServiceConfiguration", stdcall, dynlib: "HTTPAPI.dll".}
pragma(lib, "httpapi");
extern(Windows)
uint HttpQueryServiceConfiguration(
    void* ServiceHandle,   // HANDLE optional
    int ConfigId,   // HTTP_SERVICE_CONFIG_ID
    void* pInput,   // void* optional
    uint InputLength,   // DWORD
    void* pOutput,   // void* optional, out
    uint OutputLength,   // DWORD
    uint* pReturnLength,   // DWORD* optional, out
    OVERLAPPED* pOverlapped   // OVERLAPPED* optional
);
ccall((:HttpQueryServiceConfiguration, "HTTPAPI.dll"), stdcall, UInt32,
      (Ptr{Cvoid}, Int32, Ptr{Cvoid}, UInt32, Ptr{Cvoid}, UInt32, Ptr{UInt32}, Ptr{OVERLAPPED}),
      ServiceHandle, ConfigId, pInput, InputLength, pOutput, OutputLength, pReturnLength, pOverlapped)
# ServiceHandle : HANDLE optional -> Ptr{Cvoid}
# ConfigId : HTTP_SERVICE_CONFIG_ID -> Int32
# pInput : void* optional -> Ptr{Cvoid}
# InputLength : DWORD -> UInt32
# pOutput : void* optional, out -> Ptr{Cvoid}
# OutputLength : DWORD -> UInt32
# pReturnLength : DWORD* optional, out -> Ptr{UInt32}
# pOverlapped : OVERLAPPED* optional -> Ptr{OVERLAPPED}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
uint32_t HttpQueryServiceConfiguration(
    void* ServiceHandle,
    int32_t ConfigId,
    void* pInput,
    uint32_t InputLength,
    void* pOutput,
    uint32_t OutputLength,
    uint32_t* pReturnLength,
    void* pOverlapped);
]]
local httpapi = ffi.load("httpapi")
-- httpapi.HttpQueryServiceConfiguration(ServiceHandle, ConfigId, pInput, InputLength, pOutput, OutputLength, pReturnLength, pOverlapped)
-- ServiceHandle : HANDLE optional
-- ConfigId : HTTP_SERVICE_CONFIG_ID
-- pInput : void* optional
-- InputLength : DWORD
-- pOutput : void* optional, out
-- OutputLength : DWORD
-- pReturnLength : DWORD* optional, out
-- pOverlapped : OVERLAPPED* optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('HTTPAPI.dll');
const HttpQueryServiceConfiguration = lib.func('__stdcall', 'HttpQueryServiceConfiguration', 'uint32_t', ['void *', 'int32_t', 'void *', 'uint32_t', 'void *', 'uint32_t', 'uint32_t *', 'void *']);
// HttpQueryServiceConfiguration(ServiceHandle, ConfigId, pInput, InputLength, pOutput, OutputLength, pReturnLength, pOverlapped)
// ServiceHandle : HANDLE optional -> 'void *'
// ConfigId : HTTP_SERVICE_CONFIG_ID -> 'int32_t'
// pInput : void* optional -> 'void *'
// InputLength : DWORD -> 'uint32_t'
// pOutput : void* optional, out -> 'void *'
// OutputLength : DWORD -> 'uint32_t'
// pReturnLength : DWORD* optional, out -> 'uint32_t *'
// pOverlapped : OVERLAPPED* optional -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("HTTPAPI.dll", {
  HttpQueryServiceConfiguration: { parameters: ["pointer", "i32", "pointer", "u32", "pointer", "u32", "pointer", "pointer"], result: "u32" },
});
// lib.symbols.HttpQueryServiceConfiguration(ServiceHandle, ConfigId, pInput, InputLength, pOutput, OutputLength, pReturnLength, pOverlapped)
// ServiceHandle : HANDLE optional -> "pointer"
// ConfigId : HTTP_SERVICE_CONFIG_ID -> "i32"
// pInput : void* optional -> "pointer"
// InputLength : DWORD -> "u32"
// pOutput : void* optional, out -> "pointer"
// OutputLength : DWORD -> "u32"
// pReturnLength : DWORD* optional, out -> "pointer"
// pOverlapped : OVERLAPPED* optional -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t HttpQueryServiceConfiguration(
    void* ServiceHandle,
    int32_t ConfigId,
    void* pInput,
    uint32_t InputLength,
    void* pOutput,
    uint32_t OutputLength,
    uint32_t* pReturnLength,
    void* pOverlapped);
C, "HTTPAPI.dll");
// $ffi->HttpQueryServiceConfiguration(ServiceHandle, ConfigId, pInput, InputLength, pOutput, OutputLength, pReturnLength, pOverlapped);
// ServiceHandle : HANDLE optional
// ConfigId : HTTP_SERVICE_CONFIG_ID
// pInput : void* optional
// InputLength : DWORD
// pOutput : void* optional, out
// OutputLength : DWORD
// pReturnLength : DWORD* optional, out
// pOverlapped : OVERLAPPED* 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 Httpapi extends StdCallLibrary {
    Httpapi INSTANCE = Native.load("httpapi", Httpapi.class);
    int HttpQueryServiceConfiguration(
        Pointer ServiceHandle,   // HANDLE optional
        int ConfigId,   // HTTP_SERVICE_CONFIG_ID
        Pointer pInput,   // void* optional
        int InputLength,   // DWORD
        Pointer pOutput,   // void* optional, out
        int OutputLength,   // DWORD
        IntByReference pReturnLength,   // DWORD* optional, out
        Pointer pOverlapped   // OVERLAPPED* optional
    );
}
@[Link("httpapi")]
lib LibHTTPAPI
  fun HttpQueryServiceConfiguration = HttpQueryServiceConfiguration(
    ServiceHandle : Void*,   # HANDLE optional
    ConfigId : Int32,   # HTTP_SERVICE_CONFIG_ID
    pInput : Void*,   # void* optional
    InputLength : UInt32,   # DWORD
    pOutput : Void*,   # void* optional, out
    OutputLength : UInt32,   # DWORD
    pReturnLength : UInt32*,   # DWORD* optional, out
    pOverlapped : OVERLAPPED*   # OVERLAPPED* optional
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef HttpQueryServiceConfigurationNative = Uint32 Function(Pointer<Void>, Int32, Pointer<Void>, Uint32, Pointer<Void>, Uint32, Pointer<Uint32>, Pointer<Void>);
typedef HttpQueryServiceConfigurationDart = int Function(Pointer<Void>, int, Pointer<Void>, int, Pointer<Void>, int, Pointer<Uint32>, Pointer<Void>);
final HttpQueryServiceConfiguration = DynamicLibrary.open('HTTPAPI.dll')
    .lookupFunction<HttpQueryServiceConfigurationNative, HttpQueryServiceConfigurationDart>('HttpQueryServiceConfiguration');
// ServiceHandle : HANDLE optional -> Pointer<Void>
// ConfigId : HTTP_SERVICE_CONFIG_ID -> Int32
// pInput : void* optional -> Pointer<Void>
// InputLength : DWORD -> Uint32
// pOutput : void* optional, out -> Pointer<Void>
// OutputLength : DWORD -> Uint32
// pReturnLength : DWORD* optional, out -> Pointer<Uint32>
// pOverlapped : OVERLAPPED* optional -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function HttpQueryServiceConfiguration(
  ServiceHandle: THandle;   // HANDLE optional
  ConfigId: Integer;   // HTTP_SERVICE_CONFIG_ID
  pInput: Pointer;   // void* optional
  InputLength: DWORD;   // DWORD
  pOutput: Pointer;   // void* optional, out
  OutputLength: DWORD;   // DWORD
  pReturnLength: Pointer;   // DWORD* optional, out
  pOverlapped: Pointer   // OVERLAPPED* optional
): DWORD; stdcall;
  external 'HTTPAPI.dll' name 'HttpQueryServiceConfiguration';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "HttpQueryServiceConfiguration"
  c_HttpQueryServiceConfiguration :: Ptr () -> Int32 -> Ptr () -> Word32 -> Ptr () -> Word32 -> Ptr Word32 -> Ptr () -> IO Word32
-- ServiceHandle : HANDLE optional -> Ptr ()
-- ConfigId : HTTP_SERVICE_CONFIG_ID -> Int32
-- pInput : void* optional -> Ptr ()
-- InputLength : DWORD -> Word32
-- pOutput : void* optional, out -> Ptr ()
-- OutputLength : DWORD -> Word32
-- pReturnLength : DWORD* optional, out -> Ptr Word32
-- pOverlapped : OVERLAPPED* optional -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let httpqueryserviceconfiguration =
  foreign "HttpQueryServiceConfiguration"
    ((ptr void) @-> int32_t @-> (ptr void) @-> uint32_t @-> (ptr void) @-> uint32_t @-> (ptr uint32_t) @-> (ptr void) @-> returning uint32_t)
(* ServiceHandle : HANDLE optional -> (ptr void) *)
(* ConfigId : HTTP_SERVICE_CONFIG_ID -> int32_t *)
(* pInput : void* optional -> (ptr void) *)
(* InputLength : DWORD -> uint32_t *)
(* pOutput : void* optional, out -> (ptr void) *)
(* OutputLength : DWORD -> uint32_t *)
(* pReturnLength : DWORD* optional, out -> (ptr uint32_t) *)
(* pOverlapped : OVERLAPPED* optional -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library httpapi (t "HTTPAPI.dll"))
(cffi:use-foreign-library httpapi)

(cffi:defcfun ("HttpQueryServiceConfiguration" http-query-service-configuration :convention :stdcall) :uint32
  (service-handle :pointer)   ; HANDLE optional
  (config-id :int32)   ; HTTP_SERVICE_CONFIG_ID
  (p-input :pointer)   ; void* optional
  (input-length :uint32)   ; DWORD
  (p-output :pointer)   ; void* optional, out
  (output-length :uint32)   ; DWORD
  (p-return-length :pointer)   ; DWORD* optional, out
  (p-overlapped :pointer))   ; OVERLAPPED* optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $HttpQueryServiceConfiguration = Win32::API::More->new('HTTPAPI',
    'DWORD HttpQueryServiceConfiguration(HANDLE ServiceHandle, int ConfigId, LPVOID pInput, DWORD InputLength, LPVOID pOutput, DWORD OutputLength, LPVOID pReturnLength, LPVOID pOverlapped)');
# my $ret = $HttpQueryServiceConfiguration->Call($ServiceHandle, $ConfigId, $pInput, $InputLength, $pOutput, $OutputLength, $pReturnLength, $pOverlapped);
# ServiceHandle : HANDLE optional -> HANDLE
# ConfigId : HTTP_SERVICE_CONFIG_ID -> int
# pInput : void* optional -> LPVOID
# InputLength : DWORD -> DWORD
# pOutput : void* optional, out -> LPVOID
# OutputLength : DWORD -> DWORD
# pReturnLength : DWORD* optional, out -> LPVOID
# pOverlapped : OVERLAPPED* optional -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

公式の関連項目
使用する型