ホーム › Networking.WinSock › WSAInstallServiceClassW
WSAInstallServiceClassW
関数新しいサービスクラス情報を登録する。
シグネチャ
// WS2_32.dll (Unicode / -W)
#include <windows.h>
INT WSAInstallServiceClassW(
WSASERVICECLASSINFOW* lpServiceClassInfo
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| lpServiceClassInfo | WSASERVICECLASSINFOW* | in |
戻り値の型: INT
各言語での呼び出し定義
// WS2_32.dll (Unicode / -W)
#include <windows.h>
INT WSAInstallServiceClassW(
WSASERVICECLASSINFOW* lpServiceClassInfo
);[DllImport("WS2_32.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern int WSAInstallServiceClassW(
IntPtr lpServiceClassInfo // WSASERVICECLASSINFOW*
);<DllImport("WS2_32.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function WSAInstallServiceClassW(
lpServiceClassInfo As IntPtr ' WSASERVICECLASSINFOW*
) As Integer
End Function' lpServiceClassInfo : WSASERVICECLASSINFOW*
Declare PtrSafe Function WSAInstallServiceClassW Lib "ws2_32" ( _
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
WSAInstallServiceClassW = ctypes.windll.ws2_32.WSAInstallServiceClassW
WSAInstallServiceClassW.restype = ctypes.c_int
WSAInstallServiceClassW.argtypes = [
ctypes.c_void_p, # lpServiceClassInfo : WSASERVICECLASSINFOW*
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WS2_32.dll')
WSAInstallServiceClassW = Fiddle::Function.new(
lib['WSAInstallServiceClassW'],
[
Fiddle::TYPE_VOIDP, # lpServiceClassInfo : WSASERVICECLASSINFOW*
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "ws2_32")]
extern "system" {
fn WSAInstallServiceClassW(
lpServiceClassInfo: *mut WSASERVICECLASSINFOW // WSASERVICECLASSINFOW*
) -> 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 WSAInstallServiceClassW(IntPtr lpServiceClassInfo);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WS2_32_WSAInstallServiceClassW' -Namespace Win32 -PassThru
# $api::WSAInstallServiceClassW(lpServiceClassInfo)#uselib "WS2_32.dll"
#func global WSAInstallServiceClassW "WSAInstallServiceClassW" wptr
; WSAInstallServiceClassW varptr(lpServiceClassInfo) ; 戻り値は stat
; lpServiceClassInfo : WSASERVICECLASSINFOW* -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "WS2_32.dll" #cfunc global WSAInstallServiceClassW "WSAInstallServiceClassW" var ; res = WSAInstallServiceClassW(lpServiceClassInfo) ; lpServiceClassInfo : WSASERVICECLASSINFOW* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "WS2_32.dll" #cfunc global WSAInstallServiceClassW "WSAInstallServiceClassW" sptr ; res = WSAInstallServiceClassW(varptr(lpServiceClassInfo)) ; lpServiceClassInfo : WSASERVICECLASSINFOW* -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT WSAInstallServiceClassW(WSASERVICECLASSINFOW* lpServiceClassInfo) #uselib "WS2_32.dll" #cfunc global WSAInstallServiceClassW "WSAInstallServiceClassW" var ; res = WSAInstallServiceClassW(lpServiceClassInfo) ; lpServiceClassInfo : WSASERVICECLASSINFOW* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT WSAInstallServiceClassW(WSASERVICECLASSINFOW* lpServiceClassInfo) #uselib "WS2_32.dll" #cfunc global WSAInstallServiceClassW "WSAInstallServiceClassW" intptr ; res = WSAInstallServiceClassW(varptr(lpServiceClassInfo)) ; lpServiceClassInfo : WSASERVICECLASSINFOW* -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
ws2_32 = windows.NewLazySystemDLL("WS2_32.dll")
procWSAInstallServiceClassW = ws2_32.NewProc("WSAInstallServiceClassW")
)
// lpServiceClassInfo (WSASERVICECLASSINFOW*)
r1, _, err := procWSAInstallServiceClassW.Call(
uintptr(lpServiceClassInfo),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction WSAInstallServiceClassW(
lpServiceClassInfo: Pointer // WSASERVICECLASSINFOW*
): Integer; stdcall;
external 'WS2_32.dll' name 'WSAInstallServiceClassW';result := DllCall("WS2_32\WSAInstallServiceClassW"
, "Ptr", lpServiceClassInfo ; WSASERVICECLASSINFOW*
, "Int") ; return: INT●WSAInstallServiceClassW(lpServiceClassInfo) = DLL("WS2_32.dll", "int WSAInstallServiceClassW(void*)")
# 呼び出し: WSAInstallServiceClassW(lpServiceClassInfo)
# lpServiceClassInfo : WSASERVICECLASSINFOW* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。