VBA - How to get the serial number of UNC Drive Without API calling

Luthius

Active Member
Joined
Apr 5, 2011
Messages
324
Guys
For security reasons I want that my workbook can only be used if it is on a network.
This network sometimes is mapped by user with different Letters.
I would like to find a way to get the serial number of the network drive based on the UNC path instead of Drive Letter.
But I would like to do it without API calling because some computers have issues on their Windows.
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
I have the code below but is necessary to inform the Letter. I want by UNC drive path.

Code:
[COLOR=#0000ff]Public Function[/COLOR] HDSerialNumber() [COLOR=#0000ff]As String

[/COLOR][COLOR=#0000ff]Dim[/COLOR] fsObj [COLOR=#0000ff]As Object[/COLOR]
[COLOR=#0000ff]Dim [/COLOR]Drv [COLOR=#0000ff]As Object[/COLOR]
    [COLOR=#0000ff]Set[/COLOR] fsObj = [COLOR=#0000ff]New [/COLOR]Scripting.FileSystemObject
    [COLOR=#0000ff]Set[/COLOR] Drv = fsObj.Drives("[COLOR=#ff0000][B]J[/B][/COLOR]")
    HDSerialNumber = Left(Hex(Drv.SerialNumber), 4) _
                     & "-" & Right(Hex(Drv.SerialNumber), 4)
   
[COLOR=#0000ff]End Function[/COLOR]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,374
Messages
6,124,571
Members
449,173
Latest member
Kon123

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top