How to get the Device Instance Path from drive letter using c#

sathish viswanathan 1 Reputation point
2021-07-06T06:36:07.823+00:00

I need to get the Device Instance Path from the drive letter in C#. Using WMI is also fine.

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,229 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Castorix31 81,636 Reputation points
    2021-07-06T07:16:45.233+00:00

    SetupDiGetClassDevs, SetupDiEnumDeviceInterfaces , SetupDiGetDeviceInterfaceDetail
    +
    DeviceIoControl and IOCTL_STORAGE_GET_DEVICE_NUMBER

    0 comments No comments

  2. Daniel Zhang-MSFT 9,611 Reputation points
    2021-07-06T08:30:44.527+00:00

    Hi sathishviswanathan-5522,
    David Ching has provided a solution that using a Windows API in this thread, and you can refer to it.
    Best Regards,
    Daniel Zhang


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments