이 방법이 있습니다.
기본적으로이 같은 장치 관리자에있는 모든 항목을 통해 루프를 필요 :
search = New System.Management.ManagementObjectSearcher("SELECT * From Win32_PnPEntity")
For Each info In search.Get()
' Go through each device detected.
Next
나는 다음의 DeviceID 및 ClassGuid 섹션을했다.
GUID가 CD/DVD 플레이어의 GUID 인 {4D36E965-E325-11CE-BFC1-08002BE10318}과 일치하는 경우 사용자가 수행하고자하는 작업에 따라 장치를 사용/사용하지 않도록 설정했습니다.
활성화 또는 비활성화하려면이 편리한 프로그램을 모두 준비했습니다. from here.
나는 단순히이 Form1.vb를 편집 :
Imports System.Management
공공 Form1 클래스
Private Sub btnEnable_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnable.Click
getCdDrives("Enable")
End Sub
Private Sub btnDisable_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisable.Click
getCdDrives("Diable")
End Sub
Public Function getCdDrives(ByVal EnableOrDisable As String) As Boolean
If InputBox("password") = "password" Then
Try
Dim info As System.Management.ManagementObject
Dim search As System.Management.ManagementObjectSearcher
Dim deviceGuid As String
Dim deviceType As String
Dim cameraIsSeenByWindows As Boolean = False
Dim showDebugPrompts As Boolean = False
Dim actualGuid As Guid
search = New System.Management.ManagementObjectSearcher("SELECT * From Win32_PnPEntity")
For Each info In search.Get()
' Go through each device detected.
deviceType = CType(info("DeviceID"), String)
deviceGuid = CType(info("ClassGuid"), String)
If deviceGuid = "{4D36E965-E325-11CE-BFC1-08002BE10318}" Then
actualGuid = New Guid(deviceGuid)
If EnableOrDisable = "Enable" Then
DeviceHelper.SetDeviceEnabled(actualGuid, deviceType, True)
Else
DeviceHelper.SetDeviceEnabled(actualGuid, deviceType, False)
End If
End If
Next
If EnableOrDisable = "Enable" Then
btnDisable.Enabled = True
btnEnable.Enabled = False
Else
btnDisable.Enabled = False
btnEnable.Enabled = True
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
Else
MsgBox("Oooh Va Vu!!")
End If
End Function
최종 클래스
것이다 다음 장치 관리자에서 CD/DVD 드라이브를 통해 루프를 그들을 활성화/비활성화하십시오.
아직 코드를 정리해야합니다. 스크립트를 스레드로 실행해야합니다. 스크립트를 실행하는 동안 순간에 멈 춥니 다.
또한 CD 드라이브가 타이머 이벤트를 사용하는 상태를 알아내는 프로그램을 만들려고합니다. 그런 다음 적절히보고하십시오. 그런 다음 양식이없는 시스템 트레이에서 실행되도록해야합니다. 마침내 데스크톱 상호 작용이 활성화 된 LSA로 실행되도록하십시오.
잠시 후에 마무리하겠습니다.하지만 필요한 것은 모두 여기에 있어야합니다.
희망이 조금 도움이되기를 바랍니다!
장치 관리자에서 장치를 사용하지 않도록 설정하는 것이 좋을 것 같습니다. DVD/CD-ROM 섹션의 모든 항목을 비활성화하는 것뿐입니다. 어떻게 할 수 있습니까? –