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

NS_SERVICE_INFOW

構造体
サイズx64: 88 バイト / x86: 48 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
dwNameSpaceDWORD4+0+0サービスが属するネームスペースの識別子を示す。
ServiceInfoSERVICE_INFOW80/44+8+4サービスの詳細を保持するSERVICE_INFOW構造体。

各言語での定義

#include <windows.h>

// BLOB  (x64 16 / x86 8 バイト)
typedef struct BLOB {
    DWORD cbSize;
    BYTE* pBlobData;
} BLOB;

// SERVICE_INFOW  (x64 80 / x86 44 バイト)
typedef struct SERVICE_INFOW {
    GUID* lpServiceType;
    LPWSTR lpServiceName;
    LPWSTR lpComment;
    LPWSTR lpLocale;
    RESOURCE_DISPLAY_TYPE dwDisplayHint;
    DWORD dwVersion;
    DWORD dwTime;
    LPWSTR lpMachineName;
    SERVICE_ADDRESSES* lpServiceAddress;
    BLOB ServiceSpecificInfo;
} SERVICE_INFOW;

// NS_SERVICE_INFOW  (x64 88 / x86 48 バイト)
typedef struct NS_SERVICE_INFOW {
    DWORD dwNameSpace;
    SERVICE_INFOW ServiceInfo;
} NS_SERVICE_INFOW;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct BLOB
{
    public uint cbSize;
    public IntPtr pBlobData;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SERVICE_INFOW
{
    public IntPtr lpServiceType;
    public IntPtr lpServiceName;
    public IntPtr lpComment;
    public IntPtr lpLocale;
    public uint dwDisplayHint;
    public uint dwVersion;
    public uint dwTime;
    public IntPtr lpMachineName;
    public IntPtr lpServiceAddress;
    public BLOB ServiceSpecificInfo;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct NS_SERVICE_INFOW
{
    public uint dwNameSpace;
    public SERVICE_INFOW ServiceInfo;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure BLOB
    Public cbSize As UInteger
    Public pBlobData As IntPtr
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SERVICE_INFOW
    Public lpServiceType As IntPtr
    Public lpServiceName As IntPtr
    Public lpComment As IntPtr
    Public lpLocale As IntPtr
    Public dwDisplayHint As UInteger
    Public dwVersion As UInteger
    Public dwTime As UInteger
    Public lpMachineName As IntPtr
    Public lpServiceAddress As IntPtr
    Public ServiceSpecificInfo As BLOB
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure NS_SERVICE_INFOW
    Public dwNameSpace As UInteger
    Public ServiceInfo As SERVICE_INFOW
End Structure
import ctypes
from ctypes import wintypes

class BLOB(ctypes.Structure):
    _fields_ = [
        ("cbSize", wintypes.DWORD),
        ("pBlobData", ctypes.c_void_p),
    ]

class SERVICE_INFOW(ctypes.Structure):
    _fields_ = [
        ("lpServiceType", ctypes.c_void_p),
        ("lpServiceName", ctypes.c_void_p),
        ("lpComment", ctypes.c_void_p),
        ("lpLocale", ctypes.c_void_p),
        ("dwDisplayHint", wintypes.DWORD),
        ("dwVersion", wintypes.DWORD),
        ("dwTime", wintypes.DWORD),
        ("lpMachineName", ctypes.c_void_p),
        ("lpServiceAddress", ctypes.c_void_p),
        ("ServiceSpecificInfo", BLOB),
    ]

class NS_SERVICE_INFOW(ctypes.Structure):
    _fields_ = [
        ("dwNameSpace", wintypes.DWORD),
        ("ServiceInfo", SERVICE_INFOW),
    ]
#[repr(C)]
pub struct BLOB {
    pub cbSize: u32,
    pub pBlobData: *mut core::ffi::c_void,
}

#[repr(C)]
pub struct SERVICE_INFOW {
    pub lpServiceType: *mut core::ffi::c_void,
    pub lpServiceName: *mut core::ffi::c_void,
    pub lpComment: *mut core::ffi::c_void,
    pub lpLocale: *mut core::ffi::c_void,
    pub dwDisplayHint: u32,
    pub dwVersion: u32,
    pub dwTime: u32,
    pub lpMachineName: *mut core::ffi::c_void,
    pub lpServiceAddress: *mut core::ffi::c_void,
    pub ServiceSpecificInfo: BLOB,
}

#[repr(C)]
pub struct NS_SERVICE_INFOW {
    pub dwNameSpace: u32,
    pub ServiceInfo: SERVICE_INFOW,
}
import "golang.org/x/sys/windows"

type BLOB struct {
	cbSize uint32
	pBlobData uintptr
}

type SERVICE_INFOW struct {
	lpServiceType uintptr
	lpServiceName uintptr
	lpComment uintptr
	lpLocale uintptr
	dwDisplayHint uint32
	dwVersion uint32
	dwTime uint32
	lpMachineName uintptr
	lpServiceAddress uintptr
	ServiceSpecificInfo BLOB
}

type NS_SERVICE_INFOW struct {
	dwNameSpace uint32
	ServiceInfo SERVICE_INFOW
}
type
  BLOB = record
    cbSize: DWORD;
    pBlobData: Pointer;
  end;

  SERVICE_INFOW = record
    lpServiceType: Pointer;
    lpServiceName: Pointer;
    lpComment: Pointer;
    lpLocale: Pointer;
    dwDisplayHint: DWORD;
    dwVersion: DWORD;
    dwTime: DWORD;
    lpMachineName: Pointer;
    lpServiceAddress: Pointer;
    ServiceSpecificInfo: BLOB;
  end;

  NS_SERVICE_INFOW = record
    dwNameSpace: DWORD;
    ServiceInfo: SERVICE_INFOW;
  end;
const BLOB = extern struct {
    cbSize: u32,
    pBlobData: ?*anyopaque,
};

const SERVICE_INFOW = extern struct {
    lpServiceType: ?*anyopaque,
    lpServiceName: ?*anyopaque,
    lpComment: ?*anyopaque,
    lpLocale: ?*anyopaque,
    dwDisplayHint: u32,
    dwVersion: u32,
    dwTime: u32,
    lpMachineName: ?*anyopaque,
    lpServiceAddress: ?*anyopaque,
    ServiceSpecificInfo: BLOB,
};

const NS_SERVICE_INFOW = extern struct {
    dwNameSpace: u32,
    ServiceInfo: SERVICE_INFOW,
};
type
  BLOB {.bycopy.} = object
    cbSize: uint32
    pBlobData: pointer

  SERVICE_INFOW {.bycopy.} = object
    lpServiceType: pointer
    lpServiceName: pointer
    lpComment: pointer
    lpLocale: pointer
    dwDisplayHint: uint32
    dwVersion: uint32
    dwTime: uint32
    lpMachineName: pointer
    lpServiceAddress: pointer
    ServiceSpecificInfo: BLOB

  NS_SERVICE_INFOW {.bycopy.} = object
    dwNameSpace: uint32
    ServiceInfo: SERVICE_INFOW
struct BLOB
{
    uint cbSize;
    void* pBlobData;
}

struct SERVICE_INFOW
{
    void* lpServiceType;
    void* lpServiceName;
    void* lpComment;
    void* lpLocale;
    uint dwDisplayHint;
    uint dwVersion;
    uint dwTime;
    void* lpMachineName;
    void* lpServiceAddress;
    BLOB ServiceSpecificInfo;
}

struct NS_SERVICE_INFOW
{
    uint dwNameSpace;
    SERVICE_INFOW ServiceInfo;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; NS_SERVICE_INFOW サイズ: 48 バイト(x86)
dim st, 12    ; 4byte整数×12(構造体サイズ 48 / 4 切り上げ)
; dwNameSpace : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; ServiceInfo : SERVICE_INFOW (+4, 44byte)  varptr(st)+4 を基点に操作(44byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; NS_SERVICE_INFOW サイズ: 88 バイト(x64)
dim st, 22    ; 4byte整数×22(構造体サイズ 88 / 4 切り上げ)
; dwNameSpace : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; ServiceInfo : SERVICE_INFOW (+8, 80byte)  varptr(st)+8 を基点に操作(80byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global BLOB
    #field int cbSize
    #field intptr pBlobData
#endstruct

#defstruct global SERVICE_INFOW
    #field intptr lpServiceType
    #field intptr lpServiceName
    #field intptr lpComment
    #field intptr lpLocale
    #field int dwDisplayHint
    #field int dwVersion
    #field int dwTime
    #field intptr lpMachineName
    #field intptr lpServiceAddress
    #field BLOB ServiceSpecificInfo
#endstruct

#defstruct global NS_SERVICE_INFOW
    #field int dwNameSpace
    #field SERVICE_INFOW ServiceInfo
#endstruct

stdim st, NS_SERVICE_INFOW        ; NSTRUCT 変数を確保
st->dwNameSpace = 100
mes "dwNameSpace=" + st->dwNameSpace