Win32 API 日本語リファレンス
ホームSystem.Threading › CreateSemaphoreW

CreateSemaphoreW

関数
名前付きまたは無名のセマフォを作成する(Unicode版)。
DLLKERNEL32.dll文字セットUnicode (-W)呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

// KERNEL32.dll  (Unicode / -W)
#include <windows.h>

HANDLE CreateSemaphoreW(
    SECURITY_ATTRIBUTES* lpSemaphoreAttributes,   // optional
    INT lInitialCount,
    INT lMaximumCount,
    LPCWSTR lpName   // optional
);

パラメーター

名前方向説明
lpSemaphoreAttributesSECURITY_ATTRIBUTES*inoptional

SECURITY_ATTRIBUTES 構造体へのポインターです。このパラメーターが NULL の場合、ハンドルは子プロセスに継承されません。

構造体の lpSecurityDescriptor メンバーは、新しいセマフォのセキュリティ記述子を指定します。このパラメーターが NULL の場合、セマフォには既定のセキュリティ記述子が割り当てられます。セマフォの既定のセキュリティ記述子内の ACL は、作成者のプライマリトークンまたは偽装トークンから取得されます。

lInitialCountINTinセマフォオブジェクトの初期カウントです。この値は 0 以上、かつ lMaximumCount 以下でなければなりません。セマフォの状態は、カウントが 0 より大きいときにシグナル状態となり、0 のときに非シグナル状態となります。待機関数がセマフォを待機していたスレッドを解放するたびに、カウントは 1 ずつ減少します。カウントは、 ReleaseSemaphore 関数を呼び出すことで指定した量だけ増加します。
lMaximumCountINTinセマフォオブジェクトの最大カウントです。この値は 0 より大きくなければなりません。
lpNameLPCWSTRinoptional

セマフォオブジェクトの名前です。名前は MAX_PATH 文字までに制限されます。名前の比較は大文字と小文字を区別します。

lpName が既存の名前付きセマフォオブジェクトの名前と一致する場合、この関数は SEMAPHORE_ALL_ACCESS アクセス権を要求します。この場合、lInitialCount および lMaximumCount パラメーターは、作成元プロセスによって既に設定されているため無視されます。lpSemaphoreAttributes パラメーターが NULL でない場合、ハンドルが継承可能かどうかを決定しますが、そのセキュリティ記述子メンバーは無視されます。

lpNameNULL の場合、セマフォオブジェクトは名前なしで作成されます。

lpName が既存のイベント、ミューテックス、待機可能タイマー、ジョブ、またはファイルマッピングオブジェクトの名前と一致する場合、関数は失敗し、 GetLastError 関数は ERROR_INVALID_HANDLE を返します。これは、これらのオブジェクトが同じ名前空間を共有しているために発生します。

名前には、グローバル名前空間またはセッション名前空間にオブジェクトを明示的に作成するための "Global" または "Local" プレフィックスを付けることができます。名前の残りの部分には、円記号 (\) を除く任意の文字を含めることができます。詳細については、 Kernel Object Namespaces を参照してください。ファストユーザー切り替えはターミナルサービスのセッションを使用して実装されています。アプリケーションが複数のユーザーをサポートできるように、カーネルオブジェクト名はターミナルサービス向けに示されたガイドラインに従う必要があります。

オブジェクトはプライベート名前空間内に作成できます。詳細については、Object Namespaces を参照してください。

戻り値の型: HANDLE

公式ドキュメント

名前付きまたは名前なしのセマフォオブジェクトを作成、または開きます。(CreateSemaphoreW)

戻り値

関数が成功した場合、戻り値はセマフォオブジェクトへのハンドルです。名前付きセマフォオブジェクトが関数呼び出しの前に既に存在していた場合、関数は既存のオブジェクトへのハンドルを返し、 GetLastErrorERROR_ALREADY_EXISTS を返します。

関数が失敗した場合、戻り値は NULL です。拡張エラー情報を取得するには、GetLastError を呼び出します。

解説(Remarks)

