ホーム › System.GroupPolicy › GetAppliedGPOListW
GetAppliedGPOListW
関数適用済みGPOの一覧を取得する(Unicode版)。
シグネチャ
// USERENV.dll (Unicode / -W)
#include <windows.h>
DWORD GetAppliedGPOListW(
DWORD dwFlags,
LPCWSTR pMachineName, // optional
PSID pSidUser, // optional
GUID* pGuidExtension,
GROUP_POLICY_OBJECTW** ppGPOList
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| dwFlags | DWORD | in |
| pMachineName | LPCWSTR | inoptional |
| pSidUser | PSID | inoptional |
| pGuidExtension | GUID* | in |
| ppGPOList | GROUP_POLICY_OBJECTW** | out |
戻り値の型: DWORD
各言語での呼び出し定義
// USERENV.dll (Unicode / -W)
#include <windows.h>
DWORD GetAppliedGPOListW(
DWORD dwFlags,
LPCWSTR pMachineName, // optional
PSID pSidUser, // optional
GUID* pGuidExtension,
GROUP_POLICY_OBJECTW** ppGPOList
);[DllImport("USERENV.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint GetAppliedGPOListW(
uint dwFlags, // DWORD
[MarshalAs(UnmanagedType.LPWStr)] string pMachineName, // LPCWSTR optional
IntPtr pSidUser, // PSID optional
ref Guid pGuidExtension, // GUID*
IntPtr ppGPOList // GROUP_POLICY_OBJECTW** out
);<DllImport("USERENV.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function GetAppliedGPOListW(
dwFlags As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPWStr)> pMachineName As String, ' LPCWSTR optional
pSidUser As IntPtr, ' PSID optional
ByRef pGuidExtension As Guid, ' GUID*
ppGPOList As IntPtr ' GROUP_POLICY_OBJECTW** out
) As UInteger
End Function' dwFlags : DWORD
' pMachineName : LPCWSTR optional
' pSidUser : PSID optional
' pGuidExtension : GUID*
' ppGPOList : GROUP_POLICY_OBJECTW** out
Declare PtrSafe Function GetAppliedGPOListW Lib "userenv" ( _
ByVal dwFlags As Long, _
ByVal pMachineName As LongPtr, _
ByVal pSidUser As LongPtr, _
ByVal pGuidExtension As LongPtr, _
ByVal ppGPOList As LongPtr) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetAppliedGPOListW = ctypes.windll.userenv.GetAppliedGPOListW
GetAppliedGPOListW.restype = wintypes.DWORD
GetAppliedGPOListW.argtypes = [
wintypes.DWORD, # dwFlags : DWORD
wintypes.LPCWSTR, # pMachineName : LPCWSTR optional
wintypes.HANDLE, # pSidUser : PSID optional
ctypes.c_void_p, # pGuidExtension : GUID*
ctypes.c_void_p, # ppGPOList : GROUP_POLICY_OBJECTW** out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('USERENV.dll')
GetAppliedGPOListW = Fiddle::Function.new(
lib['GetAppliedGPOListW'],
[
-Fiddle::TYPE_INT, # dwFlags : DWORD
Fiddle::TYPE_VOIDP, # pMachineName : LPCWSTR optional
Fiddle::TYPE_VOIDP, # pSidUser : PSID optional
Fiddle::TYPE_VOIDP, # pGuidExtension : GUID*
Fiddle::TYPE_VOIDP, # ppGPOList : GROUP_POLICY_OBJECTW** out
],
-Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "userenv")]
extern "system" {
fn GetAppliedGPOListW(
dwFlags: u32, // DWORD
pMachineName: *const u16, // LPCWSTR optional
pSidUser: *mut core::ffi::c_void, // PSID optional
pGuidExtension: *mut GUID, // GUID*
ppGPOList: *mut *mut GROUP_POLICY_OBJECTW // GROUP_POLICY_OBJECTW** out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("USERENV.dll", CharSet = CharSet.Unicode)]
public static extern uint GetAppliedGPOListW(uint dwFlags, [MarshalAs(UnmanagedType.LPWStr)] string pMachineName, IntPtr pSidUser, ref Guid pGuidExtension, IntPtr ppGPOList);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USERENV_GetAppliedGPOListW' -Namespace Win32 -PassThru
# $api::GetAppliedGPOListW(dwFlags, pMachineName, pSidUser, pGuidExtension, ppGPOList)#uselib "USERENV.dll"
#func global GetAppliedGPOListW "GetAppliedGPOListW" wptr, wptr, wptr, wptr, wptr
; GetAppliedGPOListW dwFlags, pMachineName, pSidUser, varptr(pGuidExtension), varptr(ppGPOList) ; 戻り値は stat
; dwFlags : DWORD -> "wptr"
; pMachineName : LPCWSTR optional -> "wptr"
; pSidUser : PSID optional -> "wptr"
; pGuidExtension : GUID* -> "wptr"
; ppGPOList : GROUP_POLICY_OBJECTW** out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "USERENV.dll" #cfunc global GetAppliedGPOListW "GetAppliedGPOListW" int, wstr, sptr, var, var ; res = GetAppliedGPOListW(dwFlags, pMachineName, pSidUser, pGuidExtension, ppGPOList) ; dwFlags : DWORD -> "int" ; pMachineName : LPCWSTR optional -> "wstr" ; pSidUser : PSID optional -> "sptr" ; pGuidExtension : GUID* -> "var" ; ppGPOList : GROUP_POLICY_OBJECTW** out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "USERENV.dll" #cfunc global GetAppliedGPOListW "GetAppliedGPOListW" int, wstr, sptr, sptr, sptr ; res = GetAppliedGPOListW(dwFlags, pMachineName, pSidUser, varptr(pGuidExtension), varptr(ppGPOList)) ; dwFlags : DWORD -> "int" ; pMachineName : LPCWSTR optional -> "wstr" ; pSidUser : PSID optional -> "sptr" ; pGuidExtension : GUID* -> "sptr" ; ppGPOList : GROUP_POLICY_OBJECTW** out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD GetAppliedGPOListW(DWORD dwFlags, LPCWSTR pMachineName, PSID pSidUser, GUID* pGuidExtension, GROUP_POLICY_OBJECTW** ppGPOList) #uselib "USERENV.dll" #cfunc global GetAppliedGPOListW "GetAppliedGPOListW" int, wstr, intptr, var, var ; res = GetAppliedGPOListW(dwFlags, pMachineName, pSidUser, pGuidExtension, ppGPOList) ; dwFlags : DWORD -> "int" ; pMachineName : LPCWSTR optional -> "wstr" ; pSidUser : PSID optional -> "intptr" ; pGuidExtension : GUID* -> "var" ; ppGPOList : GROUP_POLICY_OBJECTW** out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD GetAppliedGPOListW(DWORD dwFlags, LPCWSTR pMachineName, PSID pSidUser, GUID* pGuidExtension, GROUP_POLICY_OBJECTW** ppGPOList) #uselib "USERENV.dll" #cfunc global GetAppliedGPOListW "GetAppliedGPOListW" int, wstr, intptr, intptr, intptr ; res = GetAppliedGPOListW(dwFlags, pMachineName, pSidUser, varptr(pGuidExtension), varptr(ppGPOList)) ; dwFlags : DWORD -> "int" ; pMachineName : LPCWSTR optional -> "wstr" ; pSidUser : PSID optional -> "intptr" ; pGuidExtension : GUID* -> "intptr" ; ppGPOList : GROUP_POLICY_OBJECTW** out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
userenv = windows.NewLazySystemDLL("USERENV.dll")
procGetAppliedGPOListW = userenv.NewProc("GetAppliedGPOListW")
)
// dwFlags (DWORD), pMachineName (LPCWSTR optional), pSidUser (PSID optional), pGuidExtension (GUID*), ppGPOList (GROUP_POLICY_OBJECTW** out)
r1, _, err := procGetAppliedGPOListW.Call(
uintptr(dwFlags),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pMachineName))),
uintptr(pSidUser),
uintptr(pGuidExtension),
uintptr(ppGPOList),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction GetAppliedGPOListW(
dwFlags: DWORD; // DWORD
pMachineName: PWideChar; // LPCWSTR optional
pSidUser: THandle; // PSID optional
pGuidExtension: PGUID; // GUID*
ppGPOList: Pointer // GROUP_POLICY_OBJECTW** out
): DWORD; stdcall;
external 'USERENV.dll' name 'GetAppliedGPOListW';result := DllCall("USERENV\GetAppliedGPOListW"
, "UInt", dwFlags ; DWORD
, "WStr", pMachineName ; LPCWSTR optional
, "Ptr", pSidUser ; PSID optional
, "Ptr", pGuidExtension ; GUID*
, "Ptr", ppGPOList ; GROUP_POLICY_OBJECTW** out
, "UInt") ; return: DWORD●GetAppliedGPOListW(dwFlags, pMachineName, pSidUser, pGuidExtension, ppGPOList) = DLL("USERENV.dll", "dword GetAppliedGPOListW(dword, char*, void*, void*, void*)")
# 呼び出し: GetAppliedGPOListW(dwFlags, pMachineName, pSidUser, pGuidExtension, ppGPOList)
# dwFlags : DWORD -> "dword"
# pMachineName : LPCWSTR optional -> "char*"
# pSidUser : PSID optional -> "void*"
# pGuidExtension : GUID* -> "void*"
# ppGPOList : GROUP_POLICY_OBJECTW** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。