I found this somewhere:
I am not sure whether this works or not? But you can give a try:
<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
Private Shared Function RegisterWindowMessage( _
ByVal lpString As String) As UInteger
Private Sub EventsController_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim MessageID As Integer
MessageID = RegisterWindowMessage("QueryCancelAutoPlay")
You can use this link this is related with C#.net but later on you can use converter
I was able to research how to enable/disable autorun through registry.
This is how to navigate and to disable the Autorun in VB through registry:
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim regVersion As RegistryKey
If regVersion Is Nothing Then
' Key doesn't exist; create it.
Dim intVersion As Integer = 0
If (Not regVersion Is Nothing) Then
intVersion = regVersion.GetValue("Version", 0)
intVersion = intVersion + 255
Depending on whether you want to disable AutoRun for all users or just for the current one, navigate to either of these registry keys (the current code is for one user):
If you want for all users, you need to substitude these lines of code:
Thanks but all the codes didn't disable the Autoplay (Autorun) I restarted the computer after executing the codes but when I plugged the USB it Autoplay it but if I do it manually and plugged the USB it doesn't play it automatically. The OS is Win7 that I'm using.
In the Registry did you change the Permission settings for the "Explorer" folder? Also, after disabling the AuutoRun from the VB program, go to the registry to the locaton where you've disabled the Autorun, and make sure that the Data for NoDriveTypeAutoRun is "0x000000ff (255)". This will tell you that AutoRun is disabled. Otherwise if it's "0x00000091 (145)" then AutoRun is still enabled.
Hold down the start button and press r. This will open the Run box. Type "regedit". This will open the Registry Editor. Then navigate to the folder "Explorer". Right click on it. You will see "Permissions...". From there on, you can follow this Video to change the permissions.
did you prefer those link that I said to you in previous comment,
I am not sure for code that I type as I never attain this type of project but yes, one of those link include solved thread...
if that don't help you:
Follow this link: HERE and also HERE
More info: Click Here (this link is not related with the vb.net, this describe how you can do it manually?, but this will help you if you know how to work with reg. in vb.net programmatically...
I suppose you know it...