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

HttpSetServerSessionProperty

関数
サーバーセッションのプロパティを設定する。
DLLHTTPAPI.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

DWORD HttpSetServerSessionProperty(
    ULONGLONG ServerSessionId,
    HTTP_SERVER_PROPERTY Property,
    void* PropertyInformation,
    DWORD PropertyInformationLength
);

パラメーター

名前方向説明
ServerSessionIdULONGLONGinプロパティを設定する対象のサーバーセッション。
PropertyHTTP_SERVER_PROPERTYin

設定するプロパティの種類を示す HTTP_SERVER_PROPERTY 列挙体のメンバー。次のいずれかを指定できます。

Property 意味
HttpServerStateProperty
サーバーセッションの状態を変更または設定します。状態は有効または無効のいずれかで、既定の状態は有効です。
HttpServerTimeoutsProperty
サーバーセッションの接続タイムアウト制限を変更または設定します。
HttpServerQosProperty
サーバーセッションの帯域幅スロットリングを変更または設定します。既定では、HTTP Server API は帯域幅を制限しません。
注意 この値は、QosTypeHttpQosSettingTypeBandwidth に設定した汎用の HTTP_QOS_SETTING_INFO 構造体にマップされます。
HttpServerLoggingProperty
サーバーセッションのログ記録を有効または無効にします。このプロパティは、集中型 W3C ログと集中型バイナリログのみを設定します。既定では、ログ記録は有効になっていません。
HttpServerAuthenticationProperty
Basic、NTLM、Negotiate、Digest の各認証スキームに対して、カーネルモードのサーバー側認証を有効にします。
HttpServerExtendedAuthenticationProperty
Kerberos 認証スキームに対して、カーネルモードのサーバー側認証を有効にします。
HttpServerChannelBindProperty
チャネルバインディングトークン (CBT) を使用するサーバー側認証を有効にします。
PropertyInformationvoid*in

プロパティデータを格納するバッファーへのポインター。

pPropertyInformation は、設定するプロパティに応じて次の表に示すプロパティデータ構造体を指します。

Property 構造体
HttpServerStateProperty HTTP_STATE_INFO
HttpServerLoggingProperty HTTP_LOGGING_INFO
HttpServerQosProperty HTTP_QOS_SETTING_INFO
HttpServerTimeoutsProperty HTTP_TIMEOUT_LIMIT_INFO
HttpServerAuthenticationProperty HTTP_SERVER_AUTHENTICATION_INFO
HttpServerExtendedAuthenticationProperty HTTP_SERVER_AUTHENTICATION_INFO
HttpServerChannelBindProperty HTTP_CHANNEL_BIND_INFO
PropertyInformationLengthDWORDinpPropertyInformation パラメーターが指すバッファーの長さ (バイト単位)。

戻り値の型: DWORD

公式ドキュメント

指定したサーバーセッションに新しいサーバーセッションプロパティを設定するか、既存のプロパティを変更します。

戻り値

関数が成功した場合は NO_ERROR を返します。

関数が失敗した場合は、次のいずれかのエラーコードを返します。

意味
ERROR_INVALID_PARAMETER
Property パラメーターで指定されたプロパティの種類が、サーバーセッションでサポートされていません。

pPropertyInformation パラメーターが NULL です。

PropertyInformationLength パラメーターが 0 です。

ServerSessionId パラメーターに有効なサーバーセッションが含まれていません。

アプリケーションにサーバーセッションプロパティを設定する権限がありません。プロパティを設定できるのは、そのサーバーセッションを作成したアプリケーションのみです。

解説(Remarks)

サーバーセッションは、その配下に作成されたすべての URL グループに適用される構成データのための、最上位レベルの構成コンテナーです。サーバーセッションは HttpCreateServerSession で作成されます。

pPropertyInformation パラメーターは、設定するプロパティの種類に対応する構成構造体を指します。PropertyInformationLength パラメーターは、その構成構造体のサイズ (バイト単位) を指定します。たとえば、HttpServerTimeoutsProperty を設定する場合、pPropertyInformation パラメーターは、少なくとも HTTP_TIMEOUT_LIMIT_INFO 構造体のサイズ以上のバッファーを指している必要があります。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

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

