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

RM_PROCESS_INFO

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

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

フィールド

フィールドサイズx64x86説明
ProcessRM_UNIQUE_PROCESS12+0+0対象プロセスの一意識別子。RM_UNIQUE_PROCESSで表す。
strAppNameWCHAR512+12+12アプリケーションの表示名。WCHARの固定長バッファ。
strServiceShortNameWCHAR128+524+524サービスの短い名前。WCHARの固定長バッファ。
ApplicationTypeRM_APP_TYPE4+652+652アプリケーションの種別。RM_APP_TYPE列挙で表す。
AppStatusDWORD4+656+656アプリケーションの現在の状態を示すフラグ。
TSSessionIdDWORD4+660+660アプリケーションが属するターミナルサービスセッションID。
bRestartableBOOL4+664+664再起動マネージャーが再起動可能かのフラグ。BOOL型。

各言語での定義

#include <windows.h>

// FILETIME  (x64 8 / x86 8 バイト)
typedef struct FILETIME {
    DWORD dwLowDateTime;
    DWORD dwHighDateTime;
} FILETIME;

// RM_UNIQUE_PROCESS  (x64 12 / x86 12 バイト)
typedef struct RM_UNIQUE_PROCESS {
    DWORD dwProcessId;
    FILETIME ProcessStartTime;
} RM_UNIQUE_PROCESS;

// RM_PROCESS_INFO  (x64 668 / x86 668 バイト)
typedef struct RM_PROCESS_INFO {
    RM_UNIQUE_PROCESS Process;
    WCHAR strAppName[256];
    WCHAR strServiceShortName[64];
    RM_APP_TYPE ApplicationType;
    DWORD AppStatus;
    DWORD TSSessionId;
    BOOL bRestartable;
} RM_PROCESS_INFO;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct FILETIME
{
    public uint dwLowDateTime;
    public uint dwHighDateTime;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct RM_UNIQUE_PROCESS
{
    public uint dwProcessId;
    public FILETIME ProcessStartTime;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct RM_PROCESS_INFO
{
    public RM_UNIQUE_PROCESS Process;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] public string strAppName;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)] public string strServiceShortName;
    public int ApplicationType;
    public uint AppStatus;
    public uint TSSessionId;
    [MarshalAs(UnmanagedType.Bool)] public bool bRestartable;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure FILETIME
    Public dwLowDateTime As UInteger
    Public dwHighDateTime As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure RM_UNIQUE_PROCESS
    Public dwProcessId As UInteger
    Public ProcessStartTime As FILETIME
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure RM_PROCESS_INFO
    Public Process As RM_UNIQUE_PROCESS
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> Public strAppName As String
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=64)> Public strServiceShortName As String
    Public ApplicationType As Integer
    Public AppStatus As UInteger
    Public TSSessionId As UInteger
    <MarshalAs(UnmanagedType.Bool)> Public bRestartable As Boolean
End Structure
import ctypes
from ctypes import wintypes

class FILETIME(ctypes.Structure):
    _fields_ = [
        ("dwLowDateTime", wintypes.DWORD),
        ("dwHighDateTime", wintypes.DWORD),
    ]

class RM_UNIQUE_PROCESS(ctypes.Structure):
    _fields_ = [
        ("dwProcessId", wintypes.DWORD),
        ("ProcessStartTime", FILETIME),
    ]

class RM_PROCESS_INFO(ctypes.Structure):
    _fields_ = [
        ("Process", RM_UNIQUE_PROCESS),
        ("strAppName", ctypes.c_wchar * 256),
        ("strServiceShortName", ctypes.c_wchar * 64),
        ("ApplicationType", ctypes.c_int),
        ("AppStatus", wintypes.DWORD),
        ("TSSessionId", wintypes.DWORD),
        ("bRestartable", wintypes.BOOL),
    ]
#[repr(C)]
pub struct FILETIME {
    pub dwLowDateTime: u32,
    pub dwHighDateTime: u32,
}

#[repr(C)]
pub struct RM_UNIQUE_PROCESS {
    pub dwProcessId: u32,
    pub ProcessStartTime: FILETIME,
}

#[repr(C)]
pub struct RM_PROCESS_INFO {
    pub Process: RM_UNIQUE_PROCESS,
    pub strAppName: [u16; 256],
    pub strServiceShortName: [u16; 64],
    pub ApplicationType: i32,
    pub AppStatus: u32,
    pub TSSessionId: u32,
    pub bRestartable: i32,
}
import "golang.org/x/sys/windows"

