code_junkie

Resolve Windows device path to drive letter

Nov 11th, 2011
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. typedef basic_string<TCHAR> tstring;
  2. typedef map<tstring, tstring> HardDiskCollection;
  3.  
  4. void Initialise( HardDiskCollection &_hardDiskCollection )
  5. {
  6. TCHAR tszLinkName[MAX_PATH] = { 0 };
  7. TCHAR tszDevName[MAX_PATH] = { 0 };
  8. TCHAR tcDrive = 0;
  9.  
  10. _tcscpy_s( tszLinkName, MAX_PATH, _T("a:") );
  11. for ( tcDrive = _T('a'); tcDrive < _T('z'); ++tcDrive )
  12. {
  13. tszLinkName[0] = tcDrive;
  14. if ( QueryDosDevice( tszLinkName, tszDevName, MAX_PATH ) )
  15. {
  16. _hardDiskCollection.insert( pair<tstring, tstring>( tszLinkName, tszDevName ) );
  17. }
  18. }
  19. }
Add Comment
Please, Sign In to add comment