' ########################################################################################
' Microsoft Windows
' File: GPEdit.inc
' Contents: Definitions and prototypes for Group Policy
' Copyright (c) 2011 Jos? Roca
' Portions Copyright (c) Microsoft Corporation.
' All Rights Reserved.
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
' EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
' MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
' ########################################################################################
'//
'// Terminology
'//
'// Group Policy Editor - The tool to view a Group Policy Object.
'//
'// Group Policy Object - A collection of administrator defined policies.
'// Each Group Policy Object (GPO) has both file system
'// and Active Directory storage available to it.
'//
'// IGPEInformation - The interface MMC Snapin Extensions use to
'// talk to the Group Policy Editor.
'//
'// IGroupPolicyObject - The interface used to create/edit a GPO directly
'// without going through the Group Policy Editor
'//
#IF NOT %DEF(PBX_GPEdit_PBI)
#DEFINE PBX_GPEdit_PBI
%EQUATE `GPEDIT_INC = 1
#INCLUDE ONCE "Legacy/System/ObjBase.inc"
'//
'// Group Policy Editor MMC SnapIn GUID
'//
'// {8FC0B734-A0E1-11d1-A7D3-0000F87571E3}
$CLSID_GPESnapIn = GUID$("{8FC0B734-A0E1-11d1-A7D3-0000F87571E3}")
'//
'// Group Policy Editor node ids
'//
'//
'// Computer Configuration\Windows Settings
'// {8FC0B737-A0E1-11d1-A7D3-0000F87571E3}
'//
$NODEID_Machine = GUID$("{8FC0B737-A0E1-11d1-A7D3-0000F87571E3}")
'//
'// Computer Configuration\Software Settings
'// {8FC0B73A-A0E1-11d1-A7D3-0000F87571E3}
'//
$NODEID_MachineSWSettings = GUID$("{8FC0B73A-A0E1-11d1-A7D3-0000F87571E3}")
'//
'// User Configuration\Windows Settings
'// {8FC0B738-A0E1-11d1-A7D3-0000F87571E3}
'//
$NODEID_User = GUID$("{8FC0B738-A0E1-11d1-A7D3-0000F87571E3}")
'//
'// User Configuration\Software Settings
'// {8FC0B73C-A0E1-11d1-A7D3-0000F87571E3}
'//
$NODEID_UserSWSettings = GUID$("{8FC0B73C-A0E1-11d1-A7D3-0000F87571E3}")
'//
'// IGPEInformation interface id
'//
'// {8FC0B735-A0E1-11d1-A7D3-0000F87571E3}
$IID_IGPEInformation = GUID$("{8FC0B735-A0E1-11d1-A7D3-0000F87571E3}")
'//
'// Group Policy Object class id
'//
'// {EA502722-A23D-11d1-A7D3-0000F87571E3}
$CLSID_GroupPolicyObject = GUID$("{EA502722-A23D-11d1-A7D3-0000F87571E3}")
'//
'// Group Policy Object interface id
'//
'// {EA502723-A23D-11d1-A7D3-0000F87571E3}
$IID_IGroupPolicyObject = GUID$("{EA502723-A23D-11d1-A7D3-0000F87571E3}")
'//
'// GUID that identifies the registry extension
'//
$REGISTRY_EXTENSION_GUID = GUID$("{35378EAC-683F-11D2-A89A-00C04FBBCFA2}")
'//
'// GUID that identifies the comments extension
'//
$ADMXCOMMENTS_EXTENSION_GUID = GUID$("{6C5A2A86-9EB3-42b9-AA83-A7371BA011B9}")
'//========================================================================================
'//
'// Resultant Set of Policy node ids
'//
'//========================================================================================
'//
'// Resultant Set of Policy MMC SnapIn GUID
'//
'// {6DC3804B-7212-458D-ADB0-9A07E2AE1FA2}
$CLSID_RSOPSnapIn = GUID$("{6DC3804B-7212-458D-ADB0-9A07E2AE1FA2}")
'//
'// Computer Configuration\Windows Settings
'// {BD4C1A2E-0B7A-4A62-A6B0-C0577539C97E}
'//
$NODEID_RSOPMachine = GUID$("{BD4C1A2E-0B7A-4A62-A6B0-C0577539C97E}")
'//
'// Computer Configuration\Software Settings
'// {6A76273E-EB8E-45DB-94C5-25663A5f2C1A}
'//
$NODEID_RSOPMachineSWSettings = GUID$("{6A76273E-EB8E-45DB-94C5-25663A5f2C1A}")
'//
'// User Configuration\Windows Settings
'// {AB87364F-0CEC-4CD8-9BF8-898F34628FB8}
'//
$NODEID_RSOPUser = GUID$("{AB87364F-0CEC-4CD8-9BF8-898F34628FB8}")
'//
'// User Configuration\Software Settings
'// {E52C5CE3-FD27-4402-84DE-D9A5F2858910}
'//
$NODEID_RSOPUserSWSettings = GUID$("{E52C5CE3-FD27-4402-84DE-D9A5F2858910}")
'//
'// IRSOPInformation interface id
'//
'// {9A5A81B5-D9C7-49EF-9D11-DDF50968C48D}
$IID_IRSOPInformation = GUID$("{9A5A81B5-D9C7-49EF-9D11-DDF50968C48D}")
'//
'// Define API decoration for direct importing of DLL references.
'//
'//
'// Group Policy Object Section flags
'//
%EQUATE `GPO_SECTION_ROOT = 0 ' // Root
%EQUATE `GPO_SECTION_USER = 1 ' // User
%EQUATE `GPO_SECTION_MACHINE = 2 ' // Machine
'//
'// Group Policy Object types
'//
#IF NOT %DEF(%GROUP_POLICY_OBJECT_TYPE_ENUM_DEFINED)
%EQUATE `GROUP_POLICY_OBJECT_TYPE_ENUM_DEFINED = 1
' enum GROUP_POLICY_OBJECT_TYPE
%EQUATE `GPOTypeLocal = 0 ' // Default GPO on the local machine
%EQUATE `GPOTypeRemote = 1 ' // GPO on a remote machine
%EQUATE `GPOTypeDS = 2 ' // GPO in the Active Directory
%EQUATE `GPOTypeLocalUser = 3 ' // User-specific GPO on the local machine
%EQUATE `GPOTypeLocalGroup = 4 ' // Group-specific GPO on the local machine
#ENDIF ' // GROUP_POLICY_OBJECT_TYPE_ENUM_DEFINED
'//
'// Group Policy Hint types
'//
' enum GROUP_POLICY_HINT_TYPE
%EQUATE `GPHintUnknown = 0 ' // No link information available
%EQUATE `GPHintMachine = 1 ' // GPO linked to a machine (local or remote)
%EQUATE `GPHintSite = 2 ' // GPO linked to a site
%EQUATE `GPHintDomain = 3 ' // GPO linked to a domain
%EQUATE `GPHintOrganizationalUnit = 4 ' // GPO linked to a organizational unit
' ########################################################################################
' Interface name = IGPEInformation
' IID = 8FC0B735-A0E1-11d1-A7D3-0000F87571E3
' Inherited interface = IUnknown
' ########################################################################################
#IF NOT %DEF(%IGPEInformation_INTERFACE_DEFINED)
 %IGPEInformation_INTERFACE_DEFINED = 1
INTERFACE IGPEInformation $IID_IGPEInformation
 INHERIT IUnknown
 ' =====================================================================================
 METHOD GetName ( ' VTable offset = 12
 BYREF pszName AS WSTRINGZ
 , BYVAL cchMaxLength AS LONG
 ) AS LONG
 ' =====================================================================================
 METHOD GetDisplayName ( ' VTable offset = 16
 BYREF pszName AS WSTRINGZ
 , BYVAL cchMaxLength AS LONG
 ) AS LONG
 ' =====================================================================================
 METHOD GetRegistryKey ( ' VTable offset = 20
 BYVAL dwSection AS DWORD
 , BYREF hKey AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetDSPath ( ' VTable offset = 24
 BYVAL dwSection AS DWORD
 , BYREF pszPath AS WSTRINGZ
 , BYVAL cchMaxPath AS LONG
 ) AS LONG
 ' =====================================================================================
 METHOD GetFileSysPath ( ' VTable offset = 28
 BYVAL dwSection AS DWORD
 , BYREF pszPath AS WSTRINGZ
 , BYVAL cchMaxPath AS LONG
 ) AS LONG
 ' =====================================================================================
 METHOD GetOptions ( ' VTable offset = 32
 BYREF dwOptions AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetType ( ' VTable offset = 36
 BYREF gpoType AS LONG
 ) AS LONG
 ' =====================================================================================
 METHOD GetHint ( ' VTable offset = 40
 BYREF gpHint AS LONG
 ) AS LONG
 ' =====================================================================================
 METHOD PolicyChanged ( ' VTable offset = 44
 BYVAL bMachine AS LONG
 , BYVAL bAdd AS LONG
 , BYREF pGuidExtension AS GUID
 , BYREF pGuidSnapin AS GUID
 ) AS LONG
 ' =====================================================================================
END INTERFACE
#ENDIF ' /* __IGPEInformation_INTERFACE_DEFINED__ */
'//
'// Group Policy Object open / creation flags
'//
%EQUATE `GPO_OPEN_LOAD_REGISTRY = &H00000001 ' // Load the registry files
%EQUATE `GPO_OPEN_READ_ONLY = &H00000002 ' // Open the GPO as read only
'//
'// Group Policy Object option flags
'//
%EQUATE `GPO_OPTION_DISABLE_USER = &H00000001 ' // The user portion of this GPO is disabled
%EQUATE `GPO_OPTION_DISABLE_MACHINE = &H00000002 ' // The machine portion of this GPO is disabled
' ########################################################################################
' Interface name = IGroupPolicyObject
' IID = EA502723-A23D-11d1-A7D3-0000F87571E3
' Inherited interface = IUnknown
' ########################################################################################
#IF NOT %DEF(%IGroupPolicyObject_INTERFACE_DEFINED)
 %IGroupPolicyObject_INTERFACE_DEFINED = 1
INTERFACE IGroupPolicyObject $IID_IGroupPolicyObject
 INHERIT IUnknown
 ' =====================================================================================
 METHOD New ( ' VTable offset = 12
 BYREF pszDomainName AS WSTRINGZ
 , BYREF pszDisplayName AS WSTRINGZ
 , BYVAL dwFlags AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD OpenDSGPO ( ' VTable offset = 16
 BYREF pszPath AS WSTRINGZ
 , BYVAL dwFlags AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD OpenLocalMachineGPO ( ' VTable offset = 20
 BYVAL dwFlags AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD OpenRemoteMachineGPO ( ' VTable offset = 24
 BYREF pszComputerName AS WSTRINGZ
 , BYVAL dwFlags AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD Save ( ' VTable offset = 28
 BYVAL bMachine AS LONG
 , BYVAL bAdd AS LONG
 , BYREF pGuidExtension AS GUID
 , BYREF pGuid AS GUID
 ) AS LONG
 ' =====================================================================================
 METHOD Delete ( ' VTable offset = 32
 ) AS LONG
 ' =====================================================================================
 METHOD GetName ( ' VTable offset = 36
 BYREF pszName AS WSTRINGZ
 , BYVAL cchMaxLength AS LONG
 ) AS LONG
 ' =====================================================================================
 METHOD GetDisplayName ( ' VTable offset = 40
 BYREF pszName AS WSTRINGZ
 , BYVAL cchMaxLength AS LONG
 ) AS LONG
 ' =====================================================================================
 METHOD SetDisplayName ( ' VTable offset = 44
 BYREF pszName AS WSTRINGZ
 ) AS LONG
 ' =====================================================================================
 METHOD GetPath ( ' VTable offset = 48
 BYREF pszPath AS WSTRINGZ
 , BYVAL cchMaxPath AS LONG
 ) AS LONG
 ' =====================================================================================
 METHOD GetDSPath ( ' VTable offset = 52
 BYVAL dwSection AS DWORD
 , BYREF pszPath AS WSTRINGZ
 , BYVAL cchMaxPath AS LONG
 ) AS LONG
 ' =====================================================================================
 METHOD GetFileSysPath ( ' VTable offset = 52
 BYVAL dwSection AS DWORD
 , BYREF pszPath AS WSTRINGZ
 , BYVAL cchMaxPath AS LONG
 ) AS LONG
 ' =====================================================================================
 METHOD GetRegistryKey ( ' VTable offset = 56
 BYVAL dwSection AS DWORD
 , BYREF hKey AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetOptions ( ' VTable offset = 60
 BYREF dwOptions AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD SetOptions ( ' VTable offset = 64
 BYVAL dwOptions AS DWORD
 , BYVAL dwMask AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetType ( ' VTable offset = 68
 BYREF gpoType AS LONG
 ) AS LONG
 ' =====================================================================================
 METHOD GetMachineName ( ' VTable offset = 72
 BYREF pszName AS WSTRINGZ
 , BYVAL cchMaxLength AS LONG
 ) AS LONG
 ' =====================================================================================
 METHOD GetPropertySheetPages ( ' VTable offset = 76
 BYREF hPages AS DWORD
 , BYREF uPageCount AS DWORD
 ) AS LONG
 ' =====================================================================================
END INTERFACE
#ENDIF ' /* __IGroupPolicyObject_INTERFACE_DEFINED__ */
'//
'// RSOP flags
'//
%EQUATE `RSOP_INFO_FLAG_DIAGNOSTIC_MODE = &H00000001 ' // Running in diagnostic mode vs planning mode
' ########################################################################################
' Interface name = IRSOPInformation
' IID = 9A5A81B5-D9C7-49EF-9D11-DDF50968C48D
' Inherited interface = IUnknown
' ########################################################################################
#IF NOT %DEF(%IRSOPInformation_INTERFACE_DEFINED)
 %IRSOPInformation_INTERFACE_DEFINED = 1
