ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Disk id (https://www.excelbanter.com/excel-programming/360595-disk-id.html)

mrt

Disk id
 
Hi there,

Has anyone developed some code to obtain the disk id of a given hard disk
(described by the letter)?

Thanks

MrT

Bob Phillips[_14_]

Disk id
 

'---------------------------------------------------------------
Function DiskVolumeId(Drive As String) As String
'---------------------------------------------------------------
Dim sTemp As String
Dim iPos As Long
iPos = InStr(1, Drive, ":")
Drive = IIf(iPos 0, Left(Drive, iPos), Drive & ":")
sTemp = Hex(CreateObject("Scripting.FileSystemObject") _
.Drives.Item(CStr(Drive)).SerialNumber)
DiskVolumeId = Left(sTemp, 4) & "-" & Right(sTemp, 4)
End Function

--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)

"MrT" wrote in message
...
Hi there,

Has anyone developed some code to obtain the disk id of a given hard disk
(described by the letter)?

Thanks

MrT




Tom Ogilvy

Disk id
 
http://support.microsoft.com/kb/291573/en-us
How To Use Visual Basic to List Active Logical Drives

http://support.microsoft.com/default...b;en-us;192689
HOWTO: Get UNC Path From a Mapped Network Share's Drive Letter

maybe places to start.

--
Regards,
Tom Ogilvy


"MrT" wrote:

Hi there,

Has anyone developed some code to obtain the disk id of a given hard disk
(described by the letter)?

Thanks

MrT


mrt

Disk id
 
Thanks! simple and perfect ! Works even when calling it directly with a path!

"Bob Phillips" wrote:


'---------------------------------------------------------------
Function DiskVolumeId(Drive As String) As String
'---------------------------------------------------------------
Dim sTemp As String
Dim iPos As Long
iPos = InStr(1, Drive, ":")
Drive = IIf(iPos 0, Left(Drive, iPos), Drive & ":")
sTemp = Hex(CreateObject("Scripting.FileSystemObject") _
.Drives.Item(CStr(Drive)).SerialNumber)
DiskVolumeId = Left(sTemp, 4) & "-" & Right(sTemp, 4)
End Function

--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)

"MrT" wrote in message
...
Hi there,

Has anyone developed some code to obtain the disk id of a given hard disk
(described by the letter)?

Thanks

MrT






All times are GMT +1. The time now is 02:55 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com