DWORD HttpSetServerSessionProperty(
    ULONGLONG ServerSessionId,
    HTTP_SERVER_PROPERTY Property,
    void* PropertyInformation,
    DWORD PropertyInformationLength
);
[DllImport("HTTPAPI.dll", ExactSpelling = true)]
static extern uint HttpSetServerSessionProperty(
    ulong ServerSessionId,   // ULONGLONG
    int Property,   // HTTP_SERVER_PROPERTY
    IntPtr PropertyInformation,   // void*
    uint PropertyInformationLength   // DWORD
);
<DllImport("HTTPAPI.dll", ExactSpelling:=True)>
Public Shared Function HttpSetServerSessionProperty(
    ServerSessionId As ULong,   ' ULONGLONG
    [Property] As Integer,   ' HTTP_SERVER_PROPERTY
    PropertyInformation As IntPtr,   ' void*
    PropertyInformationLength As UInteger   ' DWORD
) As UInteger
End Function
' ServerSessionId : ULONGLONG
' Property : HTTP_SERVER_PROPERTY
' PropertyInformation : void*
' PropertyInformationLength : DWORD
Declare PtrSafe Function HttpSetServerSessionProperty Lib "httpapi" ( _
    ByVal ServerSessionId As LongLong, _
    ByVal Property As Long, _
    ByVal PropertyInformation As LongPtr, _
    ByVal PropertyInformationLength As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

HttpSetServerSessionProperty = ctypes.windll.httpapi.HttpSetServerSessionProperty
HttpSetServerSessionProperty.restype = wintypes.DWORD
HttpSetServerSessionProperty.argtypes = [
    ctypes.c_ulonglong,  # ServerSessionId : ULONGLONG
    ctypes.c_int,  # Property : HTTP_SERVER_PROPERTY
    ctypes.POINTER(None),  # PropertyInformation : void*
    wintypes.DWORD,  # PropertyInformationLength : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('HTTPAPI.dll')
HttpSetServerSessionProperty = Fiddle::Function.new(
  lib['HttpSetServerSessionProperty'],
  [
    -Fiddle::TYPE_LONG_LONG,  # ServerSessionId : ULONGLONG
    Fiddle::TYPE_INT,  # Property : HTTP_SERVER_PROPERTY
    Fiddle::TYPE_VOIDP,  # PropertyInformation : void*
    -Fiddle::TYPE_INT,  # PropertyInformationLength : DWORD
  ],
  -Fiddle::TYPE_INT)
#[link(name = "httpapi")]
extern "system" {
    fn HttpSetServerSessionProperty(
        ServerSessionId: u64,  // ULONGLONG
        Property: i32,  // HTTP_SERVER_PROPERTY
        PropertyInformation: *mut (),  // void*
        PropertyInformationLength: u32  // DWORD
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("HTTPAPI.dll")]
public static extern uint HttpSetServerSessionProperty(ulong ServerSessionId, int Property, IntPtr PropertyInformation, uint PropertyInformationLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'HTTPAPI_HttpSetServerSessionProperty' -Namespace Win32 -PassThru
# $api::HttpSetServerSessionProperty(ServerSessionId, Property, PropertyInformation, PropertyInformationLength)
#uselib "HTTPAPI.dll"
#func global HttpSetServerSessionProperty "HttpSetServerSessionProperty" sptr, sptr, sptr, sptr
; HttpSetServerSessionProperty ServerSessionId, Property, PropertyInformation, PropertyInformationLength   ; 戻り値は stat
; ServerSessionId : ULONGLONG -> "sptr"
; Property : HTTP_SERVER_PROPERTY -> "sptr"
; PropertyInformation : void* -> "sptr"
; PropertyInformationLength : DWORD -> "sptr"
; ※HSP3.7は int64 引数(64bit値渡し)に非対応です。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "HTTPAPI.dll"
#cfunc global HttpSetServerSessionProperty "HttpSetServerSessionProperty" int64, int, sptr, int
; res = HttpSetServerSessionProperty(ServerSessionId, Property, PropertyInformation, PropertyInformationLength)
; ServerSessionId : ULONGLONG -> "int64"
; Property : HTTP_SERVER_PROPERTY -> "int"
; PropertyInformation : void* -> "sptr"
; PropertyInformationLength : DWORD -> "int"
; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。
; DWORD HttpSetServerSessionProperty(ULONGLONG ServerSessionId, HTTP_SERVER_PROPERTY Property, void* PropertyInformation, DWORD PropertyInformationLength)
#uselib "HTTPAPI.dll"
#cfunc global HttpSetServerSessionProperty "HttpSetServerSessionProperty" int64, int, intptr, int
; res = HttpSetServerSessionProperty(ServerSessionId, Property, PropertyInformation, PropertyInformationLength)
; ServerSessionId : ULONGLONG -> "int64"
; Property : HTTP_SERVER_PROPERTY -> "int"
; PropertyInformation : void* -> "intptr"
; PropertyInformationLength : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	httpapi = windows.NewLazySystemDLL("HTTPAPI.dll")
	procHttpSetServerSessionProperty = httpapi.NewProc("HttpSetServerSessionProperty")
)

// ServerSessionId (ULONGLONG), Property (HTTP_SERVER_PROPERTY), PropertyInformation (void*), PropertyInformationLength (DWORD)
r1, _, err := procHttpSetServerSessionProperty.Call(
	uintptr(ServerSessionId),
	uintptr(Property),
	uintptr(PropertyInformation),
	uintptr(PropertyInformationLength),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function HttpSetServerSessionProperty(
  ServerSessionId: UInt64;   // ULONGLONG
  Property: Integer;   // HTTP_SERVER_PROPERTY
  PropertyInformation: Pointer;   // void*
  PropertyInformationLength: DWORD   // DWORD
): DWORD; stdcall;
  external 'HTTPAPI.dll' name 'HttpSetServerSessionProperty';
result := DllCall("HTTPAPI\HttpSetServerSessionProperty"
    , "Int64", ServerSessionId   ; ULONGLONG
    , "Int", Property   ; HTTP_SERVER_PROPERTY
    , "Ptr", PropertyInformation   ; void*
    , "UInt", PropertyInformationLength   ; DWORD
    , "UInt")   ; return: DWORD
●HttpSetServerSessionProperty(ServerSessionId, Property, PropertyInformation, PropertyInformationLength) = DLL("HTTPAPI.dll", "dword HttpSetServerSessionProperty(qword, int, void*, dword)")
# 呼び出し: HttpSetServerSessionProperty(ServerSessionId, Property, PropertyInformation, PropertyInformationLength)
# ServerSessionId : ULONGLONG -> "qword"
# Property : HTTP_SERVER_PROPERTY -> "int"
# PropertyInformation : void* -> "void*"
# PropertyInformationLength : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

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

typedef HttpSetServerSessionPropertyNative = Uint32 Function(Uint64, Int32, Pointer<Void>, Uint32);
typedef HttpSetServerSessionPropertyDart = int Function(int, int, Pointer<Void>, int);
final HttpSetServerSessionProperty = DynamicLibrary.open('HTTPAPI.dll')
    .lookupFunction<HttpSetServerSessionPropertyNative, HttpSetServerSessionPropertyDart>('HttpSetServerSessionProperty');
// ServerSessionId : ULONGLONG -> Uint64
// Property : HTTP_SERVER_PROPERTY -> Int32
// PropertyInformation : void* -> Pointer<Void>
// PropertyInformationLength : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function HttpSetServerSessionProperty(
  ServerSessionId: UInt64;   // ULONGLONG
  Property: Integer;   // HTTP_SERVER_PROPERTY
  PropertyInformation: Pointer;   // void*
  PropertyInformationLength: DWORD   // DWORD
): DWORD; stdcall;
  external 'HTTPAPI.dll' name 'HttpSetServerSessionProperty';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "HttpSetServerSessionProperty"
  c_HttpSetServerSessionProperty :: Word64 -> Int32 -> Ptr () -> Word32 -> IO Word32
-- ServerSessionId : ULONGLONG -> Word64
-- Property : HTTP_SERVER_PROPERTY -> Int32
-- PropertyInformation : void* -> Ptr ()
-- PropertyInformationLength : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let httpsetserversessionproperty =
  foreign "HttpSetServerSessionProperty"
    (uint64_t @-> int32_t @-> (ptr void) @-> uint32_t @-> returning uint32_t)
(* ServerSessionId : ULONGLONG -> uint64_t *)
(* Property : HTTP_SERVER_PROPERTY -> int32_t *)
(* PropertyInformation : void* -> (ptr void) *)
(* PropertyInformationLength : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library httpapi (t "HTTPAPI.dll"))
(cffi:use-foreign-library httpapi)

(cffi:defcfun ("HttpSetServerSessionProperty" http-set-server-session-property :convention :stdcall) :uint32
  (server-session-id :uint64)   ; ULONGLONG
  (property :int32)   ; HTTP_SERVER_PROPERTY
  (property-information :pointer)   ; void*
  (property-information-length :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $HttpSetServerSessionProperty = Win32::API::More->new('HTTPAPI',
    'DWORD HttpSetServerSessionProperty(UINT64 ServerSessionId, int Property, LPVOID PropertyInformation, DWORD PropertyInformationLength)');
# my $ret = $HttpSetServerSessionProperty->Call($ServerSessionId, $Property, $PropertyInformation, $PropertyInformationLength);
# ServerSessionId : ULONGLONG -> UINT64
# Property : HTTP_SERVER_PROPERTY -> int
# PropertyInformation : void* -> LPVOID
# PropertyInformationLength : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

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