Click here to Skip to main content
15,912,578 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionvista security Pin
saisp30-Jun-07 3:14
saisp30-Jun-07 3:14 
AnswerRe: vista security Pin
bob1697230-Jun-07 6:59
bob1697230-Jun-07 6:59 
QuestionHow to find out on which disk (not partition) is Windows installed? Pin
Claudiu Bucur30-Jun-07 3:06
Claudiu Bucur30-Jun-07 3:06 
AnswerRe: How to find out on which disk (not partition) is Windows installed? Pin
Randor 30-Jun-07 12:21
professional Randor 30-Jun-07 12:21 
AnswerRe: How to find out on which disk (not partition) is Windows installed? Pin
Claudiu Bucur1-Jul-07 1:10
Claudiu Bucur1-Jul-07 1:10 
QuestionHow to use webcam in VC++? Pin
gentleguy30-Jun-07 2:01
gentleguy30-Jun-07 2:01 
AnswerRe: How to use webcam in VC++? Pin
Mark Salsbery1-Jul-07 10:11
Mark Salsbery1-Jul-07 10:11 
QuestionRegLoadKey Privilege Problem Pin
Akin Ocal30-Jun-07 0:17
Akin Ocal30-Jun-07 0:17 
I try to use RegLoadKey with HKEY_LOCAL_MACHINE hive, but it returns ERROR_ACCESS_DENIED ,
the code below works for HKEY_CURRENT_USER hive , i couldnt figure out why it didnt for also HKEY_LOCAL_MACHINE
although i am setting privilige defined as msdn ( http://msdn2.microsoft.com/en-us/library/ms724889.aspx )

Can you help me ?

HKEY hive ;
LONG lReturn ;
char sFileName[12] = "c:\\test.dat";

SetPrivilege(SE_BACKUP_NAME,TRUE);
SetPrivilege(SE_RESTORE_NAME,TRUE);

RegOpenKeyEx(HKEY_LOCAL_MACHINE, "",0,KEY_READ, &hHive);
RegSaveKey(hHive,sFileName,NULL);
lReturn = RegLoadKey(HKEY_LOCAL_MACHINE,"newhklm\\",sFileName);

// lReturn becomes 5L which means ERROR_ACCESS_DENIED

My privilige function :

BOOL SetPrivilege(LPCTSTR lpszPrivilege, BOOL bEnablePrivilege)
{
TOKEN_PRIVILEGES tp;
LUID luid;
HANDLE hToken;

OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken);
if ( !LookupPrivilegeValue(NULL, lpszPrivilege, &luid) )
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;

AdjustTokenPrivileges(hToken, FALSE, &tp, 0, (PTOKEN_PRIVILEGES) NULL, 0);

return ( (GetLastError()!=ERROR_SUCCESS)?FALSE:TRUE);
}
QuestionRe: RegLoadKey Privilege Problem Pin
David Crow2-Jul-07 5:05
David Crow2-Jul-07 5:05 
QuestionCString Pin
deeps_cute30-Jun-07 0:08
deeps_cute30-Jun-07 0:08 
AnswerRe: CString Pin
Christian Graus30-Jun-07 0:49
protectorChristian Graus30-Jun-07 0:49 
QuestionHow to do bluetooth programming on the computer side? Pin
followait29-Jun-07 23:13
followait29-Jun-07 23:13 
GeneralRe: How to do bluetooth programming on the computer side? Pin
shpid3r30-Aug-07 5:31
shpid3r30-Aug-07 5:31 
QuestionImplicit constructors Pin
tom groezer29-Jun-07 22:47
tom groezer29-Jun-07 22:47 
AnswerRe: Implicit constructors Pin
Sameerkumar Namdeo29-Jun-07 23:46
Sameerkumar Namdeo29-Jun-07 23:46 
AnswerRe: Implicit constructors Pin
fefe.wyx29-Jun-07 23:53
fefe.wyx29-Jun-07 23:53 
QuestionGet all controls on a form Pin
braune29-Jun-07 21:57
braune29-Jun-07 21:57 
QuestionRe: Get all controls on a form Pin
Hamid_RT30-Jun-07 0:42
Hamid_RT30-Jun-07 0:42 
AnswerRe: Get all controls on a form Pin
braune30-Jun-07 10:45
braune30-Jun-07 10:45 
AnswerRe: Get all controls on a form Pin
Mark Salsbery1-Jul-07 10:40
Mark Salsbery1-Jul-07 10:40 
QuestionRe: Get all controls on a form Pin
David Crow2-Jul-07 5:08
David Crow2-Jul-07 5:08 
AnswerRe: Get all controls on a form Pin
braune2-Jul-07 21:39
braune2-Jul-07 21:39 
GeneralRe: Get all controls on a form Pin
David Crow3-Jul-07 2:04
David Crow3-Jul-07 2:04 
GeneralRe: Get all controls on a form Pin
braune3-Jul-07 7:11
braune3-Jul-07 7:11 
GeneralRe: Get all controls on a form Pin
braune3-Jul-07 7:18
braune3-Jul-07 7:18 

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.