here are some hints on hitting the registry with APIs from Wayne that should be helpful.
meanwhile, i have a lazier approach using the imagehlp API and a one-row-table (where i keep all sorts of setup and preference stuff).
the API declaration up at the top of the module:
and a sub that will try to find a file in the location defined in the one-record-table, if not found there then in a default location, and if still not found then will scan c: for it
Private Declare Function SearchTreeForFile Lib "imagehlp" _
(ByVal SearchRoot As String, ByVal FileName As String, _
ByVal Foundfile As String) As Boolean
replace c:\Program Files\Common Files\Microsoft Shared\SnapshotViewer\SNAPVIEW.EXE
c:\program files\adobe\acrobat 7.0\reader\acrord32.exe
private sub foo()
'blah blah blah
'blah blah blah
'...resulting in the DAO recordset recs containing my one-record-table
'goal is to set global var gloSnapView to the full c:\path\path\name.ext
'AND save the details in the table for next time if not already there
' /// make sure snapview is under control
If Dir(Nz(recs!snappath, "c:\izy> ")) = "" Then ' "c:\izy> " is doubly-illegal so should not exist
MsgBox "The utility SNAPVIEW.EXE is not where I expected it to be! " _
& "It might be missing or moved." & vbCrLf & "I will search for it on your disk " _
& "(might take a moment).", vbOKOnly + vbInformation, "Search for snapview"
'first try the default location
tmpSnapPath = "c:\Program Files\Common Files\Microsoft Shared\Snapshot Viewer\SNAPVIEW.EXE"
If Dir(tmpSnapPath) = "" Then
'not in default, so scan the whole disk
tmpSnapPath = String(255, " ")
If SearchTreeForFile("c:\", "snapview.exe", tmpSnapPath) Then
tmpSnapPath = Trim(Replace(tmpSnapPath, Chr$(0), " "))
tmpSnapPath = ""
If tmpSnapPath = "" Then
MsgBox "I was unable to locate SNAPVIEW.EXE and will abort.", vbCritical, "Unable to continue"
recs!snappath = tmpSnapPath
MsgBox "I found SNAPVIEW.EXE and saved the location for next time.", vbInformation, "Snapview OK"
gloSnapView = recs!snappath
'blah blah blah to tidy up
currently using SS 2008R2