Using commands in vb with a class to control the command
Posted: Thu Jul 19, 2012 7:13 am
Hello this is my first tutorial
this is about using commands sort of like sendmessage type stuff!
------------------------------------------------------------------------------------------------------------------------------------------------------------
You need:
1 Class named Command.vb
1 Contextstrip named "Commands" - put a menustriptool name it devices then add on cd drive then open:

under form1 design change the name to "core"
also set contextmenu to: commands
right click core and click view code, and copy and paste this:
there are many more commands like that have to do with os based stuff plus things like advanced pc restart shutdown start screensaver and more good luck!
Credits:
50% MSDN forums - for the set audio cd open code!
50% Me - doing the custom _command part
I am using this to make something very special i might release it in the yay future if i ever finish it :P

------------------------------------------------------------------------------------------------------------------------------------------------------------
You need:
1 Class named Command.vb
1 Contextstrip named "Commands" - put a menustriptool name it devices then add on cd drive then open:

under form1 design change the name to "core"
also set contextmenu to: commands
right click core and click view code, and copy and paste this:
Code: Select all
last copy and paste this in command.vb:
Public Class Core
Dim _command As New Command
Private Sub OpenToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles OpenToolStripMenuItem.Click
_command.OpenCD()
End Sub
End Class
Code: Select all
Debug it right click then use the context menu to navigate to the open drive and click it and it should open your drive!!!Public Class Command
Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" _
(ByVal lpszCommand As String, ByVal lpszReturnString As String, _
ByVal cchReturnLength As Long, ByVal hwndCallback As Long) As Long
Public Sub OpenCD()
mciSendString("set CDAudio door open", 0, 0, 0)
End Sub
End Class
there are many more commands like that have to do with os based stuff plus things like advanced pc restart shutdown start screensaver and more good luck!
Credits:
50% MSDN forums - for the set audio cd open code!
50% Me - doing the custom _command part
I am using this to make something very special i might release it in the yay future if i ever finish it :P