Click here to Skip to main content
15,913,307 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Install INF file Pin
Randor 19-Feb-10 9:49
professional Randor 19-Feb-10 9:49 
QuestionTesting File Access Rights in MFC [Not solved yet] Pin
staffan_v17-Feb-10 22:48
professionalstaffan_v17-Feb-10 22:48 
AnswerRe: Testing File Access Rights in MFC Pin
CPallini17-Feb-10 23:24
mveCPallini17-Feb-10 23:24 
GeneralRe: Testing File Access Rights in MFC Pin
staffan_v17-Feb-10 23:32
professionalstaffan_v17-Feb-10 23:32 
GeneralRe: Testing File Access Rights in MFC Pin
Richard MacCutchan17-Feb-10 23:44
mveRichard MacCutchan17-Feb-10 23:44 
GeneralRe: Testing File Access Rights in MFC Pin
staffan_v17-Feb-10 23:50
professionalstaffan_v17-Feb-10 23:50 
GeneralRe: Testing File Access Rights in MFC Pin
Richard MacCutchan18-Feb-10 0:17
mveRichard MacCutchan18-Feb-10 0:17 
GeneralRe: Testing File Access Rights in MFC [code] Pin
staffan_v18-Feb-10 4:19
professionalstaffan_v18-Feb-10 4:19 
No problem.

I have found and used this code
bool sysAccessWrite(const LPWSTR path)
{
	DWORD result;
	SECURITY_INFORMATION secInfo = DACL_SECURITY_INFORMATION;
	PSECURITY_DESCRIPTOR secDesc;
	PACL dacl;
	TRUSTEE trustee;
	ACCESS_MASK rights;

	// Get the discretionary access control list.
	result = GetNamedSecurityInfo( path, SE_FILE_OBJECT, secInfo,
		NULL, NULL, &dacl, NULL, &secDesc );
	if( result != ERROR_SUCCESS )
	{
		// set errno = an appropriate error code
		return false;
	}

	// Determine the current user's access rights.
	trustee.pMultipleTrustee = NULL;
	trustee.MultipleTrusteeOperation = NO_MULTIPLE_TRUSTEE;
	trustee.TrusteeForm = TRUSTEE_IS_NAME;
	trustee.TrusteeType = TRUSTEE_IS_USER;
	trustee.ptstrName = _T("CURRENT_USER");
	result = GetEffectiveRightsFromAcl(dacl, &trustee, &rights);
	if( result != ERROR_SUCCESS )
	{
		// set errno = an appropriate error code
		return false;
	}

	// Free the security descriptor.
	(void) LocalFree(secDesc);

	// Return the result.
	return (rights & GENERIC_WRITE) ? true : false;
}


The problem is that it should work, but it don't. At least not when I try it under Windows 7. It gives 1F01FF (Full control) even if the program isn't capable of actually writing to the file.
QuestionRe: Testing File Access Rights in MFC Pin
David Crow19-Feb-10 5:53
David Crow19-Feb-10 5:53 
AnswerRe: Testing File Access Rights in MFC Pin
staffan_v21-Feb-10 22:49
professionalstaffan_v21-Feb-10 22:49 
AnswerRe: Testing File Access Rights in MFC Pin
David Crow22-Feb-10 2:06
David Crow22-Feb-10 2:06 
GeneralRe: Testing File Access Rights in MFC Pin
staffan_v22-Feb-10 2:19
professionalstaffan_v22-Feb-10 2:19 
GeneralRe: Testing File Access Rights in MFC Pin
CPallini18-Feb-10 0:10
mveCPallini18-Feb-10 0:10 
GeneralRe: Testing File Access Rights in MFC Pin
staffan_v18-Feb-10 1:01
professionalstaffan_v18-Feb-10 1:01 
AnswerRe: Testing File Access Rights in MFC Pin
Rajesh R Subramanian17-Feb-10 23:57
professionalRajesh R Subramanian17-Feb-10 23:57 
GeneralRe: Testing File Access Rights in MFC Pin
staffan_v18-Feb-10 0:06
professionalstaffan_v18-Feb-10 0:06 
Questioncreating ISO image using VC++ [modified] Pin
podeeshk17-Feb-10 22:41
podeeshk17-Feb-10 22:41 
QuestionDynamic created button Resizing [modified] Pin
shiv@nand17-Feb-10 22:00
shiv@nand17-Feb-10 22:00 
AnswerRe: Dynamic created button Resizing Pin
Code-o-mat17-Feb-10 22:42
Code-o-mat17-Feb-10 22:42 
AnswerRe: Dynamic created button Resizing Pin
BIJU Manjeri17-Feb-10 22:54
BIJU Manjeri17-Feb-10 22:54 
QuestionEditbox background color disappears in windows vista Pin
wuzzywezzer17-Feb-10 20:53
wuzzywezzer17-Feb-10 20:53 
QuestionProblem with Ported Application Pin
chetangbegoor17-Feb-10 19:52
chetangbegoor17-Feb-10 19:52 
AnswerRe: Problem with Ported Application Pin
Richard Andrew x6418-Feb-10 5:24
professionalRichard Andrew x6418-Feb-10 5:24 
Questionvalue that should be passed in MAKEINTRESOURCE function for application main icon Pin
learningvisualc17-Feb-10 19:41
learningvisualc17-Feb-10 19:41 
AnswerRe: value that should be passed in MAKEINTRESOURCE function for application main icon Pin
«_Superman_»17-Feb-10 19:59
professional«_Superman_»17-Feb-10 19:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.