By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,434 Members | 1,858 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,434 IT Pros & Developers. It's quick & easy.

Reboot a PC with C code

P: n/a
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)();
}

Nov 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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.
Nov 19 '05 #2

P: n/a
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.
Nov 19 '05 #3

P: n/a
Simon Biber wrote
(in article <43***********************@news.optusnet.com.au> ):
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

Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.