Click here to Skip to main content
15,902,112 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: a question about Edit Box Pin
Shuang. Wu17-May-04 17:32
Shuang. Wu17-May-04 17:32 
GeneralRe: a question about Edit Box Pin
Mahendra_78617-May-04 21:12
Mahendra_78617-May-04 21:12 
GeneralRe: a question about Edit Box Pin
David Crow18-May-04 2:43
David Crow18-May-04 2:43 
GeneralRe: a question about Edit Box Pin
Mahendra_78619-May-04 14:15
Mahendra_78619-May-04 14:15 
GeneralAdministrator Privileges Pin
Deian17-May-04 16:05
Deian17-May-04 16:05 
GeneralRe: Administrator Privileges Pin
valikac17-May-04 18:29
valikac17-May-04 18:29 
GeneralRe: Administrator Privileges Pin
David Crow18-May-04 2:46
David Crow18-May-04 2:46 
GeneralRe: Administrator Privileges Pin
Deian18-May-04 5:36
Deian18-May-04 5:36 
I use the following code to enable "all" privileges, but still, after enabling them, I can't perform uninstall programatically Frown | :( What am I doing wrong?

// Get the privileges<br />
DWORD dwLen;<br />
BOOL bRes = FALSE;<br />
HANDLE hToken; <br />
// Get a token for this process. <br />
if (!OpenProcessToken(GetCurrentProcess(), <br />
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) <br />
{ <br />
	AfxMessageBox("no waaay!");<br />
} <br />
<br />
// obtain dwLen<br />
bRes = GetTokenInformation(<br />
  hToken, <br />
  TokenPrivileges, <br />
  NULL, <br />
  0,<br />
  &dwLen<br />
); <br />
<br />
BYTE* pBuffer = new BYTE[dwLen];<br />
if(pBuffer == NULL)<br />
{<br />
  CloseHandle(hToken);<br />
  AfxMessageBox("no memory");<br />
} <br />
<br />
bRes = GetTokenInformation(<br />
  hToken, <br />
  TokenPrivileges, <br />
  pBuffer,     <br />
  dwLen,        <br />
  &dwLen<br />
);<br />
<br />
if (!bRes)<br />
{<br />
  CloseHandle(hToken);<br />
  delete [] pBuffer;<br />
  AfxMessageBox("Access denied");<br />
} <br />
<br />
// Iterate through all the privileges and enable them all<br />
TOKEN_PRIVILEGES* pPrivs = (TOKEN_PRIVILEGES*)pBuffer;<br />
for (DWORD i = 0; i < pPrivs->PrivilegeCount; i++)<br />
{<br />
  pPrivs->Privileges[i].Attributes |= SE_PRIVILEGE_ENABLED;<br />
} <br />
// Store the information back in the token<br />
bRes = AdjustTokenPrivileges(<br />
  hToken, <br />
  FALSE, <br />
  pPrivs, <br />
  0, NULL, NULL<br />
);<br />
<br />
delete [] pBuffer;<br />
CloseHandle(hToken); <br />
<br />
if (!bRes)<br />
  AfxMessageBox("Access denied");<br />
else<br />
  AfxMessageBox("success");

GeneralRe: Administrator Privileges Pin
David Crow18-May-04 6:20
David Crow18-May-04 6:20 
GeneralRe: Administrator Privileges Pin
Deian18-May-04 7:01
Deian18-May-04 7:01 
GeneralRe: Administrator Privileges Pin
David Crow18-May-04 7:48
David Crow18-May-04 7:48 
GeneralRe: Administrator Privileges Pin
Deian18-May-04 7:57
Deian18-May-04 7:57 
GeneralUNICODE problem: fgetws Pin
IGx8917-May-04 16:01
IGx8917-May-04 16:01 
GeneralRe: UNICODE problem: fgetws Pin
Mike Dimmick18-May-04 2:58
Mike Dimmick18-May-04 2:58 
GeneralRe: UNICODE problem: fgetws Pin
IGx8918-May-04 4:12
IGx8918-May-04 4:12 
GeneralReusing a dialog resource in a New Project Pin
jerry1211a17-May-04 15:53
jerry1211a17-May-04 15:53 
GeneralRe: Reusing a dialog resource in a New Project Pin
monrobot1317-May-04 16:31
monrobot1317-May-04 16:31 
GeneralRe: Reusing a dialog resource in a New Project Pin
jerry1211a17-May-04 16:51
jerry1211a17-May-04 16:51 
GeneralRe: Reusing a dialog resource in a New Project Pin
Jason Henderson17-May-04 19:14
Jason Henderson17-May-04 19:14 
GeneralRe: Reusing a dialog resource in a New Project Pin
Prakash Nadar17-May-04 18:36
Prakash Nadar17-May-04 18:36 
Generalcreate/control dynamic combo box Pin
elephantstar17-May-04 14:06
elephantstar17-May-04 14:06 
GeneralRe: create/control dynamic combo box Pin
alex.barylski17-May-04 14:44
alex.barylski17-May-04 14:44 
GeneralRe: create/control dynamic combo box Pin
elephantstar18-May-04 6:17
elephantstar18-May-04 6:17 
GeneralRe: create/control dynamic combo box Pin
alex.barylski18-May-04 7:06
alex.barylski18-May-04 7:06 
GeneralRe: create/control dynamic combo box Pin
elephantstar18-May-04 10:53
elephantstar18-May-04 10:53 

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.