Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Asked Once!

sad.boysad.boy Member Posts: 90
i had asked this question but i did not get the answer and the code i was offered did not work properly! how can i code this :i want when a condition is true the the system get restarted! please tell me clearly ;)

Comments

  • Phat NatPhat Nat Member Posts: 757
    : i had asked this question but i did not get the answer and the code i was offered did not work properly! how can i code this :i want when a condition is true the the system get restarted! please tell me clearly ;)
    :

    As I wrote in this post:
    http://www.programmersheaven.com/c/msgboard/read.asp?Board=16&MsgID=319654&Setting=A9999F0006

    The code I gave was almost correct, I just forgot the Variables. I have tries this and it works for me. Looking on the Net... I discovered this. It is the same, except it closes any Disk Caches to prevent file corruption:

    [code]
    procedure REBOOT;
    label next;
    var regs : registers;
    i : byte;
    ticks : longint;
    begin
    {... "press" alt-ctrl ...}
    mem[$0040:$0017] := mem[$0040:$0017] or $0C; { 00001100 }
    {... "press" del, try a few times ...}
    for i := 1 to 10 do
    begin
    FillChar (regs, sizeOf(regs), 0); { initialize }
    regs.ah := $4F; { service number }
    regs.al := $53; { del key's scan code }
    regs.flags := FCarry; { "sentinel for ignoring key" }
    Intr ($15, regs);
    {... check if the del key registered, if not retry ...}
    if regs.flags and Fcarry > 0 then goto next;
    {... waste some time, watch out for midnight ...}
    ticks := MemL [$0040:$006C];
    repeat until (MemL[$0040:$006C] - ticks > 3) or
    (MemL[$0040:$006C] - ticks < 0)
    end; {for}
    exit;
    next:
    {... disk reset: writes all modified disk buffers to disk ...}
    FillChar (regs, sizeOf(regs), 0);
    regs.ah := $0D;
    MsDos (regs);
    {... set post-reset flag, use $0000 instead of $1234 for coldboot ...}
    memW[$0040:$0072] := $1234;
    {... jump to $FFFF:0000 BIOS reset ...}
    Inline($EA/$00/$00/$FF/$FF);
    end; (* reboot *)
    [/code]

    So, unless you were unclear and you are NOT running DOS, but a DOS box in Windows, this will work. Otherwise, refer to question #49 (second to last answer) in the file FAQPAS2.TXT here:
    ftp://garbo.uwasa.fi/pc/ts/tsfaqp50.zip

    Phat Nat

Sign In or Register to comment.