CreateSemaphore が返すハンドルは SEMAPHORE_ALL_ACCESS アクセス権を持ち、呼び出し元にアクセスが許可されている限り、セマフォオブジェクトへのハンドルを必要とする任意の関数で使用できます。サービスから、または別のユーザーを偽装しているスレッドからセマフォを作成する場合、作成時にセマフォにセキュリティ記述子を適用するか、作成元プロセスの既定の DACL を変更してその既定のセキュリティ記述子を変更することができます。詳細については、 Synchronization Object Security and Access Rights を参照してください。

セマフォオブジェクトの状態は、カウントが 0 より大きいときにシグナル状態となり、カウントが 0 のときに非シグナル状態となります。lInitialCount パラメーターは初期カウントを指定します。カウントが 0 未満になることや、lMaximumCount パラメーターで指定された値を超えることはありません。

呼び出し元プロセスの任意のスレッドは、いずれかの 待機関数の呼び出しでセマフォオブジェクトのハンドルを指定できます。単一オブジェクト待機関数は、指定したオブジェクトの状態がシグナル状態になったときに復帰します。複数オブジェクト待機関数は、指定したオブジェクトのいずれか 1 つがシグナル状態になったとき、またはすべてがシグナル状態になったときのいずれかで復帰するように指示できます。待機関数が復帰すると、待機中のスレッドは解放され、実行を続行します。スレッドがセマフォオブジェクトの待機を完了するたびに、セマフォオブジェクトのカウントは 1 ずつ減少します。スレッドの処理が終了すると、ReleaseSemaphore 関数を呼び出し、セマフォオブジェクトのカウントを増加させます。

複数のプロセスが同じセマフォオブジェクトのハンドルを持つことができ、プロセス間同期にオブジェクトを使用できます。次のオブジェクト共有メカニズムが利用できます。

ハンドルを閉じるには、CloseHandle 関数を使用します。プロセスが終了すると、システムは自動的にハンドルを閉じます。セマフォオブジェクトは、その最後のハンドルが閉じられたときに破棄されます。

CreateSemaphore を使用する例については、 Using Semaphore Objects を参照してください。

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

各言語での呼び出し定義

// KERNEL32.dll  (Unicode / -W)
#include <windows.h>

HANDLE CreateSemaphoreW(
    SECURITY_ATTRIBUTES* lpSemaphoreAttributes,   // optional
    INT lInitialCount,
    INT lMaximumCount,
    LPCWSTR lpName   // optional
);
[DllImport("KERNEL32.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern IntPtr CreateSemaphoreW(
    IntPtr lpSemaphoreAttributes,   // SECURITY_ATTRIBUTES* optional
    int lInitialCount,   // INT
    int lMaximumCount,   // INT
    [MarshalAs(UnmanagedType.LPWStr)] string lpName   // LPCWSTR optional
);
<DllImport("KERNEL32.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function CreateSemaphoreW(
    lpSemaphoreAttributes As IntPtr,   ' SECURITY_ATTRIBUTES* optional
    lInitialCount As Integer,   ' INT
    lMaximumCount As Integer,   ' INT
    <MarshalAs(UnmanagedType.LPWStr)> lpName As String   ' LPCWSTR optional
) As IntPtr
End Function
' lpSemaphoreAttributes : SECURITY_ATTRIBUTES* optional
' lInitialCount : INT
' lMaximumCount : INT
' lpName : LPCWSTR optional
Declare PtrSafe Function CreateSemaphoreW Lib "kernel32" ( _
    ByVal lpSemaphoreAttributes As LongPtr, _
    ByVal lInitialCount As Long, _
    ByVal lMaximumCount As Long, _
    ByVal lpName As LongPtr) As LongPtr
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CreateSemaphoreW = ctypes.windll.kernel32.CreateSemaphoreW
CreateSemaphoreW.restype = ctypes.c_void_p
CreateSemaphoreW.argtypes = [
    ctypes.c_void_p,  # lpSemaphoreAttributes : SECURITY_ATTRIBUTES* optional
    ctypes.c_int,  # lInitialCount : INT
    ctypes.c_int,  # lMaximumCount : INT
    wintypes.LPCWSTR,  # lpName : LPCWSTR optional
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('KERNEL32.dll')
CreateSemaphoreW = Fiddle::Function.new(
  lib['CreateSemaphoreW'],
  [
    Fiddle::TYPE_VOIDP,  # lpSemaphoreAttributes : SECURITY_ATTRIBUTES* optional
    Fiddle::TYPE_INT,  # lInitialCount : INT
    Fiddle::TYPE_INT,  # lMaximumCount : INT
    Fiddle::TYPE_VOIDP,  # lpName : LPCWSTR optional
  ],
  Fiddle::TYPE_VOIDP)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "kernel32")]
