std::wstring isAdmin()
{
	SID_IDENTIFIER_AUTHORITY pIdentStruct = SECURITY_NT_AUTHORITY;
	PSID ptrSidStruct;
	BOOL isMember = false;

	if (!AllocateAndInitializeSid(&pIdentStruct, 2,SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &ptrSidStruct))
	{
		return L"Unable to allocate & initialize SID struct";
	}
	if (!CheckTokenMembership( 0, ptrSidStruct, &isMember))
	{
		FreeSid(ptrSidStruct);
		return L"You do not have administrator priveledges.";
	}
	else
	{
		FreeSid(ptrSidStruct);
		return L"You have administrator privledges!";
	}
}

the above code is suppose to check if the user has admin priveleges or not...i think it is not working properly because everytime i run the code i get the "You have admin privledges" string...even if the program is not run as /right mouse click /run as asministrator

any ideas? thx