Click here to Skip to main content
15,899,754 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralCalling dos command in a win32 console application Pin
kk919-Mar-01 13:14
kk919-Mar-01 13:14 
GeneralRe: Calling dos command in a win32 console application Pin
Tim Deveaux19-Mar-01 14:10
Tim Deveaux19-Mar-01 14:10 
GeneralRe: Calling dos command in a win32 console application Pin
Michael Martin19-Mar-01 15:19
professionalMichael Martin19-Mar-01 15:19 
GeneralCustomizing Intellisense Information Tooltips Pin
19-Mar-01 12:23
suss19-Mar-01 12:23 
GeneralRe: Customizing Intellisense Information Tooltips Pin
20-Mar-01 5:48
suss20-Mar-01 5:48 
GeneralChecking for administrative rights in windows NT Pin
19-Mar-01 12:07
suss19-Mar-01 12:07 
GeneralRe: Checking for administrative rights in windows NT Pin
Tim Deveaux19-Mar-01 13:59
Tim Deveaux19-Mar-01 13:59 
GeneralRe: Checking for administrative rights in windows NT Pin
Cathy17-Aug-01 15:09
Cathy17-Aug-01 15:09 
It works! Thanks! Big Grin | :-D

It's not short though. You have to define SetPrivilege(...)
It's in MSDN "Taking Object Ownership"

BOOL SetPrivilege(
HANDLE hToken, // access token handle
LPCTSTR lpszPrivilege, // name of privilege to enable/disable
BOOL bEnablePrivilege // to enable or disable privilege
)
{
TOKEN_PRIVILEGES tp;
LUID luid;

if ( !LookupPrivilegeValue(
NULL, // lookup privilege on local system
lpszPrivilege, // privilege to lookup
&luid ) )
{ // receives LUID of privilege
printf("LookupPrivilegeValue error: %u\n", GetLastError() );
return FALSE;
}

tp.PrivilegeCount = 1;
tp.Privileges[0].Luid = luid;
if (bEnablePrivilege)
tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
else
tp.Privileges[0].Attributes = 0;

// Enable the privilege or disable all privileges.

AdjustTokenPrivileges(
hToken,
FALSE,
&tp,
sizeof(TOKEN_PRIVILEGES),
(PTOKEN_PRIVILEGES) NULL,
(PDWORD) NULL);

// Call GetLastError to determine whether the function succeeded.

if (GetLastError() != ERROR_SUCCESS)
{
printf("AdjustTokenPrivileges failed: %u\n", GetLastError() );
return FALSE;
}

return TRUE;
}

It's a common enough thing to have to do. I'm sure there must be some built in function somewhere.


GeneralRecasting a void pointer Pin
Andrew Traub19-Mar-01 12:03
Andrew Traub19-Mar-01 12:03 
GeneralRe: Recasting a void pointer Pin
Jonathan Gilligan19-Mar-01 12:25
Jonathan Gilligan19-Mar-01 12:25 
GeneralSwitching between two forms Pin
19-Mar-01 9:06
suss19-Mar-01 9:06 
GeneralDisable Tree Item in Outlook bar control Pin
19-Mar-01 8:59
suss19-Mar-01 8:59 
QuestionHow to use proxy like IE Pin
TomK19-Mar-01 7:18
TomK19-Mar-01 7:18 
GeneralCHtmlView::OnBeforeNavigate2 try to spy Pin
mstuebner19-Mar-01 7:13
mstuebner19-Mar-01 7:13 
GeneralRe: CHtmlView::OnBeforeNavigate2 try to spy Pin
jerry0davis20-Mar-01 0:48
jerry0davis20-Mar-01 0:48 
GeneralRe: CHtmlView::OnBeforeNavigate2 try to spy Pin
Datacrime20-Mar-01 2:06
Datacrime20-Mar-01 2:06 
QuestionHow To Bitmap a Push button? Pin
19-Mar-01 6:28
suss19-Mar-01 6:28 
AnswerRe: How To Bitmap a Push button? Pin
Christian Graus19-Mar-01 11:47
protectorChristian Graus19-Mar-01 11:47 
QuestionProblems with CRecordset DoDataExchange !!!??? Pin
Ariel19-Mar-01 6:18
Ariel19-Mar-01 6:18 
GeneralSending an e-mail message Pin
confalonieri19-Mar-01 5:57
confalonieri19-Mar-01 5:57 
GeneralRe: Sending an e-mail message Pin
l a u r e n19-Mar-01 6:09
l a u r e n19-Mar-01 6:09 
GeneralRe: Sending an e-mail message Pin
BLaZe3-Apr-01 17:21
BLaZe3-Apr-01 17:21 
GeneralATL/COM and MFC Pin
#realJSOP19-Mar-01 4:16
professional#realJSOP19-Mar-01 4:16 
GeneralRe: ATL/COM and MFC Pin
Chris Losinger19-Mar-01 4:57
professionalChris Losinger19-Mar-01 4:57 
GeneralRe: ATL/COM and MFC Pin
#realJSOP19-Mar-01 5:59
professional#realJSOP19-Mar-01 5: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.