DECLARE SUB shutdown () 'SHUTDOWN - APM shutdown routine by Toshi. 'Realmode Advanced Power Management function access 'with this, you can shut down a APM-enabled computer 'immediately, bypassing Windows. In Win98, it will 'the OS to do SCANDISK next time you reboot. 'Note: Load QB using QB/L to get rid of ' "Subprogram not defined" errors. TYPE regtype ax AS INTEGER bx AS INTEGER cx AS INTEGER dx AS INTEGER bp AS INTEGER si AS INTEGER di AS INTEGER flags AS INTEGER END TYPE DIM SHARED regs AS regtype SCREEN 0: WIDTH 80: PALETTE: CLS INPUT "Do you want to shut down immediately"; a$ a$ = UCASE$(a$) IF a$ = "Y" OR a$ = "YES" THEN shutdown DEFINT A-Z SUB shutdown regs.ax = &H5300 'APM installation check regs.bx = &H0 'device=APM system BIOS CALL interrupt(&H15, regs, regs) IF regs.flags AND 1 = 1 THEN PRINT "APM version:"; HEX$(regs.ax \ 256); "."; HEX$(regs.ax AND 255) IF (regs.cx AND 8) THEN PRINT "APM power management disabled." ELSE PRINT "APM power management enabled." END IF ELSE PRINT "APM failure." END END IF regs.ax = &H530D: 'enable device power management regs.bx = &H1: 'to everything managed by the APM BIOS regs.cx = 1: '1=enable, 0=disable CALL interrupt(&H15, regs, regs) IF regs.flags AND 1 THEN SELECT CASE (regs.ax \ 256) CASE 1: PRINT "APM functionality disabled" CASE 3: PRINT "interface not connected" CASE 9: PRINT "unrecognized device ID" CASE &HA: PRINT "parameter out of range" END END SELECT ELSE PRINT "ok, enabled." END IF regs.ax = &H5301: 'connect to real mode interface regs.bx = &H0 CALL interrupt(&H15, regs, regs) IF regs.flags AND 1 THEN SELECT CASE (regs.ax \ 256) CASE 2: PRINT "real mode connection already established." CASE 5: PRINT "16-bit protected mode connection already established." CASE 7: PRINT "32-bit protected mode connection already established." CASE 9: PRINT "unrecognized device ID." CASE &H86: PRINT "APM not present.": END END SELECT END IF regs.ax = &H5301: 'connect to real mode interface regs.bx = &H0 CALL interrupt(&H15, regs, regs) regs.ax = &H530E regs.bx = &H0: 'device=system bios regs.cx = &H102: 'set mode=APM 1.2 CALL interrupt(&H15, regs, regs) regs.ax = &H5307: 'set power state regs.bx = &H1: 'to all devices regs.cx = &H3: 'to off CALL interrupt(&H15, regs, regs) END SUB