Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Reboot a PC with C code

Reply
Thread Tools

Reboot a PC with C code

 
 
Antonio
Guest
Posts: n/a
 
      11-19-2005
Hi,
i would write a C program (with Microsoft VC) to reboot a win 98 pc. I found
this code but didn't work

Tnks.

#define MAGIC 0 /* for cold restart */
/* #define MAGIC 0x1234 /* for warm restart */

#define BOOT_SEG 0xffffL
#define BOOT_OFF 0x0000L
#define BOOT_ADR ((BOOT_SEG << 16) | BOOT_OFF)

#define DOS_SEG 0x0040L
#define RESET_FLAG 0x0072L
#define RESET_ADR ((DOS_SEG << 16) | RESET_FLAG)

main()
{
void ((far *fp)()) = (void (far *)()) BOOT_ADR;

*(int far *)RESET_ADR = MAGIC;
(*fp)();
}



 
Reply With Quote
 
 
 
 
Skarmander
Guest
Posts: n/a
 
      11-19-2005
Antonio wrote:
> Hi,
> i would write a C program (with Microsoft VC) to reboot a win 98 pc. I found
> this code but didn't work
>

<snip>
Go to comp.os.ms-windows.programmer.win32. This newsgroup deals with the
C language, not arbitrary code written in C.

You are a barbarian, by the way. Use the Win32 function ExitWindows() or
ExitWindowsEx(), not magical mystery calls.

> Tnks.
>

These days people can't even spell "thanks" out in full anymore.

S.
 
Reply With Quote
 
 
 
 
Simon Biber
Guest
Posts: n/a
 
      11-19-2005
Antonio wrote:
> Hi,
> i would write a C program (with Microsoft VC) to reboot a win 98 pc. I found
> this code but didn't work
>
> Tnks.
>
> #define MAGIC 0 /* for cold restart */
> /* #define MAGIC 0x1234 /* for warm restart */
>
> #define BOOT_SEG 0xffffL
> #define BOOT_OFF 0x0000L
> #define BOOT_ADR ((BOOT_SEG << 16) | BOOT_OFF)
>
> #define DOS_SEG 0x0040L
> #define RESET_FLAG 0x0072L
> #define RESET_ADR ((DOS_SEG << 16) | RESET_FLAG)
>
> main()
> {
> void ((far *fp)()) = (void (far *)()) BOOT_ADR;
>
> *(int far *)RESET_ADR = MAGIC;
> (*fp)();
> }


This is MS-DOS code, not Windows code. I'm sure there's some CamelCase
function in the Windows API that'll do the job for you.

--
Simon.
 
Reply With Quote
 
Randy Howard
Guest
Posts: n/a
 
      11-19-2005
Simon Biber wrote
(in article <437eab15$0$27014$> ):

> This is MS-DOS code, not Windows code. I'm sure there's some CamelCase
> function in the Windows API that'll do the job for you.


IIRC,

outb(0x64, 0xfe);

works fairly efficiently, but can be painful. Nevertheless, it
isn't standard C by any stretch of the imagination.



--
Randy Howard (2reply remove FOOBAR)
"The power of accurate observation is called cynicism by those
who have not got it." - George Bernard Shaw





 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reboot, reboot, reboot Lawrence D'Oliveiro NZ Computing 12 03-07-2009 11:35 PM
To reboot the PIX or not reboot - that is the question Darren Green Cisco 1 03-14-2006 10:59 PM
Reboot a PC with C++ code Antonio C++ 1 11-19-2005 01:37 AM
System reboot/system freeze with simple code in Visual C++ 6 and lcc-win32 (OS issue?) Wagner Dias C++ 3 03-28-2005 07:59 PM
XP Pro Wireless drivers lost @ each reboot =?Utf-8?B?RGF2ZSBILg==?= Wireless Networking 2 09-17-2004 12:51 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57