Win32 API 日本語リファレンス
ホームStorage.FileSystem › FILE_NOTIFY_INFORMATION

FILE_NOTIFY_INFORMATION

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

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

フィールド

フィールドサイズx64x86説明
NextEntryOffsetDWORD4+0+0次のエントリへのバイトオフセット。0なら最終エントリ。
ActionFILE_ACTION4+4+4発生した変更の種類(追加/削除/変更/リネーム等のFILE_ACTION)。
FileNameLengthDWORD4+8+8FileNameのバイト長(NULL終端を含まない)。
FileNameWCHAR2+12+12変更されたファイルの相対パス名(可変長WCHAR配列)。

各言語での定義

#include <windows.h>

// FILE_NOTIFY_INFORMATION  (x64 16 / x86 16 バイト)
typedef struct FILE_NOTIFY_INFORMATION {
    DWORD NextEntryOffset;
    FILE_ACTION Action;
    DWORD FileNameLength;
    WCHAR FileName[1];
} FILE_NOTIFY_INFORMATION;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct FILE_NOTIFY_INFORMATION
{
    public uint NextEntryOffset;
    public uint Action;
    public uint FileNameLength;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1)] public string FileName;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure FILE_NOTIFY_INFORMATION
    Public NextEntryOffset As UInteger
    Public Action As UInteger
    Public FileNameLength As UInteger
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=1)> Public FileName As String
End Structure
import ctypes
from ctypes import wintypes

class FILE_NOTIFY_INFORMATION(ctypes.Structure):
    _fields_ = [
        ("NextEntryOffset", wintypes.DWORD),
        ("Action", wintypes.DWORD),
        ("FileNameLength", wintypes.DWORD),
        ("FileName", ctypes.c_wchar * 1),
    ]
#[repr(C)]
pub struct FILE_NOTIFY_INFORMATION {
    pub NextEntryOffset: u32,
    pub Action: u32,
    pub FileNameLength: u32,
    pub FileName: [u16; 1],
}
import "golang.org/x/sys/windows"

type FILE_NOTIFY_INFORMATION struct {
	NextEntryOffset uint32
	Action uint32
	FileNameLength uint32
	FileName [1]uint16
}
type
  FILE_NOTIFY_INFORMATION = record
    NextEntryOffset: DWORD;
    Action: DWORD;
    FileNameLength: DWORD;
    FileName: array[0..0] of WideChar;
  end;
const FILE_NOTIFY_INFORMATION = extern struct {
    NextEntryOffset: u32,
    Action: u32,
    FileNameLength: u32,
    FileName: [1]u16,
};
type
  FILE_NOTIFY_INFORMATION {.bycopy.} = object
    NextEntryOffset: uint32
    Action: uint32
    FileNameLength: uint32
    FileName: array[1, uint16]
struct FILE_NOTIFY_INFORMATION
{
    uint NextEntryOffset;
    uint Action;
    uint FileNameLength;
    wchar[1] FileName;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; FILE_NOTIFY_INFORMATION サイズ: 16 バイト(x64)
dim st, 4    ; 4byte整数×4(構造体サイズ 16 / 4 切り上げ)
; NextEntryOffset : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; Action : FILE_ACTION (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; FileNameLength : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; FileName : WCHAR (+12, 2byte)  varptr(st)+12 を基点に操作(2byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global FILE_NOTIFY_INFORMATION
    #field int NextEntryOffset
    #field int Action
    #field int FileNameLength
    #field wchar FileName 1
#endstruct

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