This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Private Sub Server_Close(sender As Object, e As EventArgs) Handles MyBase.Disposed | |
If svr IsNot Nothing AndAlso svr.IsListening Then svr.Stop() | |
End Sub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Class Form1 | |
Dim svr As Grapevine.Server.RestServer | |
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load | |
svr = New Grapevine.Server.RestServer | |
With svr | |
.Port = 80 | |
.Host = "0.0.0.0" | |
.UseHttps = False | |
AddHandler svr.Router.BeforeRouting, AddressOf BeforeRouting | |
.LogToConsole.Start() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Private Sub weq_DeviceInsertion(sender As Object, e As EventArrivedEventArgs) | |
Dim LogDisk = e.NewEvent("TargetInstance") | |
Console.WriteLine(LogDisk.Properties("Name").Value) | |
End Sub | |
Private Sub AddWatcher() | |
'Copy weq_Insertion but use __InstanceDeletionEvent instead for Removals | |
Dim weq_Insertion As WqlEventQuery = New WqlEventQuery("SELECT * FROM __InstanceCreationEvent WITHIN 5 WHERE TargetInstance ISA 'Win32_LogicalDisk'") | |
w_Insertion = New ManagementEventWatcher(weq_Insertion) | |
AddHandler w_Insertion.EventArrived, AddressOf weq_DeviceInsertion |