Win32 API 日本語リファレンス
ホームDevices.Display › EngAcquireSemaphore

EngAcquireSemaphore

関数
セマフォを獲得して排他制御を行う。
DLLGDI32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

void EngAcquireSemaphore(
    HSEMAPHORE hsem
);

パラメーター

名前方向
hsemHSEMAPHOREin

戻り値の型: void

各言語での呼び出し定義

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

void EngAcquireSemaphore(
    HSEMAPHORE hsem
);
[DllImport("GDI32.dll", ExactSpelling = true)]
static extern void EngAcquireSemaphore(
    IntPtr hsem   // HSEMAPHORE
);
<DllImport("GDI32.dll", ExactSpelling:=True)>
Public Shared Sub EngAcquireSemaphore(
    hsem As IntPtr   ' HSEMAPHORE
)
End Sub
' hsem : HSEMAPHORE
Declare PtrSafe Sub EngAcquireSemaphore Lib "gdi32" ( _
    ByVal hsem As LongPtr)
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

EngAcquireSemaphore = ctypes.windll.gdi32.EngAcquireSemaphore
EngAcquireSemaphore.restype = None
EngAcquireSemaphore.argtypes = [
    wintypes.HANDLE,  # hsem : HSEMAPHORE
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('GDI32.dll')
EngAcquireSemaphore = Fiddle::Function.new(
  lib['EngAcquireSemaphore'],
  [
    Fiddle::TYPE_VOIDP,  # hsem : HSEMAPHORE
  ],
  Fiddle::TYPE_VOID)
#[link(name = "gdi32")]
extern "system" {
    fn EngAcquireSemaphore(
        hsem: *mut core::ffi::c_void  // HSEMAPHORE
    );
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("GDI32.dll")]
public static extern void EngAcquireSemaphore(IntPtr hsem);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_EngAcquireSemaphore' -Namespace Win32 -PassThru
# $api::EngAcquireSemaphore(hsem)
#uselib "GDI32.dll"
#func global EngAcquireSemaphore "EngAcquireSemaphore" sptr
; EngAcquireSemaphore hsem
; hsem : HSEMAPHORE -> "sptr"
#uselib "GDI32.dll"
#func global EngAcquireSemaphore "EngAcquireSemaphore" sptr
; EngAcquireSemaphore hsem
; hsem : HSEMAPHORE -> "sptr"
; void EngAcquireSemaphore(HSEMAPHORE hsem)
#uselib "GDI32.dll"
#func global EngAcquireSemaphore "EngAcquireSemaphore" intptr
; EngAcquireSemaphore hsem
; hsem : HSEMAPHORE -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	gdi32 = windows.NewLazySystemDLL("GDI32.dll")
	procEngAcquireSemaphore = gdi32.NewProc("EngAcquireSemaphore")
)

// hsem (HSEMAPHORE)
r1, _, err := procEngAcquireSemaphore.Call(
	uintptr(hsem),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // void
procedure EngAcquireSemaphore(
  hsem: THandle   // HSEMAPHORE
); stdcall;
  external 'GDI32.dll' name 'EngAcquireSemaphore';
result := DllCall("GDI32\EngAcquireSemaphore"
    , "Ptr", hsem   ; HSEMAPHORE
    , "Int")   ; return: void
●EngAcquireSemaphore(hsem) = DLL("GDI32.dll", "int EngAcquireSemaphore(void*)")
# 呼び出し: EngAcquireSemaphore(hsem)
# hsem : HSEMAPHORE -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。