Avatar of A. Cristian Csiki
A. Cristian Csiki
Flag for Ireland asked on

Reset computer

Greetings.
I'm wondering if there is a way to make a system reset from a source code? Any ideas how ?
Thanks for caring.
Delphi

Avatar of undefined
Last Comment
A. Cristian Csiki

8/22/2022 - Mon
TName

Do you mean restart the OS, like in

procedure TForm1.Button1Click(Sender: TObject);
begin
  ExitWindowsEx(EWX_REBOOT,0);
end;

or am I way off target?
Mike Littlewood

Yeah I think that is what he wants

to reboot;

exitwindowsex(EWX_REBOOT,0);

to shutdown

exitwindowsex(EWX_SHUTDOWN,0); (or with ewx_poweroff)
A. Cristian Csiki

ASKER
I now to reboot the system, but I want to reset it. Like the reset button does. Is this posible?
Your help has saved me hundreds of hours of internet surfing.
fblack61
Mike Littlewood

But that is what the reset button does .. it reboots the PC .. or have I been told a lie for the last 20 years he he
TName

I think the idea is to reboot without cleanly shutting down. If  yes, then it would't be a very nice thing to do by code, I think. You only use the reset button when the OS is non-responsive, in which case your application should be pretty much helpless also...
A. Cristian Csiki

ASKER
ok, my mistake :D. But still the code doesn't work. I have win xp sp 2 and doesn't do nothing. :(
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER CERTIFIED SOLUTION
TName

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
TName

But save your project first :)
TName

Or better: don't do it with the IDE running!
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Johnjces

Just my 2 cents...

If you really really want to do a hardware reset, most motherboards have two pins on one of the header connectors that when shorted will do a hardware reset. It brings all the reset lines on the buses to logic 0 and will do a hardware reset.

To do this you must of course short those pins or at least bring the active reset pin to ground. The reset pin will normally be at about +5 volts.

This can be accomplished by a single PNP transistor, a 1.2K Ohm resistor and some port software and a port driver for Win NT and above.

Basically, you could connect the base of the transistor to one of the data lines of an unused parallel/printer port, the emitter and collector properly connected between the reset pin and ground, use the port driver and software to bring that pin low which will in turn cause the the transistor to conduct and pow, your PC will reset.

A lot to do for a hardware reset, but it works. There are a lot of circuits out there for using your printer port for control and JDR Microdevices in California has  complete PCI and ISA board for output control. There are freeware drivers for direct access to ports as well.

This verbal example is overly simplified, and right now I am not certain if you would need a PNP or NPN transistor, but hopefully you get the point.

Also, hardware resets can cause problems with your hard drives and data especially if doing a write at the time of the reset.

John
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
saravananvg

Hello Sir,

   Place a button on the form and use the following procedure to shutdown windows. Kindly check the various other options under ExitWindowsEx function available under Windows SDK.

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}
procedure ExitWin2000(ewx: integer);
var
 hToken: THANDLE;
 hProc: THANDLE;
 mLUID: TLargeInteger;
 mPriv, mNewPriv: TOKEN_PRIVILEGES;
 mBufferLength: DWord;
begin
 if not (ewx in [1, 2]) then
   exit;
 hProc := GetCurrentProcess();
 OpenProcessToken(hProc, TOKEN_ADJUST_PRIVILEGES + TOKEN_QUERY, hToken);
 LookupPrivilegeValue('', 'SeShutdownPrivilege', mLUID);
 mPriv.PrivilegeCount := 1;
 mPriv.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
 mPriv.Privileges[0].Luid := mLUID;
 AdjustTokenPrivileges(hToken, False, mPriv, (4 + (12 * mPriv.PrivilegeCount)), mNewPriv, mBufferLength);
 case ewx of
   1: ExitWindowsEx(EWX_FORCE + EWX_REBOOT, 0);
   2: ExitWindowsEx(EWX_FORCE + EWX_POWEROFF, 0);
 end;
end;
procedure shutDown();
var
 os:OSVERSIONINFO;
begin
 os.dwOSVersionInfoSize:=sizeOf(TOSversionInfo);
 getVersionEx(os);
 if (os.dwPlatformId=VER_PLATFORM_WIN32_WINDOWS) then
   exitWindowsEx(EWX_SHUTDOWN,0);
 if (os.dwPlatformId=VER_PLATFORM_WIN32_NT) then
   exitWin2000(2);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
  ShutDown;
end;

end.

with regards,
padmaja.
mahdiparak

A. Cristian Csiki

ASKER
i'll split the points between TNAME and rllibby because they had the closest answers to my q. Thanks to all.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.