Click here to Skip to main content
15,891,828 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Is any function which close all open files? Pin
Vijjuuu.12-Apr-09 19:25
Vijjuuu.12-Apr-09 19:25 
GeneralRe: Is any function which close all open files? Pin
002comp12-Apr-09 19:38
002comp12-Apr-09 19:38 
GeneralRe: Is any function which close all open files? Pin
Vijjuuu.12-Apr-09 19:52
Vijjuuu.12-Apr-09 19:52 
GeneralRe: Is any function which close all open files? Pin
002comp12-Apr-09 20:38
002comp12-Apr-09 20:38 
QuestionExternal USB Hard Disk Drive Pin
Abinash Mohanty12-Apr-09 18:53
Abinash Mohanty12-Apr-09 18:53 
QuestionList control problem. Pin
sam_psycho12-Apr-09 18:26
sam_psycho12-Apr-09 18:26 
AnswerRe: List control problem. Pin
SachinBhave12-Apr-09 21:34
SachinBhave12-Apr-09 21:34 
QuestionUsing EDCF protocol in Network Simulator program [modified] Pin
linux_00712-Apr-09 10:30
linux_00712-Apr-09 10:30 
QuestionAPPLICATIONS FOR APPLE MAC Pin
MIKEB7212-Apr-09 8:38
MIKEB7212-Apr-09 8:38 
AnswerRe: APPLICATIONS FOR APPLE MAC Pin
Maximilien12-Apr-09 11:29
Maximilien12-Apr-09 11:29 
QuestionHow to cancel serializing within CDocument::Serilize()? Pin
Joseph Marzbani12-Apr-09 8:28
Joseph Marzbani12-Apr-09 8:28 
Questionhelp with binary Pin
Aljaz11112-Apr-09 7:36
Aljaz11112-Apr-09 7:36 
AnswerRe: help with binary Pin
Luc 64801112-Apr-09 8:30
Luc 64801112-Apr-09 8:30 
GeneralRe: help with binary Pin
Aljaz11112-Apr-09 9:59
Aljaz11112-Apr-09 9:59 
Questionproblem about cvcamshift Pin
onlybluemoon12-Apr-09 5:38
onlybluemoon12-Apr-09 5:38 
Questionhow to delete cstring from specific index Pin
Aljaz11112-Apr-09 3:09
Aljaz11112-Apr-09 3:09 
AnswerRe: how to delete cstring from specific index Pin
Hamid_RT12-Apr-09 5:06
Hamid_RT12-Apr-09 5:06 
GeneralRe: how to delete cstring from specific index Pin
Aljaz11112-Apr-09 7:34
Aljaz11112-Apr-09 7:34 
GeneralRe: how to delete cstring from specific index Pin
Larry Mills Sr12-Apr-09 9:48
Larry Mills Sr12-Apr-09 9:48 
GeneralRe: how to delete cstring from specific index Pin
Aljaz11112-Apr-09 10:00
Aljaz11112-Apr-09 10:00 
GeneralRe: how to delete cstring from specific index Pin
Aljaz11112-Apr-09 10:04
Aljaz11112-Apr-09 10:04 
GeneralRe: how to delete cstring from specific index Pin
«_Superman_»12-Apr-09 18:40
professional«_Superman_»12-Apr-09 18:40 
QuestionRe: how to delete cstring from specific index Pin
David Crow13-Apr-09 3:44
David Crow13-Apr-09 3:44 
QuestionToo FEW Arguments in BOOL? Pin
rbwest8611-Apr-09 21:56
rbwest8611-Apr-09 21:56 
Ok, heres what should happen. The program should return the value's of the access token of the current user. What is wrong with this picture?

I believe I need to relate SetPrivilege to a string. So later on I can use cout SetPrivilege()

I am setting up a GUEST account on my laptop, then running my program to retrieve the access token, so we can view the relate ACE's within the DACL. The point is to retrieve the limited access and display it on the screen. So I can then change it; getting familiar with ACE's, DACL's, and SACL's.

The error I get when compiling this source is that BOOL has to Few arguments. So BOOL does not have enough supplied telling it what to do, correct?

Thank you all in advance!

V/R

Rob & Big


#include <iostream><br />
#include <string><br />
#include <windows.h><br />
#include <stdio.h><br />
using namespace std;<br />
<br />
<br />
BOOL SetPrivilege(<br />
    HANDLE hToken,          // access token handle<br />
    LPCTSTR lpszPrivilege,  // name of privilege to enable/disable<br />
    BOOL bEnablePrivilege   // to enable or disable privilege<br />
    ) <br />
{<br />
	TOKEN_PRIVILEGES tp;<br />
	LUID luid;<br />
<br />
	if ( !LookupPrivilegeValue( <br />
			NULL,            // lookup privilege on local system<br />
			lpszPrivilege,   // privilege to lookup <br />
			&luid ) )        // receives LUID of privilege<br />
	{<br />
		printf("LookupPrivilegeValue error: %u\n", GetLastError() ); <br />
		return FALSE; <br />
	}<br />
<br />
	tp.PrivilegeCount = 1;<br />
	tp.Privileges[0].Luid = luid;<br />
	if (bEnablePrivilege)<br />
		tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;<br />
	else<br />
		tp.Privileges[0].Attributes = 0;<br />
<br />
	// Enable the privilege or disable all privileges.<br />
<br />
	if ( !AdjustTokenPrivileges(<br />
		   hToken, <br />
		   FALSE, <br />
		   &tp, <br />
		   sizeof(TOKEN_PRIVILEGES), <br />
		   (PTOKEN_PRIVILEGES) NULL, <br />
		   (PDWORD) NULL) )<br />
	{ <br />
		  printf("AdjustTokenPrivileges error: %u\n", GetLastError() ); <br />
		  return FALSE; <br />
	} <br />
<br />
	if (GetLastError() == ERROR_NOT_ALL_ASSIGNED)<br />
<br />
	{<br />
		  printf("The token does not have the specified privilege. \n");<br />
		  return FALSE;<br />
	} <br />
<br />
	return TRUE;<br />
}<br />
<br />
// Retrieve Local Computer Name<br />
string GetLocalComputerName()<br />
{<br />
   TCHAR chrComputerName[MAX_COMPUTERNAME_LENGTH + 1];<br />
   string strRetVal;<br />
   DWORD dwBufferSize = MAX_COMPUTERNAME_LENGTH + 1;<br />
   <br />
   if(GetComputerName(chrComputerName,&dwBufferSize)) {<br />
      strRetVal = chrComputerName;<br />
   } else {<br />
      strRetVal = "";<br />
   }<br />
   <br />
   return(strRetVal);<br />
}<br />
<br />
<br />
int main()<br />
{<br />
   system("CLS");<br />
   string password;<br />
   cout << "password: ";<br />
   cin >> password;<br />
   <br />
   if (password == "123"){<br />
      system("CLS");  //Cleares the screen<br />
      cout << "password accepted" << endl;}<br />
   <br />
   else{<br />
      cout << "password incorrect" << endl;<br />
      goto exit;}<br />
exit:<br />
      <br />
      system("CLS");<br />
      system("TITLE Local Computer Name");<br />
<br />
      // Print local computer name.<br />
      cout << GetLocalComputerName() << endl;<br />
      cout << SetPrivilege();<br />
std::cin.ignore( std::numeric_limits<std::streamsize>::max(), '\y' ); <br />
      return 0;<br />
}

AnswerRe: Too FEW Arguments in BOOL? Pin
David Crow13-Apr-09 3:41
David Crow13-Apr-09 3:41 

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.