extern "system" {
    fn CreateSemaphoreW(
        lpSemaphoreAttributes: *mut SECURITY_ATTRIBUTES,  // SECURITY_ATTRIBUTES* optional
        lInitialCount: i32,  // INT
        lMaximumCount: i32,  // INT
        lpName: *const u16  // LPCWSTR optional
    ) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("KERNEL32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern IntPtr CreateSemaphoreW(IntPtr lpSemaphoreAttributes, int lInitialCount, int lMaximumCount, [MarshalAs(UnmanagedType.LPWStr)] string lpName);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_CreateSemaphoreW' -Namespace Win32 -PassThru
# $api::CreateSemaphoreW(lpSemaphoreAttributes, lInitialCount, lMaximumCount, lpName)
#uselib "KERNEL32.dll"
#func global CreateSemaphoreW "CreateSemaphoreW" wptr, wptr, wptr, wptr
; CreateSemaphoreW varptr(lpSemaphoreAttributes), lInitialCount, lMaximumCount, lpName   ; 戻り値は stat
; lpSemaphoreAttributes : SECURITY_ATTRIBUTES* optional -> "wptr"
; lInitialCount : INT -> "wptr"
; lMaximumCount : INT -> "wptr"
; lpName : LPCWSTR optional -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "KERNEL32.dll"
#cfunc global CreateSemaphoreW "CreateSemaphoreW" var, int, int, wstr
; res = CreateSemaphoreW(lpSemaphoreAttributes, lInitialCount, lMaximumCount, lpName)
; lpSemaphoreAttributes : SECURITY_ATTRIBUTES* optional -> "var"
; lInitialCount : INT -> "int"
; lMaximumCount : INT -> "int"
; lpName : LPCWSTR optional -> "wstr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HANDLE CreateSemaphoreW(SECURITY_ATTRIBUTES* lpSemaphoreAttributes, INT lInitialCount, INT lMaximumCount, LPCWSTR lpName)
#uselib "KERNEL32.dll"
#cfunc global CreateSemaphoreW "CreateSemaphoreW" var, int, int, wstr
; res = CreateSemaphoreW(lpSemaphoreAttributes, lInitialCount, lMaximumCount, lpName)
; lpSemaphoreAttributes : SECURITY_ATTRIBUTES* optional -> "var"
; lInitialCount : INT -> "int"
; lMaximumCount : INT -> "int"
; lpName : LPCWSTR optional -> "wstr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procCreateSemaphoreW = kernel32.NewProc("CreateSemaphoreW")
)

// lpSemaphoreAttributes (SECURITY_ATTRIBUTES* optional), lInitialCount (INT), lMaximumCount (INT), lpName (LPCWSTR optional)
r1, _, err := procCreateSemaphoreW.Call(
	uintptr(lpSemaphoreAttributes),
	uintptr(lInitialCount),
	uintptr(lMaximumCount),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpName))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HANDLE
function CreateSemaphoreW(
  lpSemaphoreAttributes: Pointer;   // SECURITY_ATTRIBUTES* optional
  lInitialCount: Integer;   // INT
  lMaximumCount: Integer;   // INT
  lpName: PWideChar   // LPCWSTR optional
): THandle; stdcall;
  external 'KERNEL32.dll' name 'CreateSemaphoreW';
result := DllCall("KERNEL32\CreateSemaphoreW"
    , "Ptr", lpSemaphoreAttributes   ; SECURITY_ATTRIBUTES* optional
    , "Int", lInitialCount   ; INT
    , "Int", lMaximumCount   ; INT
    , "WStr", lpName   ; LPCWSTR optional
    , "Ptr")   ; return: HANDLE
