Click here to Skip to main content
15,885,366 members
Articles / Desktop Programming / MFC

Query the New Windows Audit Policies Programmatically

Rate me:
Please Sign up or sign in to vote.
4.08/5 (7 votes)
26 Feb 2010CPOL3 min read 54K   2K   14  
This sample show how to access the information retrieved by running Auditpol.
//	---------------------------------------------------------------------------------------------
//	Author:			Marc Ochsenmeier
//	Email:			info@winitor.net
//	Web:			www.winitor.net
//	Date:			25.02.2010
//
//	Description:	Read the Windows Audit Policy settings programmatically like "Auditpol" does.
//	---------------------------------------------------------------------------------------------
#include "stdafx.h"
#include "Audit Policy Browser.h"
#include "Audit Policy BrowserDlg.h"
#include "Audit Policy Manager.h"
#include "Audit Policy Category.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CAuditPolicyBrowserApp
BEGIN_MESSAGE_MAP(CAuditPolicyBrowserApp, CWinAppEx)
	ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
END_MESSAGE_MAP()

// CAuditPolicyBrowserApp construction
CAuditPolicyBrowserApp::CAuditPolicyBrowserApp()
{
}

// The one and only CAuditPolicyBrowserApp object
CAuditPolicyBrowserApp theApp;

// CAuditPolicyBrowserApp initialization
BOOL CAuditPolicyBrowserApp::InitInstance()
{
	// InitCommonControlsEx() is required on Windows XP if an application
	// manifest specifies use of ComCtl32.dll version 6 or later to enable
	// visual styles.  Otherwise, any window creation will fail.
	INITCOMMONCONTROLSEX InitCtrls;
	InitCtrls.dwSize = sizeof(InitCtrls);
	// Set this to include all the common control classes you want to use
	// in your application.
	InitCtrls.dwICC = ICC_WIN95_CLASSES;
	InitCommonControlsEx(&InitCtrls);

	CWinAppEx::InitInstance();

	AfxEnableControlContainer();

	//	Our UI-based App
	CAuditPolicyBrowserDlg dlg;
	m_pMainWnd = &dlg;
	dlg.DoModal();

	return FALSE;
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer winitor
Germany Germany
Marc Ochsenmeier is the author of pestudio (www.winitor.com) and worked as developer with the focus on Windows Security. He now works as a Malware Analyst

pestudio is on twitter at: https://twitter.com/ochsenmeier

Comments and Discussions