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

GenerateGPNotification

関数
グループポリシーの変更通知を生成する。
DLLUSERENV.dll呼出規約winapi

シグネチャ

// USERENV.dll
#include <windows.h>

DWORD GenerateGPNotification(
    BOOL bMachine,
    LPCWSTR lpwszMgmtProduct,
    DWORD dwMgmtProductOptions
);

パラメーター

名前方向
bMachineBOOLin
lpwszMgmtProductLPCWSTRin
dwMgmtProductOptionsDWORDin

戻り値の型: DWORD

各言語での呼び出し定義

// USERENV.dll
#include <windows.h>

DWORD GenerateGPNotification(
    BOOL bMachine,
    LPCWSTR lpwszMgmtProduct,
    DWORD dwMgmtProductOptions
);
[DllImport("USERENV.dll", ExactSpelling = true)]
static extern uint GenerateGPNotification(
    bool bMachine,   // BOOL
    [MarshalAs(UnmanagedType.LPWStr)] string lpwszMgmtProduct,   // LPCWSTR
    uint dwMgmtProductOptions   // DWORD
);
<DllImport("USERENV.dll", ExactSpelling:=True)>
Public Shared Function GenerateGPNotification(
    bMachine As Boolean,   ' BOOL
    <MarshalAs(UnmanagedType.LPWStr)> lpwszMgmtProduct As String,   ' LPCWSTR
    dwMgmtProductOptions As UInteger   ' DWORD
) As UInteger
End Function
' bMachine : BOOL
' lpwszMgmtProduct : LPCWSTR
' dwMgmtProductOptions : DWORD
Declare PtrSafe Function GenerateGPNotification Lib "userenv" ( _
    ByVal bMachine As Long, _
    ByVal lpwszMgmtProduct As LongPtr, _
    ByVal dwMgmtProductOptions As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GenerateGPNotification = ctypes.windll.userenv.GenerateGPNotification
GenerateGPNotification.restype = wintypes.DWORD
GenerateGPNotification.argtypes = [
    wintypes.BOOL,  # bMachine : BOOL
    wintypes.LPCWSTR,  # lpwszMgmtProduct : LPCWSTR
    wintypes.DWORD,  # dwMgmtProductOptions : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('USERENV.dll')
GenerateGPNotification = Fiddle::Function.new(
  lib['GenerateGPNotification'],
  [
    Fiddle::TYPE_INT,  # bMachine : BOOL
    Fiddle::TYPE_VOIDP,  # lpwszMgmtProduct : LPCWSTR
    -Fiddle::TYPE_INT,  # dwMgmtProductOptions : DWORD
  ],
  -Fiddle::TYPE_INT)
#[link(name = "userenv")]
extern "system" {
    fn GenerateGPNotification(
        bMachine: i32,  // BOOL
        lpwszMgmtProduct: *const u16,  // LPCWSTR
        dwMgmtProductOptions: u32  // DWORD
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("USERENV.dll")]
public static extern uint GenerateGPNotification(bool bMachine, [MarshalAs(UnmanagedType.LPWStr)] string lpwszMgmtProduct, uint dwMgmtProductOptions);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USERENV_GenerateGPNotification' -Namespace Win32 -PassThru
# $api::GenerateGPNotification(bMachine, lpwszMgmtProduct, dwMgmtProductOptions)
#uselib "USERENV.dll"
#func global GenerateGPNotification "GenerateGPNotification" sptr, sptr, sptr
; GenerateGPNotification bMachine, lpwszMgmtProduct, dwMgmtProductOptions   ; 戻り値は stat
; bMachine : BOOL -> "sptr"
; lpwszMgmtProduct : LPCWSTR -> "sptr"
; dwMgmtProductOptions : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "USERENV.dll"
#cfunc global GenerateGPNotification "GenerateGPNotification" int, wstr, int
; res = GenerateGPNotification(bMachine, lpwszMgmtProduct, dwMgmtProductOptions)
; bMachine : BOOL -> "int"
; lpwszMgmtProduct : LPCWSTR -> "wstr"
; dwMgmtProductOptions : DWORD -> "int"
; DWORD GenerateGPNotification(BOOL bMachine, LPCWSTR lpwszMgmtProduct, DWORD dwMgmtProductOptions)
#uselib "USERENV.dll"
#cfunc global GenerateGPNotification "GenerateGPNotification" int, wstr, int
; res = GenerateGPNotification(bMachine, lpwszMgmtProduct, dwMgmtProductOptions)
; bMachine : BOOL -> "int"
; lpwszMgmtProduct : LPCWSTR -> "wstr"
; dwMgmtProductOptions : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	userenv = windows.NewLazySystemDLL("USERENV.dll")
	procGenerateGPNotification = userenv.NewProc("GenerateGPNotification")
)

// bMachine (BOOL), lpwszMgmtProduct (LPCWSTR), dwMgmtProductOptions (DWORD)
r1, _, err := procGenerateGPNotification.Call(
	uintptr(bMachine),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpwszMgmtProduct))),
	uintptr(dwMgmtProductOptions),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function GenerateGPNotification(
  bMachine: BOOL;   // BOOL
  lpwszMgmtProduct: PWideChar;   // LPCWSTR
  dwMgmtProductOptions: DWORD   // DWORD
): DWORD; stdcall;
  external 'USERENV.dll' name 'GenerateGPNotification';
result := DllCall("USERENV\GenerateGPNotification"
    , "Int", bMachine   ; BOOL
    , "WStr", lpwszMgmtProduct   ; LPCWSTR
    , "UInt", dwMgmtProductOptions   ; DWORD
    , "UInt")   ; return: DWORD
●GenerateGPNotification(bMachine, lpwszMgmtProduct, dwMgmtProductOptions) = DLL("USERENV.dll", "dword GenerateGPNotification(bool, char*, dword)")
# 呼び出し: GenerateGPNotification(bMachine, lpwszMgmtProduct, dwMgmtProductOptions)
# bMachine : BOOL -> "bool"
# lpwszMgmtProduct : LPCWSTR -> "char*"
# dwMgmtProductOptions : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。