What API is the opposite of this function? I need to specify the device name and get the drive letter. I know I could use this function, but I don't want to have to get the list of all Drives and do a reverse lookup and have to refresh the list every time to be sure I have all devices that may be new, etc.
Announcement
Collapse
No announcement yet.
Opposite of QueryDosDevice?
Collapse
X
-
>but I don't want to have to get the list of all Drives and do a reverse lookup
A. Why not? Ain't no big thang, er, thing.
B. I don't know what the 'device name' for a disk drive might be, but if it's the UNC name you should be able to open and read files using the the '\\computername\sharename\path\file' form of the filename.
How are you getting the 'device name' in the first place?
MCMMichael Mattias
Tal Systems (retired)
Port Washington WI USA
[email protected]
http://www.talsystems.com
-
Well, that is the tricky part. What I'm doing is making a listview contain the list of running apps and I wanted to use their icon as well. I found the various GetModuleFilename/GetWindowModuleFilename threads, but these functions didn't appear to work right in XP...I found a KB that mentioned they only work with the current process too since things aren't shared like they used to be.
Then I found some stuff I believe posted by Jose that helped out and worked, but returned the "Kernel Mode" Device names like Linux/Unix.
So, right now I use something like:
Code:GetWindowThreadProcessId(hWnd, procID) procID= OpenProcess(%PROCESS_QUERY_INFORMATION,ByVal 0, procID) GetProcessImageFileName(procID, AppFilename, 569)
Code:Type driveStruct driveLetter As Asciiz * 3 kernelPath As Asciiz * 310 End Type Function GetDrivePath(ByVal kernelPath As String) As String Local currentDrives As String Local driveArray() As driveStruct Local tempVal As Dword Local tempString As String Local curMatchLen As Dword Local lanSplit As Dword currentDrives= Repeat$(106, $Nul) GetLogicalDriveStrings(105, ByVal StrPtr(currentDrives)) Dim driveArray(25) For tempVal= 0 To 25 driveArray(tempVal).driveLetter= Left$(Parse$(currentDrives, $Nul, tempVal + 1), 2) If Len(driveArray(tempVal).driveLetter) = 0 Then Exit For QueryDosDevice(driveArray(tempVal).driveLetter, driveArray(tempVal).kernelPath, 309) ' Need to handle shares like- \Device\LanmanRedirector\;H:000000000003a8ae\sharename\users\GARSTANG lanSplit= InStr(driveArray(tempVal).kernelPath, ";") If lanSplit <> 0 Then driveArray(tempVal).kernelPath= Left$(driveArray(tempVal).kernelPath, lanSplit - 1) + Remain$(lanSplit, driveArray(tempVal).kernelPath, "\") End If Next tempVal For tempVal= 0 To tempVal - 1 tempString= driveArray(tempVal).kernelPath If (Len(tempString) > curMatchLen) And (Left$(kernelPath, Len(tempString)) = tempString) Then Function= driveArray(tempVal).driveLetter + Mid$(kernelPath, Len(tempString) + 1) curMatchLen= Len(tempString) End If Next tempVal End Function
Last edited by Roger Garstang; 11 Apr 2008, 10:49 AM.sigpic
Mobile Solutions
Sys Analyst and Development
Comment
-
I just looked thru the "WNetxxx functions" with the goal of replacing the call to QueryDOSDevice.
Specifically I was looking at wNetOPenEnum.
This looks interesting. And as long as I now have a network in my office, I can actually try it. I'll do that over the weekend, assuming I finish my personal income tax preparation.
But I have to believe there is some "Wnetxxxx" function which can work for you to get a "\\computername\Sharename" for each current logical drive on the subject PC.
MCMMichael Mattias
Tal Systems (retired)
Port Washington WI USA
[email protected]
http://www.talsystems.com
Comment
Comment