Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6351097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:56:12+00:00 2026-05-24T21:56:12+00:00

My task is to track adding and deleting disk drives from windows service. I

  • 0

My task is to track adding and deleting disk drives from windows service. I use RegisterServiceCtrlHandlerEx and RegisterDeviceNotification to implement this. My service control handler routine succefully receives SERVICE_CONTROL_DEVICEEVENT control code and handles DBT_DEVICEARRIVAL and DBT_DEVICEREMOVECOMPLETE events for GUID_DEVINTERFACE_VOLUME clsss. By the way windows does not send DBT_DEVICEQUERYREMOVE, DBT_DEVICEQUERYREMOVEFAILED, DBT_DEVICEREMOVEPENDING events to my routine but now i want to solve another problem.

When i receive DBT_DEVICEARRIVAL and DBT_DEVICEREMOVECOMPLETE events and dbch_devicetype is DBT_DEVTYP_DEVICEINTERFACE i can read device name from dbcc_name field of DEV_BROADCAST_DEVICEINTERFACE structure. It looks like this: \?\STORAGE#RemovableMedia#7&331a4e33&0&RM#{53f5630d-b6bf-11d0-94f2-00a0c91efb8b}

I can convert this string to volume guid path using GetVolumeNameForVolumeMountPoint procedure only on DBT_DEVICEARRIVAL event. On DBT_DEVICEREMOVECOMPLETE event GetVolumeNameForVolumeMountPoint returns error 3 (The system cannot find the path specified).

On the other hand during service start i do scan for all volumes in the system with FindFirstVolume/FindNextVolume which returns to me list of volume GUID paths of all volumes.

So if volume exists when my service starts i can receive its volume GUID path. And if that volume will be removed while my service is running then i will receive device name (like \?\STORAGE#RemovableMedia#7&331a4e33&0&RM#{53f5630d-b6bf-11d0-94f2-00a0c91efb8b} ) from
DBT_DEVICEREMOVECOMPLETE event.

As i wrote above i can not use GetVolumeNameForVolumeMountPoint during DBT_DEVICEREMOVECOMPLETE event to get volume GUID path. So i would like to find a way to convert volume GUID path received from FindFirstVolume/FindNextVolume to device name. I need this to maintain my own list of present removable disk drives in the system.

Please give me some advice on this problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T21:56:13+00:00Added an answer on May 24, 2026 at 9:56 pm

    So i found no way to retrieve device paths from volume GUID paths returned by FindFisrtVolume/FindNextVolume. Instead i will replace FindFisrtVolume/FindNextVolume with enumerating device interfaces using SetupApi.

    Here is steps to do that:

    1. Call SetupDiGetClassDevs(&GUID_DEVINTERFACE_VOLUME,NULL,NULL,DIGCF_INTERFACEDEVICE|DIGCF_PRESENT) to retrieve device info set.
    2. Enum device interfaces with SetupDiEnumDeviceInterfaces(devinfoset,NULL,&GUID_DEVINTERFACE_VOLUME,idx,&devitf).
    3. For each device interface call SetupDiGetDeviceInterfaceDetail to retrieve device path.

    Unfortunately device path retrieved in this way differs in case from device path which windows passes in DBT_DEVICEARRIVAL and DBT_DEVICEREMOVECOMPLETE events. So we need to normalize device paths when we compare them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Would anyone happen to know a trick that will keep this MSBuild task from
I'm trying to track down a memory leak in my .NET app. Windows Task
My task is to track registered and guest users on my site. I use
TFS2008. I'd like to track task points on a Task work item, but there
Task: implement paging of database records suitable for different RDBMS. Method should work for
is there any way to intercept calendar task,meetings. Means track task and meeting on
I'm receiving errors from Gtk that I can't track down. Every time my mouse
How can I get the task_id value for a task from within the task?
Can anyone help me with this strange error I'm getting when adding a new
could anyone suggest a way (other than using Task Manager) to track and log

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.