Click here to Skip to main content
15,880,796 members
Articles / Programming Languages / C++

The Windows Access Control Model Part 4

Rate me:
Please Sign up or sign in to vote.
4.86/5 (29 votes)
7 Sep 200543 min read 227.8K   6.8K   100  
The final article in the access control series presents a guide to the access control editor and its associated ISecurityInformation interface.
/**
*	This code is by OShah. all code will have the following licence.
*	Copyright Shexec32. All code bears the following licence:
**/

/**
*	Copyright Shexec32 2004-2005. 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.
**/


#include "../FilePermsBoxDLL/SecurityCore.h"

#import "mscorlib.tlb" \
	raw_interfaces_only auto_rename rename_namespace("FilePermsBox")
#import "System.Windows.Forms.tlb" \
	raw_interfaces_only exclude("IDataObject") auto_rename rename_namespace("System_Windows_Forms")
#import "../NetWrapper/FilePermsBox.interop.dll" \
	auto_rename rename_namespace("FilePermsBox")

intptr_t UseManagedCOMWrapperLib(const std::basic_string<TCHAR> &FileName)
{
	/** Test function for the COM wrapper interface. We can test if the interface is working
	*	using this function. The function calls the .NET PIA to get its COM interface, then.
	**/

	intptr_t Result = 0;

	SAFEARRAY *sa = NULL;
	try
	{

		sa = ::SafeArrayCreateVector(VT_BSTR, 0, 1);

		long rgIndices = 0;
		::_bstr_t ppvData = FileName.c_str();
		::SafeArrayPutElement(sa, &rgIndices, ppvData.GetBSTR());

		FilePermsBox::IManagedSecurityBoxWrapperPtr iInterface;
		iInterface.CreateInstance(L"FilePermsBox.SecurityBox");
		if(static_cast<FilePermsBox::IManagedSecurityBoxWrapper *>(iInterface) != NULL)
		{
			iInterface->FileNames = sa;
			iInterface->COSecurityBox1(FALSE);
			Result = 0;
		}
		else Result = 2;
	} catch (::_com_error &) {
		Result = 2;
	}

	::SafeArrayDestroy(sa);

	return Result;
}


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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
Mr. Shah is a reclusive C++/C# developer lurking somewhere in the depths of the city of London. He learnt physics at Kings' College London and obtained a Master in Science there. Having earned an MCAD, he teeters on the brink of transitioning from C++ to C#, unsure of which language to jump to. Fortunately, he also knows how to use .NET interop to merge code between the two languages (which means he won't have to make the choice anytime soon).

His interests (apart from programming) are walking, football (the real one!), philosophy, history, retro-gaming, strategy gaming, and any good game in general.

He maintains a website / blog / FAQ / junk at shexec32.serveftp.net, where he places the best answers he's written to the questions you've asked. If you can find him, maybe you can hire Mr. Shah to help you with anything C++[/CLI]/C#/.NET related Smile | :) .

Comments and Discussions