Using commands in vb with a class to control the command

Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
3 posts Page 1 of 1
Contributors
User avatar
lucky134
Just Registered
Just Registered
Posts: 5
Joined: Wed Jul 18, 2012 7:54 pm

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:

Image

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
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
last copy and paste this in command.vb:
Code: Select all
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
Debug it right click then use the context menu to navigate to the open drive and click it and it should open your drive!!!
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 do not have the required permissions to view the files attached to this post.
Last edited by lucky134 on Fri Jul 20, 2012 7:01 am, edited 2 times in total.
User avatar
Shim
VIP - Donator
VIP - Donator
Posts: 882
Joined: Wed Dec 14, 2011 5:02 am

Re: Using commands with class
Shim
nice tutorial lucky134 , keep it up the good work . :D
Find my programs on Softpedia
User avatar
pip
VIP - Donator
VIP - Donator
Posts: 156
Joined: Tue Jul 12, 2011 3:13 am

That's ma brother :P
<a href="http://www.points2shop.com/s/xbox_point ... 5082"><img src="http://points2shop.com/images/promotion ... ricoxg.gif" border="0"/></a>
3 posts Page 1 of 1
Return to “Tutorials”