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

WSAGetServiceClassInfoW

関数
サービスクラスのスキーマ情報を取得する。
DLLWS2_32.dll文字セットUnicode (-W)呼出規約winapiSetLastErrorあり対応OSWindows 2000 以降

シグネチャ

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

INT WSAGetServiceClassInfoW(
    GUID* lpProviderId,
    GUID* lpServiceClassId,
    DWORD* lpdwBufSize,
    WSASERVICECLASSINFOW* lpServiceClassInfo
);

パラメーター

名前方向
lpProviderIdGUID*in
lpServiceClassIdGUID*in
lpdwBufSizeDWORD*inout
lpServiceClassInfoWSASERVICECLASSINFOW*out

戻り値の型: INT

各言語での呼び出し定義

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

INT WSAGetServiceClassInfoW(
    GUID* lpProviderId,
    GUID* lpServiceClassId,
    DWORD* lpdwBufSize,
    WSASERVICECLASSINFOW* lpServiceClassInfo
);
[DllImport("WS2_32.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern int WSAGetServiceClassInfoW(
    ref Guid lpProviderId,   // GUID*
    ref Guid lpServiceClassId,   // GUID*
    ref uint lpdwBufSize,   // DWORD* in/out
    IntPtr lpServiceClassInfo   // WSASERVICECLASSINFOW* out
);
<DllImport("WS2_32.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function WSAGetServiceClassInfoW(
    ByRef lpProviderId As Guid,   ' GUID*
    ByRef lpServiceClassId As Guid,   ' GUID*
    ByRef lpdwBufSize As UInteger,   ' DWORD* in/out
    lpServiceClassInfo As IntPtr   ' WSASERVICECLASSINFOW* out
) As Integer
End Function
' lpProviderId : GUID*
' lpServiceClassId : GUID*
' lpdwBufSize : DWORD* in/out
' lpServiceClassInfo : WSASERVICECLASSINFOW* out
Declare PtrSafe Function WSAGetServiceClassInfoW Lib "ws2_32" ( _
    ByVal lpProviderId As LongPtr, _
    ByVal lpServiceClassId As LongPtr, _
    ByRef lpdwBufSize As Long, _
    ByVal lpServiceClassInfo As LongPtr) As Long
' 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

WSAGetServiceClassInfoW = ctypes.windll.ws2_32.WSAGetServiceClassInfoW
WSAGetServiceClassInfoW.restype = ctypes.c_int
WSAGetServiceClassInfoW.argtypes = [
    ctypes.c_void_p,  # lpProviderId : GUID*
    ctypes.c_void_p,  # lpServiceClassId : GUID*
    ctypes.POINTER(wintypes.DWORD),  # lpdwBufSize : DWORD* in/out
    ctypes.c_void_p,  # lpServiceClassInfo : WSASERVICECLASSINFOW* out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WS2_32.dll')
WSAGetServiceClassInfoW = Fiddle::Function.new(
  lib['WSAGetServiceClassInfoW'],
  [
    Fiddle::TYPE_VOIDP,  # lpProviderId : GUID*
    Fiddle::TYPE_VOIDP,  # lpServiceClassId : GUID*
    Fiddle::TYPE_VOIDP,  # lpdwBufSize : DWORD* in/out
    Fiddle::TYPE_VOIDP,  # lpServiceClassInfo : WSASERVICECLASSINFOW* out
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "ws2_32")]
extern "system" {
    fn WSAGetServiceClassInfoW(
        lpProviderId: *mut GUID,  // GUID*
        lpServiceClassId: *mut GUID,  // GUID*
        lpdwBufSize: *mut u32,  // DWORD* in/out
        lpServiceClassInfo: *mut WSASERVICECLASSINFOW  // WSASERVICECLASSINFOW* out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("WS2_32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern int WSAGetServiceClassInfoW(ref Guid lpProviderId, ref Guid lpServiceClassId, ref uint lpdwBufSize, IntPtr lpServiceClassInfo);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WS2_32_WSAGetServiceClassInfoW' -Namespace Win32 -PassThru
# $api::WSAGetServiceClassInfoW(lpProviderId, lpServiceClassId, lpdwBufSize, lpServiceClassInfo)
#uselib "WS2_32.dll"
#func global WSAGetServiceClassInfoW "WSAGetServiceClassInfoW" wptr, wptr, wptr, wptr
; WSAGetServiceClassInfoW varptr(lpProviderId), varptr(lpServiceClassId), varptr(lpdwBufSize), varptr(lpServiceClassInfo)   ; 戻り値は stat
; lpProviderId : GUID* -> "wptr"
; lpServiceClassId : GUID* -> "wptr"
; lpdwBufSize : DWORD* in/out -> "wptr"
; lpServiceClassInfo : WSASERVICECLASSINFOW* out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "WS2_32.dll"
#cfunc global WSAGetServiceClassInfoW "WSAGetServiceClassInfoW" var, var, var, var
; res = WSAGetServiceClassInfoW(lpProviderId, lpServiceClassId, lpdwBufSize, lpServiceClassInfo)
; lpProviderId : GUID* -> "var"
; lpServiceClassId : GUID* -> "var"
; lpdwBufSize : DWORD* in/out -> "var"
; lpServiceClassInfo : WSASERVICECLASSINFOW* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; INT WSAGetServiceClassInfoW(GUID* lpProviderId, GUID* lpServiceClassId, DWORD* lpdwBufSize, WSASERVICECLASSINFOW* lpServiceClassInfo)
#uselib "WS2_32.dll"
#cfunc global WSAGetServiceClassInfoW "WSAGetServiceClassInfoW" var, var, var, var
; res = WSAGetServiceClassInfoW(lpProviderId, lpServiceClassId, lpdwBufSize, lpServiceClassInfo)
; lpProviderId : GUID* -> "var"
; lpServiceClassId : GUID* -> "var"
; lpdwBufSize : DWORD* in/out -> "var"
; lpServiceClassInfo : WSASERVICECLASSINFOW* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	ws2_32 = windows.NewLazySystemDLL("WS2_32.dll")
	procWSAGetServiceClassInfoW = ws2_32.NewProc("WSAGetServiceClassInfoW")
)

// lpProviderId (GUID*), lpServiceClassId (GUID*), lpdwBufSize (DWORD* in/out), lpServiceClassInfo (WSASERVICECLASSINFOW* out)
r1, _, err := procWSAGetServiceClassInfoW.Call(
	uintptr(lpProviderId),
	uintptr(lpServiceClassId),
	uintptr(lpdwBufSize),
	uintptr(lpServiceClassInfo),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function WSAGetServiceClassInfoW(
  lpProviderId: PGUID;   // GUID*
  lpServiceClassId: PGUID;   // GUID*
  lpdwBufSize: Pointer;   // DWORD* in/out
  lpServiceClassInfo: Pointer   // WSASERVICECLASSINFOW* out
): Integer; stdcall;
  external 'WS2_32.dll' name 'WSAGetServiceClassInfoW';
result := DllCall("WS2_32\WSAGetServiceClassInfoW"
    , "Ptr", lpProviderId   ; GUID*
    , "Ptr", lpServiceClassId   ; GUID*
    , "Ptr", lpdwBufSize   ; DWORD* in/out
    , "Ptr", lpServiceClassInfo   ; WSASERVICECLASSINFOW* out
    , "Int")   ; return: INT
●WSAGetServiceClassInfoW(lpProviderId, lpServiceClassId, lpdwBufSize, lpServiceClassInfo) = DLL("WS2_32.dll", "int WSAGetServiceClassInfoW(void*, void*, void*, void*)")
# 呼び出し: WSAGetServiceClassInfoW(lpProviderId, lpServiceClassId, lpdwBufSize, lpServiceClassInfo)
# lpProviderId : GUID* -> "void*"
# lpServiceClassId : GUID* -> "void*"
# lpdwBufSize : DWORD* in/out -> "void*"
# lpServiceClassInfo : WSASERVICECLASSINFOW* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。