●CreateSemaphoreW(lpSemaphoreAttributes, lInitialCount, lMaximumCount, lpName) = DLL("KERNEL32.dll", "void* CreateSemaphoreW(void*, int, int, char*)")
# 呼び出し: CreateSemaphoreW(lpSemaphoreAttributes, lInitialCount, lMaximumCount, lpName)
# lpSemaphoreAttributes : SECURITY_ATTRIBUTES* optional -> "void*"
# lInitialCount : INT -> "int"
# lMaximumCount : INT -> "int"
# lpName : LPCWSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。
const std = @import("std");

extern "kernel32" fn CreateSemaphoreW(
    lpSemaphoreAttributes: [*c]SECURITY_ATTRIBUTES, // SECURITY_ATTRIBUTES* optional
    lInitialCount: i32, // INT
    lMaximumCount: i32, // INT
    lpName: [*c]const u16 // LPCWSTR optional
) callconv(std.os.windows.WINAPI) ?*anyopaque;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。
proc CreateSemaphoreW(
    lpSemaphoreAttributes: ptr SECURITY_ATTRIBUTES,  # SECURITY_ATTRIBUTES* optional
    lInitialCount: int32,  # INT
    lMaximumCount: int32,  # INT
    lpName: WideCString  # LPCWSTR optional
): pointer {.importc: "CreateSemaphoreW", stdcall, dynlib: "KERNEL32.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。
pragma(lib, "kernel32");
extern(Windows)
void* CreateSemaphoreW(
    SECURITY_ATTRIBUTES* lpSemaphoreAttributes,   // SECURITY_ATTRIBUTES* optional
    int lInitialCount,   // INT
    int lMaximumCount,   // INT
    const(wchar)* lpName   // LPCWSTR optional
);
ccall((:CreateSemaphoreW, "KERNEL32.dll"), stdcall, Ptr{Cvoid},
      (Ptr{SECURITY_ATTRIBUTES}, Int32, Int32, Cwstring),
      lpSemaphoreAttributes, lInitialCount, lMaximumCount, lpName)
# lpSemaphoreAttributes : SECURITY_ATTRIBUTES* optional -> Ptr{SECURITY_ATTRIBUTES}
# lInitialCount : INT -> Int32
# lMaximumCount : INT -> Int32
# lpName : LPCWSTR optional -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。
local ffi = require("ffi")
ffi.cdef[[
void* CreateSemaphoreW(
    void* lpSemaphoreAttributes,
    int32_t lInitialCount,
    int32_t lMaximumCount,
    const uint16_t* lpName);
]]
local kernel32 = ffi.load("kernel32")
-- kernel32.CreateSemaphoreW(lpSemaphoreAttributes, lInitialCount, lMaximumCount, lpName)
-- lpSemaphoreAttributes : SECURITY_ATTRIBUTES* optional
-- lInitialCount : INT
-- lMaximumCount : INT
-- lpName : LPCWSTR optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。
const koffi = require('koffi');
const lib = koffi.load('KERNEL32.dll');
const CreateSemaphoreW = lib.func('__stdcall', 'CreateSemaphoreW', 'void *', ['void *', 'int32_t', 'int32_t', 'str16']);
// CreateSemaphoreW(lpSemaphoreAttributes, lInitialCount, lMaximumCount, lpName)
// lpSemaphoreAttributes : SECURITY_ATTRIBUTES* optional -> 'void *'
// lInitialCount : INT -> 'int32_t'
// lMaximumCount : INT -> 'int32_t'
// lpName : LPCWSTR optional -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("KERNEL32.dll", {
  CreateSemaphoreW: { parameters: ["pointer", "i32", "i32", "buffer"], result: "pointer" },
});
// lib.symbols.CreateSemaphoreW(lpSemaphoreAttributes, lInitialCount, lMaximumCount, lpName)
// lpSemaphoreAttributes : SECURITY_ATTRIBUTES* optional -> "pointer"
// lInitialCount : INT -> "i32"
// lMaximumCount : INT -> "i32"
// lpName : LPCWSTR optional -> "buffer"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
void* CreateSemaphoreW(
    void* lpSemaphoreAttributes,
    int32_t lInitialCount,
    int32_t lMaximumCount,
    const uint16_t* lpName);
