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

EnumWindowStationsA

関数
現在のセッションのウィンドウステーションを列挙する。
DLLUSER32.dll文字セットANSI (-A)呼出規約winapiSetLastErrorあり対応OSWindows 2000 以降

シグネチャ

// USER32.dll  (ANSI / -A)
#include <windows.h>

BOOL EnumWindowStationsA(
    WINSTAENUMPROCA lpEnumFunc,
    LPARAM lParam
);

パラメーター

名前方向
lpEnumFuncWINSTAENUMPROCAin
lParamLPARAMin

戻り値の型: BOOL

各言語での呼び出し定義

// USER32.dll  (ANSI / -A)
#include <windows.h>

BOOL EnumWindowStationsA(
    WINSTAENUMPROCA lpEnumFunc,
    LPARAM lParam
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern bool EnumWindowStationsA(
    IntPtr lpEnumFunc,   // WINSTAENUMPROCA
    IntPtr lParam   // LPARAM
);
<DllImport("USER32.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function EnumWindowStationsA(
    lpEnumFunc As IntPtr,   ' WINSTAENUMPROCA
    lParam As IntPtr   ' LPARAM
) As Boolean
End Function
' lpEnumFunc : WINSTAENUMPROCA
' lParam : LPARAM
Declare PtrSafe Function EnumWindowStationsA Lib "user32" ( _
    ByVal lpEnumFunc As LongPtr, _
    ByVal lParam As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

EnumWindowStationsA = ctypes.windll.user32.EnumWindowStationsA
EnumWindowStationsA.restype = wintypes.BOOL
EnumWindowStationsA.argtypes = [
    ctypes.c_void_p,  # lpEnumFunc : WINSTAENUMPROCA
    ctypes.c_ssize_t,  # lParam : LPARAM
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('USER32.dll')
EnumWindowStationsA = Fiddle::Function.new(
  lib['EnumWindowStationsA'],
  [
    Fiddle::TYPE_VOIDP,  # lpEnumFunc : WINSTAENUMPROCA
    Fiddle::TYPE_INTPTR_T,  # lParam : LPARAM
  ],
  Fiddle::TYPE_INT)
#[link(name = "user32")]
extern "system" {
    fn EnumWindowStationsA(
        lpEnumFunc: *const core::ffi::c_void,  // WINSTAENUMPROCA
        lParam: isize  // LPARAM
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern bool EnumWindowStationsA(IntPtr lpEnumFunc, IntPtr lParam);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_EnumWindowStationsA' -Namespace Win32 -PassThru
# $api::EnumWindowStationsA(lpEnumFunc, lParam)
#uselib "USER32.dll"
#func global EnumWindowStationsA "EnumWindowStationsA" sptr, sptr
; EnumWindowStationsA lpEnumFunc, lParam   ; 戻り値は stat
; lpEnumFunc : WINSTAENUMPROCA -> "sptr"
; lParam : LPARAM -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "USER32.dll"
#cfunc global EnumWindowStationsA "EnumWindowStationsA" sptr, sptr
; res = EnumWindowStationsA(lpEnumFunc, lParam)
; lpEnumFunc : WINSTAENUMPROCA -> "sptr"
; lParam : LPARAM -> "sptr"
; BOOL EnumWindowStationsA(WINSTAENUMPROCA lpEnumFunc, LPARAM lParam)
#uselib "USER32.dll"
#cfunc global EnumWindowStationsA "EnumWindowStationsA" intptr, intptr
; res = EnumWindowStationsA(lpEnumFunc, lParam)
; lpEnumFunc : WINSTAENUMPROCA -> "intptr"
; lParam : LPARAM -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	user32 = windows.NewLazySystemDLL("USER32.dll")
	procEnumWindowStationsA = user32.NewProc("EnumWindowStationsA")
)

// lpEnumFunc (WINSTAENUMPROCA), lParam (LPARAM)
r1, _, err := procEnumWindowStationsA.Call(
	uintptr(lpEnumFunc),
	uintptr(lParam),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function EnumWindowStationsA(
  lpEnumFunc: Pointer;   // WINSTAENUMPROCA
  lParam: NativeInt   // LPARAM
): BOOL; stdcall;
  external 'USER32.dll' name 'EnumWindowStationsA';
result := DllCall("USER32\EnumWindowStationsA"
    , "Ptr", lpEnumFunc   ; WINSTAENUMPROCA
    , "Ptr", lParam   ; LPARAM
    , "Int")   ; return: BOOL
●EnumWindowStationsA(lpEnumFunc, lParam) = DLL("USER32.dll", "bool EnumWindowStationsA(void*, int)")
# 呼び出し: EnumWindowStationsA(lpEnumFunc, lParam)
# lpEnumFunc : WINSTAENUMPROCA -> "void*"
# lParam : LPARAM -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。