CODE: [Copy to clipboard]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dos.h>
#include <io.h>
#include <bios.h>
#include <fcntl.h>
static void interrupt (*OldInt8)(void);
static void interrupt NewInt8(WORD bp,WORD di,WORD si,WORD ds,WORD es,WORD dx,WORD cx,WORD bx,WORD ax);
static void interrupt NewInt8(WORD bp,WORD di,WORD si,WORD ds,WORD es,WORD dx,WORD cx,WORD bx,WORD ax)
{
if(OldInt8!=NULL) OldInt8();
// 你的判斷程序寫在這裡 ....
// 1. 取得時間
// 2. 時間到了嗎
// 3. 執行關機
}
int main(int argc, char *argv[])
{
struct SREGS sregs;
union REGS regs;
unsigned short u16;
// 本程式所需空間
u16 = *(unsigned far*)MK_FP(_psp-1, 3) + 16;
// 計時器中斷每秒會被呼叫 18.2 次
OldInt8 =getvect(0x08); // Store 0x08 VECTOR
setvect(0x08,NewInt8); // install new ISR
keep(0, u16); // 常駐在記憶體
return(1);
}