INTERFACE IRSOPInformation $IID_IRSOPInformation
 INHERIT IUnknown
 ' =====================================================================================
 METHOD GetNamespace ( ' VTable offset = 12
 BYVAL dwSection AS DWORD
 , BYREF pszName AS WSTRINGZ
 , BYVAL cchMaxLength AS LONG
 ) AS LONG
 ' =====================================================================================
 METHOD GetFlags ( ' VTable offset = 16
 BYREF pdwFlags AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetEventLogEntryText ( ' VTable offset = 20
 BYREF pszEventSource AS WSTRINGZ
 , BYREF pszEventLogName AS WSTRINGZ
 , BYREF pszEventTime AS WSTRINGZ
 , BYVAL dwEventID AS DWORD
 , BYREF ppszText AS DWORD
 ) AS LONG
 ' =====================================================================================
END INTERFACE
#ENDIF ' /* __IRSOPInformation_INTERFACE_DEFINED__ */
'//=============================================================================
'//
'// CreateGPOLink
'//
'// Creates a link to a GPO for the specified Site, Domain, or Organizational Unit
'//
'// lpGPO - ADSI path to the GPO
'// lpContainer - ADSI path to the Site, Domain, or Organizational Unit
'// fHighPriority - Create the link as the highest or lowest priority
'//
'// Returns: S_OK if successful
'//
'//=============================================================================
DECLARE FUNCTION CreateGPOLink LIB "gpedit.dll" ALIAS "CreateGPOLink" ( BYREF lpGPO AS WSTRINGZ , BYREF lpContainer AS WSTRINGZ , BYVAL fHighPriority AS LONG ) AS LONG
'//=============================================================================
'//
'// DeleteGPOLink
'//
'// Deletes a link to a GPO for the specified Site, Domain, or Organizational Unit
'//
'// lpGPO - ADSI path to the GPO
'// lpContainer - ADSI path to the Site, Domain, or Organizational Unit
'//
'// Returns: S_OK if successful
'//
'//=============================================================================
DECLARE FUNCTION CreateGPOLink LIB "gpedit.dll" ALIAS "CreateGPOLink" ( BYREF lpGPO AS WSTRINGZ , BYREF lpContainer AS WSTRINGZ , BYVAL fHighPriority AS LONG ) AS LONG
'//=============================================================================
'//
'// DeleteAllGPOLinks
'//
'// Deletes all GPO links for the specified Site, Domain, or Organizational Unit
'//
'// lpContainer - ADSI path to the Site, Domain, or Organizational Unit
'//
'// Returns: S_OK if successful
'//
'//=============================================================================
DECLARE FUNCTION DeleteAllGPOLinks LIB "gpedit.dll" ALIAS "DeleteAllGPOLinks" ( BYREF lpContainer AS WSTRINGZ ) AS LONG
'//=============================================================================
'//
'// BrowseForGPO
'//
'// Displays the GPO browser dialog
'//
'// lpBrowseInfo - Address of a GPOBROWSEINFO structure
'//
'// Returns: S_OK if successful
'//
'//=============================================================================
'//
'// Flags passed in the dwFlags field of the GPOBROWSEINFO structure
'//
%EQUATE `GPO_BROWSE_DISABLENEW = &H00000001 ' // Disables the New GPO functionality on all pages except "All"
%EQUATE `GPO_BROWSE_NOCOMPUTERS = &H00000002 ' // Removes the Computers tab
%EQUATE `GPO_BROWSE_NODSGPOS = &H00000004 ' // Removes the Domain/OU and Sites tabs
%EQUATE `GPO_BROWSE_OPENBUTTON = &H00000008 ' // Change the Ok button to say Open
%EQUATE `GPO_BROWSE_INITTOALL = &H00000010 ' // Initialize the dialog focused on the All pane
%EQUATE `GPO_BROWSE_NOUSERGPOS = &H00000020 ' // Removes the Users tab
%EQUATE `GPO_BROWSE_SENDAPPLYONEDIT = &H00000040 ' // Send the apply event if edit menu is selected
' // Size = 44 bytes
TYPE GPOBROWSEINFO DWORD
 dwSize AS DWORD ' DWORD // [in] Initialized to the size of this structure
 dwFlags AS DWORD ' DWORD // [in] Flags defined above
 hwndOwner AS DWORD ' HWND // [in] Parent window handle (can be NULL)
 lpTitle AS WSTRINGZ PTR ' LPOLESTR // [in] Title bar text. If NULL, "Browse for a Group Policy Object" will be the default text
 lpInitialOU AS WSTRINGZ PTR ' LPOLESTR // [in] Initial Domain/Organizational Unit to open focus on
 lpDSPath AS WSTRINGZ PTR
 dwDSPathSize AS DWORD ' DWORD // [in] Size in characters of buffer given in lpDSPath
 lpName AS WSTRINGZ PTR
 ' // the friendly name of the GPO (can be NULL)
 dwNameSize AS DWORD ' DWORD // [in] Size in characters of buffer given in lpName
 gpoType AS LONG ' GROUP_POLICY_OBJECT_TYPE // [out] Specifies the type of GPO
 gpoHint AS LONG ' GROUP_POLICY_HINT_TYPE // [out] Specifies a hint of the GPO association
END TYPE
DECLARE FUNCTION BrowseForGPO LIB "gpedit.dll" ALIAS "BrowseForGPO" ( BYREF lpBrowseInfo AS GPOBROWSEINFO ) AS LONG
'//=============================================================================
'//
'// ImportRSoPData
'//
'// Imports a data file generated by ExportRSoPData
'//
'// lpNameSpace - Namespace to place the data in
'// lpFileName - Filename containing the data
'//
'// Returns: S_OK if successful
'//
'// Notes: The namespace specified in lpNameSpace must exist prior to calling
'// this function.
'//
'//=============================================================================
DECLARE FUNCTION ImportRSoPData LIB "gpedit.dll" ALIAS "ImportRSoPData" ( BYREF lpNameSpace AS WSTRINGZ , BYREF lpFileName AS WSTRINGZ ) AS LONG
'//=============================================================================
'//
'// ExportRSoPData
'//
'// Exports a WBEM namespace containing RSoP information to a data file.
'// This data file can be imported to a WBEM namespace using ImportRSoPData.
'//
'// lpNameSpace - Namespace to read the data from
'// lpFileName - Filename to receive the data
'//
'// Returns: S_OK if successful
'//
'// Notes: This function should be called twice. Once for the user data
'// and once for the computer data.
'//
'//=============================================================================
DECLARE FUNCTION ExportRSoPData LIB "gpedit.dll" ALIAS "ExportRSoPData" ( BYREF lpNameSpace AS WSTRINGZ , BYREF lpFileName AS WSTRINGZ ) AS LONG
#ENDIF