type FILETIME struct {
	dwLowDateTime uint32
	dwHighDateTime uint32
}

type RM_UNIQUE_PROCESS struct {
	dwProcessId uint32
	ProcessStartTime FILETIME
}

type RM_PROCESS_INFO struct {
	Process RM_UNIQUE_PROCESS
	strAppName [256]uint16
	strServiceShortName [64]uint16
	ApplicationType int32
	AppStatus uint32
	TSSessionId uint32
	bRestartable int32
}
type
  FILETIME = record
    dwLowDateTime: DWORD;
    dwHighDateTime: DWORD;
  end;

  RM_UNIQUE_PROCESS = record
    dwProcessId: DWORD;
    ProcessStartTime: FILETIME;
  end;

  RM_PROCESS_INFO = record
    Process: RM_UNIQUE_PROCESS;
    strAppName: array[0..255] of WideChar;
    strServiceShortName: array[0..63] of WideChar;
    ApplicationType: Integer;
    AppStatus: DWORD;
    TSSessionId: DWORD;
    bRestartable: BOOL;
  end;
const FILETIME = extern struct {
    dwLowDateTime: u32,
    dwHighDateTime: u32,
};

const RM_UNIQUE_PROCESS = extern struct {
    dwProcessId: u32,
    ProcessStartTime: FILETIME,
};

const RM_PROCESS_INFO = extern struct {
    Process: RM_UNIQUE_PROCESS,
    strAppName: [256]u16,
    strServiceShortName: [64]u16,
    ApplicationType: i32,
    AppStatus: u32,
    TSSessionId: u32,
    bRestartable: i32,
};
type
  FILETIME {.bycopy.} = object
    dwLowDateTime: uint32
    dwHighDateTime: uint32

  RM_UNIQUE_PROCESS {.bycopy.} = object
    dwProcessId: uint32
    ProcessStartTime: FILETIME

  RM_PROCESS_INFO {.bycopy.} = object
    Process: RM_UNIQUE_PROCESS
    strAppName: array[256, uint16]
    strServiceShortName: array[64, uint16]
    ApplicationType: int32
    AppStatus: uint32
    TSSessionId: uint32
    bRestartable: int32
struct FILETIME
{
    uint dwLowDateTime;
    uint dwHighDateTime;
}

struct RM_UNIQUE_PROCESS
{
    uint dwProcessId;
    FILETIME ProcessStartTime;
}

struct RM_PROCESS_INFO
{
    RM_UNIQUE_PROCESS Process;
    wchar[256] strAppName;
    wchar[64] strServiceShortName;
    int ApplicationType;
    uint AppStatus;
    uint TSSessionId;
    int bRestartable;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; RM_PROCESS_INFO サイズ: 668 バイト(x64)
dim st, 167    ; 4byte整数×167(構造体サイズ 668 / 4 切り上げ)
; Process : RM_UNIQUE_PROCESS (+0, 12byte)  varptr(st)+0 を基点に操作(12byte:入れ子/配列)
; strAppName : WCHAR (+12, 512byte)  varptr(st)+12 を基点に操作(512byte:入れ子/配列)
; strServiceShortName : WCHAR (+524, 128byte)  varptr(st)+524 を基点に操作(128byte:入れ子/配列)
; ApplicationType : RM_APP_TYPE (+652, 4byte)  st.163 = 値  /  値 = st.163   (lpoke/lpeek も可)
; AppStatus : DWORD (+656, 4byte)  st.164 = 値  /  値 = st.164   (lpoke/lpeek も可)
; TSSessionId : DWORD (+660, 4byte)  st.165 = 値  /  値 = st.165   (lpoke/lpeek も可)
; bRestartable : BOOL (+664, 4byte)  st.166 = 値  /  値 = st.166   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global FILETIME
    #field int dwLowDateTime
    #field int dwHighDateTime
#endstruct

#defstruct global RM_UNIQUE_PROCESS
    #field int dwProcessId
    #field FILETIME ProcessStartTime
#endstruct

#defstruct global RM_PROCESS_INFO
    #field RM_UNIQUE_PROCESS Process
    #field wchar strAppName 256
    #field wchar strServiceShortName 64
    #field int ApplicationType
    #field int AppStatus
    #field int TSSessionId
    #field bool bRestartable
#endstruct

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