Click here to Skip to main content
15,885,309 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
AnswerRe: Too FEW Arguments in BOOL? Pin
rbwest8614-Apr-09 1:59
rbwest8614-Apr-09 1:59 
QuestionC++ FFT subroutine Pin
mrby12311-Apr-09 20:49
mrby12311-Apr-09 20:49 
AnswerRe: C++ FFT subroutine Pin
CPallini11-Apr-09 22:40
mveCPallini11-Apr-09 22:40 
Questioncan someone explain to a newby what the top line argument call. Pin
johnathan warfield11-Apr-09 19:53
johnathan warfield11-Apr-09 19:53 
AnswerRe: can someone explain to a newby what the top line argument call. Pin
«_Superman_»11-Apr-09 20:54
professional«_Superman_»11-Apr-09 20:54 
AnswerRe: can someone explain to a newby what the top line argument call. Pin
David Crow13-Apr-09 3:36
David Crow13-Apr-09 3:36 
AnswerRe: can someone explain to a newby what the top line argument call. Pin
johnathan warfield18-Apr-09 8:19
johnathan warfield18-Apr-09 8:19 
QuestionWhat does the : x( value ) mean in this constructor ??? Pin
johnathan warfield11-Apr-09 18:25
johnathan warfield11-Apr-09 18:25 
AnswerRe: What does the : x( value ) mean in this constructor ??? Pin
«_Superman_»11-Apr-09 20:50
professional«_Superman_»11-Apr-09 20:50 
GeneralRe: What does the : x( value ) mean in this constructor ??? Pin
johnathan warfield12-Apr-09 7:07
johnathan warfield12-Apr-09 7:07 
GeneralRe: What does the : x( value ) mean in this constructor ??? Pin
«_Superman_»12-Apr-09 18:37
professional«_Superman_»12-Apr-09 18:37 
QuestionHard Disk(Recovery) Pin
kikivml11-Apr-09 9:10
kikivml11-Apr-09 9:10 
AnswerRe: Hard Disk(Recovery) Pin
Hamid_RT11-Apr-09 19:48
Hamid_RT11-Apr-09 19:48 
QuestionRegistry REG_BINARY Problem Pin
locoone11-Apr-09 8:35
locoone11-Apr-09 8:35 
AnswerRe: Registry REG_BINARY Problem Pin
Baltoro11-Apr-09 11:21
Baltoro11-Apr-09 11:21 
GeneralRe: Registry REG_BINARY Problem Pin
locoone11-Apr-09 20:09
locoone11-Apr-09 20:09 

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.