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

HttpWaitForDemandStart

関数
オンデマンド起動の要求を待機する。
DLLHTTPAPI.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

DWORD HttpWaitForDemandStart(
    HANDLE RequestQueueHandle,
    OVERLAPPED* Overlapped   // optional
);

パラメーター

名前方向説明
RequestQueueHandleHANDLEinデマンド開始が登録されている要求キューへのハンドル。要求キューは HttpCreateRequestQueue 関数の呼び出しによって作成され、そのハンドルが返されます。
OverlappedOVERLAPPED*inoutoptional

非同期呼び出しの場合は、pOverlappedOVERLAPPED 構造体を指すように設定します。同期呼び出しの場合は NULL を設定します。

同期呼び出しは指定したキューに要求が到着するまでブロックされますが、非同期呼び出しはただちに ERROR_IO_PENDING を返し、呼び出し側アプリケーションは GetOverlappedResult または I/O 完了ポートを使用して操作の完了を判断します。同期のために OVERLAPPED 構造体を使用する方法の詳細については、 Synchronization and Overlapped Input and Output を参照してください。

戻り値の型: DWORD

公式ドキュメント

新しい要求キュー プロセスで処理できる新しい要求の到着を待機します。

戻り値

関数が成功すると、NO_ERROR が返されます。

関数が失敗すると、次のいずれかのエラー コードが返されます。

説明
ERROR_INVALID_PARAMETER
ReqQueueHandle パラメーターに有効な要求キューが含まれていません。
ERROR_INVALID_ID_AUTHORITY
呼び出し元のプロセスがこの要求キューのコントローラー プロセスではありません。
ERROR_INVALID_HANDLE
呼び出し元のプロセスは、要求キューのシャットダウンを既に開始しているか、要求キュー ハンドルを閉じています。
ERROR_ALREADY_EXISTS
この要求キューに対するデマンド開始の登録が既に存在します。

解説(Remarks)

デマンド開始通知を登録するために HttpWaitForDemandStart を呼び出せるのは、コントローラー プロセスのみです。コントローラー プロセスとは、要求キューを作成し、HTTP_CREATE_REQUEST_QUEUE_FLAG_CONTROLLER フラグを渡すことでコントローラー プロセスであることを示したプロセスです。コントローラー プロセス以外のプロセスが HttpWaitForDemandStart を呼び出した場合、HTTP Server API は ERROR_INVALID_ID_AUTHORITY を返します。

HttpWaitForDemandStart は、指定した要求キューに新しい要求が到着したときに完了します。このとき、コントローラー プロセスはこの API を使用して、保留中の要求を処理する新しいワーカー プロセスを起動できます。ワーカー プロセスの起動を遅延させることで、アプリケーションは必要になるまでリソースの消費を回避できます。

HTTP Server API では、1 つの要求キューに対して登録できる未処理の通知は、常に 1 つだけです。HTTP Server API は、同じ要求キューに対して HttpWaitForDemandStart を連続して呼び出せる回数に制限を設けていません。同じ要求キューを処理する未処理のプロセス数にも制限はありません。

HTTP Server API は、非同期の HttpWaitForDemandStart 呼び出しのキャンセルをサポートしています。アプリケーションは、pOverlapped パラメーターで指定した OVERLAPPED 構造体を使用して CancelIoEx を呼び出すことで、未処理の HttpWaitForDemandStart 呼び出しをキャンセルできます。

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

各言語での呼び出し定義

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

DWORD HttpWaitForDemandStart(
    HANDLE RequestQueueHandle,
    OVERLAPPED* Overlapped   // optional
);
[DllImport("HTTPAPI.dll", ExactSpelling = true)]
static extern uint HttpWaitForDemandStart(
    IntPtr RequestQueueHandle,   // HANDLE
    IntPtr Overlapped   // OVERLAPPED* optional, in/out
);
<DllImport("HTTPAPI.dll", ExactSpelling:=True)>
Public Shared Function HttpWaitForDemandStart(
    RequestQueueHandle As IntPtr,   ' HANDLE
    Overlapped As IntPtr   ' OVERLAPPED* optional, in/out
) As UInteger
End Function
' RequestQueueHandle : HANDLE
' Overlapped : OVERLAPPED* optional, in/out
Declare PtrSafe Function HttpWaitForDemandStart Lib "httpapi" ( _
    ByVal RequestQueueHandle As LongPtr, _
    ByVal Overlapped As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

HttpWaitForDemandStart = ctypes.windll.httpapi.HttpWaitForDemandStart
HttpWaitForDemandStart.restype = wintypes.DWORD
HttpWaitForDemandStart.argtypes = [
    wintypes.HANDLE,  # RequestQueueHandle : HANDLE
    ctypes.c_void_p,  # Overlapped : OVERLAPPED* optional, in/out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	httpapi = windows.NewLazySystemDLL("HTTPAPI.dll")
	procHttpWaitForDemandStart = httpapi.NewProc("HttpWaitForDemandStart")
)

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

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

typedef HttpWaitForDemandStartNative = Uint32 Function(Pointer<Void>, Pointer<Void>);
typedef HttpWaitForDemandStartDart = int Function(Pointer<Void>, Pointer<Void>);
final HttpWaitForDemandStart = DynamicLibrary.open('HTTPAPI.dll')
    .lookupFunction<HttpWaitForDemandStartNative, HttpWaitForDemandStartDart>('HttpWaitForDemandStart');
// RequestQueueHandle : HANDLE -> Pointer<Void>
// Overlapped : OVERLAPPED* optional, in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function HttpWaitForDemandStart(
  RequestQueueHandle: THandle;   // HANDLE
  Overlapped: Pointer   // OVERLAPPED* optional, in/out
): DWORD; stdcall;
  external 'HTTPAPI.dll' name 'HttpWaitForDemandStart';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "HttpWaitForDemandStart"
  c_HttpWaitForDemandStart :: Ptr () -> Ptr () -> IO Word32
-- RequestQueueHandle : HANDLE -> Ptr ()
-- Overlapped : OVERLAPPED* optional, in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let httpwaitfordemandstart =
  foreign "HttpWaitForDemandStart"
    ((ptr void) @-> (ptr void) @-> returning uint32_t)
(* RequestQueueHandle : HANDLE -> (ptr void) *)
(* Overlapped : OVERLAPPED* optional, in/out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library httpapi (t "HTTPAPI.dll"))
(cffi:use-foreign-library httpapi)

(cffi:defcfun ("HttpWaitForDemandStart" http-wait-for-demand-start :convention :stdcall) :uint32
  (request-queue-handle :pointer)   ; HANDLE
  (overlapped :pointer))   ; OVERLAPPED* optional, in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $HttpWaitForDemandStart = Win32::API::More->new('HTTPAPI',
    'DWORD HttpWaitForDemandStart(HANDLE RequestQueueHandle, LPVOID Overlapped)');
# my $ret = $HttpWaitForDemandStart->Call($RequestQueueHandle, $Overlapped);
# RequestQueueHandle : HANDLE -> HANDLE
# Overlapped : OVERLAPPED* optional, in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

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