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

NS_SERVICE_INFOA

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

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

フィールド

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

各言語での定義

#include <windows.h>

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

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

// NS_SERVICE_INFOA  (x64 88 / x86 48 バイト)
typedef struct NS_SERVICE_INFOA {
    DWORD dwNameSpace;
    SERVICE_INFOA ServiceInfo;
} NS_SERVICE_INFOA;
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_INFOA
{
    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_INFOA
{
    public uint dwNameSpace;
    public SERVICE_INFOA 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_INFOA
    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_INFOA
    Public dwNameSpace As UInteger
    Public ServiceInfo As SERVICE_INFOA
End Structure
import ctypes
from ctypes import wintypes

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

class SERVICE_INFOA(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_INFOA(ctypes.Structure):
    _fields_ = [
        ("dwNameSpace", wintypes.DWORD),
        ("ServiceInfo", SERVICE_INFOA),
    ]
#[repr(C)]
pub struct BLOB {
    pub cbSize: u32,
    pub pBlobData: *mut core::ffi::c_void,
}

#[repr(C)]
pub struct SERVICE_INFOA {
    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_INFOA {
    pub dwNameSpace: u32,
    pub ServiceInfo: SERVICE_INFOA,
}
import "golang.org/x/sys/windows"

type BLOB struct {
	cbSize uint32
	pBlobData uintptr
}

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

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

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

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

const SERVICE_INFOA = 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_INFOA = extern struct {
    dwNameSpace: u32,
    ServiceInfo: SERVICE_INFOA,
};
type
  BLOB {.bycopy.} = object
    cbSize: uint32
    pBlobData: pointer

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

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

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

struct NS_SERVICE_INFOA
{
    uint dwNameSpace;
    SERVICE_INFOA 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_INFOA サイズ: 48 バイト(x86)
dim st, 12    ; 4byte整数×12(構造体サイズ 48 / 4 切り上げ)
; dwNameSpace : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; ServiceInfo : SERVICE_INFOA (+4, 44byte)  varptr(st)+4 を基点に操作(44byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; NS_SERVICE_INFOA サイズ: 88 バイト(x64)
dim st, 22    ; 4byte整数×22(構造体サイズ 88 / 4 切り上げ)
; dwNameSpace : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; ServiceInfo : SERVICE_INFOA (+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_INFOA
    #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_INFOA
    #field int dwNameSpace
    #field SERVICE_INFOA ServiceInfo
#endstruct

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