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

HttpCloseServerSession

関数
HTTPサーバーセッションを閉じる。
DLLHTTPAPI.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

DWORD HttpCloseServerSession(
    ULONGLONG ServerSessionId
);

パラメーター

名前方向説明
ServerSessionIdULONGLONGin閉じるサーバーセッションの ID。

戻り値の型: DWORD

公式ドキュメント

サーバーセッション ID で識別されるサーバーセッションを削除します。

戻り値

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

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

意味
ERROR_INVALID_PARAMETER
サーバーセッションが存在しません。

アプリケーションにサーバーセッションを閉じる権限がありません。サーバーセッションを閉じることができるのは、そのサーバーセッションを作成したアプリケーションのみです。

解説(Remarks)

アプリケーションは、HttpCloseServerSession を呼び出す前に HttpCloseUrlGroup を呼び出して、サーバーセッションに関連付けられたすべての URL グループを閉じる必要があります。

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

各言語での呼び出し定義

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

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

HttpCloseServerSession = ctypes.windll.httpapi.HttpCloseServerSession
HttpCloseServerSession.restype = wintypes.DWORD
HttpCloseServerSession.argtypes = [
    ctypes.c_ulonglong,  # ServerSessionId : ULONGLONG
]
require 'fiddle'
require 'fiddle/import'

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

var (
	httpapi = windows.NewLazySystemDLL("HTTPAPI.dll")
	procHttpCloseServerSession = httpapi.NewProc("HttpCloseServerSession")
)

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

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

typedef HttpCloseServerSessionNative = Uint32 Function(Uint64);
typedef HttpCloseServerSessionDart = int Function(int);
final HttpCloseServerSession = DynamicLibrary.open('HTTPAPI.dll')
    .lookupFunction<HttpCloseServerSessionNative, HttpCloseServerSessionDart>('HttpCloseServerSession');
// ServerSessionId : ULONGLONG -> Uint64
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function HttpCloseServerSession(
  ServerSessionId: UInt64   // ULONGLONG
): DWORD; stdcall;
  external 'HTTPAPI.dll' name 'HttpCloseServerSession';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "HttpCloseServerSession"
  c_HttpCloseServerSession :: Word64 -> IO Word32
-- ServerSessionId : ULONGLONG -> Word64
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let httpcloseserversession =
  foreign "HttpCloseServerSession"
    (uint64_t @-> returning uint32_t)
(* ServerSessionId : ULONGLONG -> uint64_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library httpapi (t "HTTPAPI.dll"))
(cffi:use-foreign-library httpapi)

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

関連項目

公式の関連項目