C, "KERNEL32.dll");
// $ffi->CreateSemaphoreW(lpSemaphoreAttributes, lInitialCount, lMaximumCount, lpName);
// lpSemaphoreAttributes : SECURITY_ATTRIBUTES* optional
// lInitialCount : INT
// lMaximumCount : INT
// lpName : LPCWSTR 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 Kernel32 extends StdCallLibrary {
    Kernel32 INSTANCE = Native.load("kernel32", Kernel32.class, W32APIOptions.UNICODE_OPTIONS);
    Pointer CreateSemaphoreW(
        Pointer lpSemaphoreAttributes,   // SECURITY_ATTRIBUTES* optional
        int lInitialCount,   // INT
        int lMaximumCount,   // INT
        WString lpName   // LPCWSTR optional
    );
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。
@[Link("kernel32")]
lib LibKERNEL32
  fun CreateSemaphoreW = CreateSemaphoreW(
    lpSemaphoreAttributes : SECURITY_ATTRIBUTES*,   # SECURITY_ATTRIBUTES* optional
    lInitialCount : Int32,   # INT
    lMaximumCount : Int32,   # INT
    lpName : UInt16*   # LPCWSTR optional
  ) : Void*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef CreateSemaphoreWNative = Pointer<Void> Function(Pointer<Void>, Int32, Int32, Pointer<Utf16>);
typedef CreateSemaphoreWDart = Pointer<Void> Function(Pointer<Void>, int, int, Pointer<Utf16>);
final CreateSemaphoreW = DynamicLibrary.open('KERNEL32.dll')
    .lookupFunction<CreateSemaphoreWNative, CreateSemaphoreWDart>('CreateSemaphoreW');
// lpSemaphoreAttributes : SECURITY_ATTRIBUTES* optional -> Pointer<Void>
// lInitialCount : INT -> Int32
// lMaximumCount : INT -> Int32
// lpName : LPCWSTR optional -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function CreateSemaphoreW(
  lpSemaphoreAttributes: Pointer;   // SECURITY_ATTRIBUTES* optional
  lInitialCount: Integer;   // INT
  lMaximumCount: Integer;   // INT
  lpName: PWideChar   // LPCWSTR optional
): THandle; stdcall;
  external 'KERNEL32.dll' name 'CreateSemaphoreW';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "CreateSemaphoreW"
  c_CreateSemaphoreW :: Ptr () -> Int32 -> Int32 -> CWString -> IO (Ptr ())
-- lpSemaphoreAttributes : SECURITY_ATTRIBUTES* optional -> Ptr ()
-- lInitialCount : INT -> Int32
-- lMaximumCount : INT -> Int32
-- lpName : LPCWSTR optional -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let createsemaphorew =
  foreign "CreateSemaphoreW"
    ((ptr void) @-> int32_t @-> int32_t @-> (ptr uint16_t) @-> returning (ptr void))
(* lpSemaphoreAttributes : SECURITY_ATTRIBUTES* optional -> (ptr void) *)
(* lInitialCount : INT -> int32_t *)
(* lMaximumCount : INT -> int32_t *)
(* lpName : LPCWSTR optional -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library kernel32 (t "KERNEL32.dll"))
(cffi:use-foreign-library kernel32)

(cffi:defcfun ("CreateSemaphoreW" create-semaphore-w :convention :stdcall) :pointer
  (lp-semaphore-attributes :pointer)   ; SECURITY_ATTRIBUTES* optional
  (l-initial-count :int32)   ; INT
  (l-maximum-count :int32)   ; INT
  (lp-name (:string :encoding :utf-16le)))   ; LPCWSTR optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $CreateSemaphoreW = Win32::API::More->new('KERNEL32',
    'HANDLE CreateSemaphoreW(LPVOID lpSemaphoreAttributes, int lInitialCount, int lMaximumCount, LPCWSTR lpName)');
# my $ret = $CreateSemaphoreW->Call($lpSemaphoreAttributes, $lInitialCount, $lMaximumCount, $lpName);
# lpSemaphoreAttributes : SECURITY_ATTRIBUTES* optional -> LPVOID
# lInitialCount : INT -> int
# lMaximumCount : INT -> int
# lpName : LPCWSTR optional -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。

関連項目

文字セット違い
類似 API
公式の関連項目
使用する型