
-----------------------------------
Acid
Wed Jun 02, 2004 2:34 pm

A few simple questions
-----------------------------------
These may not seem hard, but I've had nobody to teach me and nobody else to ask.

Is it possible to make my program shut down the computer, and how?

How can I make the program open the CD-ROM drive of my computer?

-----------------------------------
Paul
Wed Jun 02, 2004 4:54 pm


-----------------------------------
I don't know anything about VB, but this might help u
http://www.vb-helper.com/howto_shutdown_exitwindowsex.html
for shutdown
and
for opening CD rom drive
http://www.freevbcode.com/ShowCode.asp?ID=68

-----------------------------------
Brightguy
Wed Jun 02, 2004 5:18 pm

Re: A few simple questions
-----------------------------------
Yep, after a quick search for API fucntions, I came up with:
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long

Private Const EWX_LOGOFF = 0
Private Const EWX_REBOOT = 2
Private Const EWX_SHUTDOWN = 1
Private Const EWX_FORCE = 4

Private Sub cmdShutDown_Click()
    Dim lngShutDown As Long, intConfirm As Integer
    intConfirm = MsgBox("Shut down computer?", vbOKCancel)
    If intConfirm = vbOK Then lngShutDown = ExitWindowsEx(EWX_SHUTDOWN, 0&)
End Sub

Private Sub cmdOpen_Click()
    Call mciSendString("Set CDAudio Door Open Wait", 0&, 0&, 0&)
End Sub

Private Sub cmdClose_Click()
    Call mciSendString("Set CDAudio Door Closed Wait", 0&, 0&, 0&)
End Sub

-----------------------------------
Acid
Thu Jun 03, 2004 9:49 am


-----------------------------------
Thanks a bunch.
