Here's fore the Cd-rom ejecting
And here's for the Windows shutdown:Code:Property Get CdromOpen(Optional valchange) As Boolean Static old As Boolean If Not IsMissing(valchange) Then old = valchange CdromOpen = old End Property Property Let CdromOpen(Optional valchange, newvalue As Boolean) Dim lRet&, SRet& valchange = CdromOpen(newvalue) If newvalue Then lRet = mciSendString("set CDAudio door open", SRet, 127, 0) Else lRet = mciSendString("set CDAudio door closed", SRet, 127, 0) End If End Property
Code:'In declarations Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long Enum exitmode Shutdown = 0 Restart = 1 Suspend = 2 End Enum 'In code Sub ExitWindows(how As exitmode) Const EWX_LOGOFF = 0 Const EWX_SHUTDOWN = 1 Const EWX_REBOOT = 2 Const EWX_FORCE = 4 Select Case how Case 0 t& = ExitWindowsEx(EWX_SHUTDOWN, 0) Case 1 t& = ExitWindowsEx(EWX_REBOOT Or EXW_FORCE, 0) Case 2 SetSystemPowerState 1, 1 End Select End Sub





Reply With Quote