ホーム › System.GroupPolicy › GenerateGPNotification
GenerateGPNotification
関数グループポリシーの変更通知を生成する。
シグネチャ
// USERENV.dll
#include <windows.h>
DWORD GenerateGPNotification(
BOOL bMachine,
LPCWSTR lpwszMgmtProduct,
DWORD dwMgmtProductOptions
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| bMachine | BOOL | in | TRUEでコンピューター、FALSEでユーザーのポリシー通知を生成する。 |
| lpwszMgmtProduct | LPCWSTR | in | 通知を発行する管理製品の名前を指す文字列。 |
| dwMgmtProductOptions | DWORD | in | 管理製品の種別を示すオプション。サードパーティ製等の区分を指定する。 |
戻り値の型: 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 // DWORDfunction 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)。const std = @import("std");
extern "userenv" fn GenerateGPNotification(
bMachine: i32, // BOOL
lpwszMgmtProduct: [*c]const u16, // LPCWSTR
dwMgmtProductOptions: u32 // DWORD
) callconv(std.os.windows.WINAPI) u32;proc GenerateGPNotification(
bMachine: int32, # BOOL
lpwszMgmtProduct: WideCString, # LPCWSTR
dwMgmtProductOptions: uint32 # DWORD
): uint32 {.importc: "GenerateGPNotification", stdcall, dynlib: "USERENV.dll".}pragma(lib, "userenv");
extern(Windows)
uint GenerateGPNotification(
int bMachine, // BOOL
const(wchar)* lpwszMgmtProduct, // LPCWSTR
uint dwMgmtProductOptions // DWORD
);ccall((:GenerateGPNotification, "USERENV.dll"), stdcall, UInt32,
(Int32, Cwstring, UInt32),
bMachine, lpwszMgmtProduct, dwMgmtProductOptions)
# bMachine : BOOL -> Int32
# lpwszMgmtProduct : LPCWSTR -> Cwstring
# dwMgmtProductOptions : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t GenerateGPNotification(
int32_t bMachine,
const uint16_t* lpwszMgmtProduct,
uint32_t dwMgmtProductOptions);
]]
local userenv = ffi.load("userenv")
-- userenv.GenerateGPNotification(bMachine, lpwszMgmtProduct, dwMgmtProductOptions)
-- bMachine : BOOL
-- lpwszMgmtProduct : LPCWSTR
-- dwMgmtProductOptions : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('USERENV.dll');
const GenerateGPNotification = lib.func('__stdcall', 'GenerateGPNotification', 'uint32_t', ['int32_t', 'str16', 'uint32_t']);
// GenerateGPNotification(bMachine, lpwszMgmtProduct, dwMgmtProductOptions)
// bMachine : BOOL -> 'int32_t'
// lpwszMgmtProduct : LPCWSTR -> 'str16'
// dwMgmtProductOptions : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("USERENV.dll", {
GenerateGPNotification: { parameters: ["i32", "buffer", "u32"], result: "u32" },
});
// lib.symbols.GenerateGPNotification(bMachine, lpwszMgmtProduct, dwMgmtProductOptions)
// bMachine : BOOL -> "i32"
// lpwszMgmtProduct : LPCWSTR -> "buffer"
// dwMgmtProductOptions : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t GenerateGPNotification(
int32_t bMachine,
const uint16_t* lpwszMgmtProduct,
uint32_t dwMgmtProductOptions);
C, "USERENV.dll");
// $ffi->GenerateGPNotification(bMachine, lpwszMgmtProduct, dwMgmtProductOptions);
// bMachine : BOOL
// lpwszMgmtProduct : LPCWSTR
// dwMgmtProductOptions : DWORD
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Userenv extends StdCallLibrary {
Userenv INSTANCE = Native.load("userenv", Userenv.class);
int GenerateGPNotification(
boolean bMachine, // BOOL
WString lpwszMgmtProduct, // LPCWSTR
int dwMgmtProductOptions // DWORD
);
}@[Link("userenv")]
lib LibUSERENV
fun GenerateGPNotification = GenerateGPNotification(
bMachine : Int32, # BOOL
lpwszMgmtProduct : UInt16*, # LPCWSTR
dwMgmtProductOptions : UInt32 # DWORD
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef GenerateGPNotificationNative = Uint32 Function(Int32, Pointer<Utf16>, Uint32);
typedef GenerateGPNotificationDart = int Function(int, Pointer<Utf16>, int);
final GenerateGPNotification = DynamicLibrary.open('USERENV.dll')
.lookupFunction<GenerateGPNotificationNative, GenerateGPNotificationDart>('GenerateGPNotification');
// bMachine : BOOL -> Int32
// lpwszMgmtProduct : LPCWSTR -> Pointer<Utf16>
// dwMgmtProductOptions : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function GenerateGPNotification(
bMachine: BOOL; // BOOL
lpwszMgmtProduct: PWideChar; // LPCWSTR
dwMgmtProductOptions: DWORD // DWORD
): DWORD; stdcall;
external 'USERENV.dll' name 'GenerateGPNotification';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "GenerateGPNotification"
c_GenerateGPNotification :: CInt -> CWString -> Word32 -> IO Word32
-- bMachine : BOOL -> CInt
-- lpwszMgmtProduct : LPCWSTR -> CWString
-- dwMgmtProductOptions : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let generategpnotification =
foreign "GenerateGPNotification"
(int32_t @-> (ptr uint16_t) @-> uint32_t @-> returning uint32_t)
(* bMachine : BOOL -> int32_t *)
(* lpwszMgmtProduct : LPCWSTR -> (ptr uint16_t) *)
(* dwMgmtProductOptions : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library userenv (t "USERENV.dll"))
(cffi:use-foreign-library userenv)
(cffi:defcfun ("GenerateGPNotification" generate-gpnotification :convention :stdcall) :uint32
(b-machine :int32) ; BOOL
(lpwsz-mgmt-product (:string :encoding :utf-16le)) ; LPCWSTR
(dw-mgmt-product-options :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $GenerateGPNotification = Win32::API::More->new('USERENV',
'DWORD GenerateGPNotification(BOOL bMachine, LPCWSTR lpwszMgmtProduct, DWORD dwMgmtProductOptions)');
# my $ret = $GenerateGPNotification->Call($bMachine, $lpwszMgmtProduct, $dwMgmtProductOptions);
# bMachine : BOOL -> BOOL
# lpwszMgmtProduct : LPCWSTR -> LPCWSTR
# dwMgmtProductOptions : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。