 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Nerio Guest
|
Posted: Sat Aug 27, 2005 11:55 pm Post subject: Reset and restarting |
|
|
My apologies for having clicked on the wrong site and sent message to your
private address.
| Quote: | There are many places:
1) The "Startup" group in the Start Menu
2) The "Run" and "RunOnce" subkeys of the
"SoftwareMicrosoftWindowsCurrentVersion" key of the Register's
HKEY_CURRENT_USER and HKEY_LOCAL_MACHINE areas.
It really depends on what your actual needs are, and what kind of systems
you are targetting.
Gambit
Sorry for trouble, but why ExitWindowsEx(EWX_FORCE or EWX_LOGOFF or |
EWX_SHUTDOWN, 0) go fine and ....(EWX_REBOOT or EWX_POWEROFF, 0) seem do
nothing? (ExitWindows() has no reboot capabilities! or not?)
PS destination operating systems are Windows ME and XP (with or whitout SP2)
Many thanks
Nerio
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Sun Aug 28, 2005 7:34 pm Post subject: Re: Reset and restarting |
|
|
"Nerio" <ne_serzanti (AT) tin (DOT) it> wrote
| Quote: | Sorry for trouble, but why ExitWindowsEx(EWX_FORCE or EWX_LOGOFF
or EWX_SHUTDOWN, 0) go fine and ....(EWX_REBOOT or EWX_POWEROFF,
0) seem do nothing?
|
Did you read the documentation for ExitWindows() yet? Did you adjust your
program's privileges to allow rebooting in the first place?
Gambit
|
|
| Back to top |
|
 |
Nerio Guest
|
Posted: Mon Aug 29, 2005 10:52 am Post subject: Re: Reset and restarting |
|
|
"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> ha scritto nel messaggio
news:431212ad$1 (AT) newsgroups (DOT) borland.com...
| Quote: |
"Nerio" <ne_serzanti (AT) tin (DOT) it> wrote in message
news:4310fd3c (AT) newsgroups (DOT) borland.com...
Sorry for trouble, but why ExitWindowsEx(EWX_FORCE or EWX_LOGOFF
or EWX_SHUTDOWN, 0) go fine and ....(EWX_REBOOT or EWX_POWEROFF,
0) seem do nothing?
Did you read the documentation for ExitWindows() yet? Did you adjust your
program's privileges to allow rebooting in the first place?
Gambit
Really I am not able to change priviliges! |
My listing is :
HANDLE Ht;
TOKEN_PRIVILEGES newTp, oldTp; // to restore original values in due time
LUID *myLuid; // used in LookupPrivilegeValue
if(!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES |
TOKEN_QUERY, &Ht))
{ ShowMessage("Error opening Process Token"); return; }
if(!LookupPrivilegeValue(0, SE_SHUTDOWN_NAME, myLuid)) // is useful ?
{ ShowMessage("Error reading Privilege Value"); return; }
== now I should change to SE_PRIVILEGE_ENABLED the relative value in newTp
but how?
Probably I have to redo a more in-depth study of structures.
Thank you very much
Nerio
|
|
| Back to top |
|
 |
Nerio Guest
|
Posted: Tue Aug 30, 2005 10:10 am Post subject: Re: Reset and restarting |
|
|
"Nerio" <ne_serzanti (AT) tin (DOT) it> ha scritto nel messaggio
news:4312e8e4 (AT) newsgroups (DOT) borland.com...
| Quote: | "Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> ha scritto nel messaggio
news:431212ad$1 (AT) newsgroups (DOT) borland.com...
"Nerio" <ne_serzanti (AT) tin (DOT) it> wrote in message
news:4310fd3c (AT) newsgroups (DOT) borland.com...
Sorry for trouble, but why ExitWindowsEx(EWX_FORCE or EWX_LOGOFF
or EWX_SHUTDOWN, 0) go fine and ....(EWX_REBOOT or EWX_POWEROFF,
0) seem do nothing?
Did you read the documentation for ExitWindows() yet? Did you adjust
your
program's privileges to allow rebooting in the first place?
Gambit
Really I am not able to change priviliges!
My listing is : ...........
Nerio
The point is not my structures knowledge (or not only) but particularly my |
manifest ignorance of Windows.
Searching in Googles I found this listing (adapted for my use) :
------
{ HANDLE hToken;
TOKEN_PRIVILEGES newTp, oldTp;
unsigned long dwSize = sizeof(TOKEN_PRIVILEGES);
LUID luid;
if(!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES |
TOKEN_QUERY,
&hToken))
{ ShowMessage("Error opening ProcessToken"); return; }
if(!LookupPrivilegeValue(0, SE_SHUTDOWN_NAME, &luid))
{ ShowMessage("Error reading PrivilegeValue"); return; }
newTp.PrivilegeCount = 1;
newTp.Privileges[0].Luid = luid;
newTp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
if(!AdjustTokenPrivileges(hToken, false, &newTp, sizeof(TOKEN_PRIVILEGES),
&oldTp, &dwSize))
{ ShowMessage("Error on AdjustToken - (enabling)"); CloseHandle(hToken);
return; }
ExitWindowsEx(EWX_REBOOT, 0);
}
------
Many thanks again for help
Nerio
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Tue Sep 06, 2005 5:56 am Post subject: Re: Reset and restarting |
|
|
"Nerio" <ne_serzanti (AT) tin (DOT) it> wrote
| Quote: | Really I am not able to change priviliges!
|
Plase go to http://www.deja.com and do a search through the newsgroup
archives. Sample code has been posted many many times before.
Gambit
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|