Pergunta

I want to block a USB based on volume using C#. Like I want to block USB stick if capacity is greater than 8GB.

Look there is a method to block USB on PC using registry. but this will make USB undetectable so I can not get volume information.

I want to do that If my client program is running on some machine and I put restriction that USB capacity >=8GB should be restricted, so my C# code should safely remove the USB and should now show any balloon, I mean silently remove it.

Foi útil?

Solução

If you are disabling the USBSTOR key, then you prevent "ACCESS" to it, that includes gathering information from it.

I suggest you look here: WM_DEVICECHANGE

Using this you can catch when the USB is entered and then get the drive letter and use the DEV_BROADCAST_VOLUME to gather information on it, then you can disable it using your registry method.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top