Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Help   Contact   Merch   Join   Order   Logon   Forums   
 
Back to Access Developers    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
OS Level GUID for File Identification
Kurt Peterson 
      
3 months ago
Using VBA, how can I determine a unique identifier for the currently open Access database file?  Something like a GUID but for the file specifically, similar to how every file on an NTFS volume has an object identifier.  If a copy of the file were to be created, a new unique identifier would be associated with this new file.  Closing a file and then reopening it would not change its unique identifier.
Alex Hedley  @Reply  
            
3 months ago
Could use PS to get some attributes: Get-ItemProperty -Path "filename" | Select-Object Attributes
Kurt Peterson OP  @Reply  
      
3 months ago
Thank you for your quick response. I have never used PS within MS Access VBA so first did some research on that which I was unable to get figured out in a short amount of time.  Eventually I gave up on that path and instead focused directly on PowerShell to see what information I could determine about a file without having to figure out how to integrate a full solution into VBA.  Looking strictly at the PowerShell list of available File Attributes and File Properties, sadly none of them appear to give me a specific value similar to a GUID value.  Any alternate suggestions would be appreciated.
Alex Hedley  @Reply  
            
3 months ago
WMI

https://github.com/vinaypamnani/wmie2
https://github.com/vinaypamnani/wmie

https://devblogs.microsoft.com/scripting/weekend-scripter-the-wmi-explorer-tool/
Kurt Peterson OP  @Reply  
      
3 months ago
Thanks - I'll look into it next.  Probably won't be able to get more time on it today but will hopefully be able to research it by next weekend.
Kurt Peterson OP  @Reply  
      
3 months ago
I have done a lot of research on this and ended up finding the following code to work.  It uses API Declarations.  I will be using the VolumeSerialNumber, FileIndexHigh, and FileIndexLow to create my unique string.

    ' Get the current database path
    filePath = CurrentProject.FullName
    ' Open a handle to the file (Read-only)
    hFile = GetFileHandle(filePath, 0)
        If hFile <> 0 Then
        If GetFileInformationByHandle(hFile, fInfo) <> 0 Then
            ' Combine serial number, high and low parts (simplified representation)
            GetNTFSFileID = fInfo.dwVolumeSerialNumber & "-" & fInfo.nFileIndexHigh & "-" & fInfo.nFileIndexLow
        End If
        CloseHandle hFile
    End If


Thanks again for your help in getting me to this answer.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Developers.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 8/12/2026 3:25:59 PM. PLT: 1s