Link to home
Start Free TrialLog in
Avatar of ramsejp
ramsejp

asked on

How do I do a registry lookup?

I want to do i registry lookup that returns the file name including path of the inbox.dbx file.  I want to be sure this is the default inbox for outlook or outlook express on the machine.  how do i do it?

thanks
Avatar of wileecoy
wileecoy
Flag of United States of America image

Here is a great piece of code for searching through the registry.

http://www.freevbcode.com/ShowCode.Asp?ID=3175

Wileecoy.
Avatar of Richie_Simonetti
Yeah, Ark is on every question even if he doesn't post anything! ;)
Cheers
Lol Richie, does that mean that ramseip should post a 'points for' question???

Isn't it a common programming motto, "If you can't create it, copy it!"
Pardon me, "If you can't create it, reference it!"

That doesn't sound as bad.  ;)

Avatar of ramsejp
ramsejp

ASKER

This code doesn't seem to find what I'm looking for.  I can manually search the registry and find the folder where the files are kept but I can't with this program.  Got anything else?
This will find the inbox.dbx file without the registry.I don't know how you would determine if it was the default.

Private Sub Form_Load()
MsgBox PathTo("inbox.dbx")
End Sub

Function PathTo(strFile As String) As String
Dim x As Integer
Dim strDirs As String
Dim strDir As String
Dim strEntry As String
'Replace 'C:\' with the drive you want to make the search on it.
strDirs = "C:\" & vbNullChar
Do While Len(strDirs)
x = InStr(strDirs, vbNullChar)
strDir = Left$(strDirs, x - 1)
strDirs = Mid$(strDirs, x + 1)
If Len(Dir$(strDir & strFile)) Then
PathTo = strDir & Dir$(strDir & strFile)
Exit Function
End If
strEntry = Dir$(strDir & "*.*", vbDirectory)
Do While Len(strEntry)
On Error GoTo SKIPP
If (GetAttr(strDir & strEntry) And vbDirectory) Then
If strEntry <> "." And strEntry <> ".." Then
  strDirs = strDirs & strDir & strEntry & "\" & vbNullChar
End If
End If
strEntry = Dir$
Loop
SKIPP:
Loop
PathTo = ""
End Function
No wileecoy, i agree with your last post and didn't mention "points for..".
It was a sort of bad joke, nothing else...
Avatar of ramsejp

ASKER

it seems that when using the code you sent me to, you don't always get correct results when searching for keys that have spaces in them.  for example, i am searching for the key called "Store Root" and the program just will not find it.  I can do a search using the regedit search and it finds it no problem.  something isn't right.

Dude - you are exactly right...

Let me look at this a bit.  I apologize.

Wileecoy.
Hey
I'm glad if my code can help somebody, an, of course, points should be awarded to first person who sent working code/link, not the author (actually, points not a goal for me, I already got all my T-Shirts :)). BTW, I did search in registry for "inbox" with my app and Regedit - found same entries, but no default folder. Which entrie did you looking for?

Cheers
Actually, I am having problems finding ValueNames and Values that are in Keys that have SubKeys.

I haven't tested them all, but the ones that I have tested are giving me problems.

I have Outlook and am looking for the "Store Root" that ramsejp is also looking for.  I can find it in the registry search, but not in the vb app.

Ok - I just tested some others and they worked.

This is the SubKey path that I am trying to find it at.

HKEY_USERS\S-1-5-21-1275210071-1682526488-1343024091-1000\Identities\{18DB8111-1FBD-4F9C-AC6D-2613E525AC72}\Software\Microsoft\Outlook Express\5.0


Any ideas?

Hi
Not sure for NT - can not testing, may be it require special privileges.

Cheers
I'm on W2k.  Not sure.

What OS are you on ramsejp?
wilecoy, thanks for pointed this prb. Found a bug, fixed, recently sent fixed code to FreeVBCode. To fix it manually, change in cRegSearch.cls in RegEnumValues Sub:
'=======================================
'...................................
ValueName = String(MAX_KEY_SIZE, 0)
cbDataSize = MAX_VALUE_SIZE
ReDim arrData(cbDataSize - 1)
   Do
'...................................
'=======================================
to
'=======================================
   Do
     ValueName = String(MAX_KEY_SIZE, 0)
     cbDataSize = MAX_VALUE_SIZE
     ReDim arrData(cbDataSize - 1)
'=======================================

Cheers
ping...
I could not find an inbox entry in Registry (Win 98). The only thing that I could is the HKEY_CURRENT_USER/Identities, which will show me all the available Identities to Outlook Express. Also there is User Name and Directory Name in the corresponding identities. But the Directory Name appears like encrypted in HexaDecimal or Decimal.

And, I hope find within the drives for dbx may not solve your problem, since hope, the dbx can be changed location to a network place also.

So, there should be some way in Outlook Application Model, to do this.

Hope it helps.
Avatar of ramsejp

ASKER

I'm using w2k.

My code says:

ValueName = String(MAX_KEY_SIZE, 0)
cbDataSize = MAX_VALUE_SIZE
ReDim arrData(cbDataSize)
Do

Should it the ReDim be:

ReDim arrData(cbDataSize - 1)

??

I'm changing it to what you have above Ark.
Avatar of ramsejp

ASKER

ok, that worked.  Now I just need to make it so I can run a function that returns that value...

Does anyone know if there is a difference in the way Outlook and Outlook Expresss stores the path??

thanks.
ramsejp,

I hope the path for files, though the default one is there, we can change it anytime. Like this in Outlook Express, if I am right:

Tools
  Options
    Maintenance Tab
       Store Folder button
          Change option

to change the directory of mails storage. Also you can view the directory where it is currently stored.
Works Beautifully!

Thanks.

Wileecoy.
Hi
ramsejp - more correct is ReDim arrData(cbDataSize - 1), but should be no prb with ReDim arrData(cbDataSize). The only correction is place this code inside Do...Loop.
So, correct code for this function:
Private Sub EnumRegValues(ByVal lKeyRoot As Long, ByVal sSubKey As String)
   Dim curidx As Long, ValueName As String, ValueValue As String
   Dim hKey As Long
   Dim lType As Long
   Dim arrData() As Byte
   Dim cbDataSize As Long
   If lStopSearch Then Exit Sub
   On Error GoTo ErrEnum
   If RegOpenKeyEx(lKeyRoot, sSubKey, 0, KEY_READ, hKey) Then Exit Sub
   Do
     ValueName = String(MAX_KEY_SIZE, 0)
     cbDataSize = MAX_VALUE_SIZE
     ReDim arrData(cbDataSize - 1)
     If RegEnumValue(hKey, curidx, ValueName, MAX_KEY_SIZE, ByVal 0&, lType, arrData(0), cbDataSize) <> ERROR_SUCCESS Then Exit Do
     If cbDataSize < 1 Then cbDataSize = 1
     ReDim Preserve arrData(cbDataSize - 1)
     ValueName = TrimNull(ValueName)
     If (mvarSearchFlags And VALUE_NAME) = VALUE_NAME Then
        If CheckMatching(ValueName) Then RaiseEvent SearchFound(RootKeyName(lKeyRoot), sSubKey & "\" & ValueName, GetRegData(lType, arrData), FOUND_IN_VALUE_NAME)
     End If
     If (mvarSearchFlags And VALUE_VALUE) = VALUE_VALUE Then
        ValueValue = TrimNull(GetRegData(lType, arrData))
        If CheckMatching(ValueValue) Then
           RaiseEvent SearchFound(RootKeyName(lKeyRoot), sSubKey & "\" & ValueName, ValueValue, FOUND_IN_VALUE_VALUE)
        End If
     End If
     curidx = curidx + 1
   Loop
ErrEnum:
   If Err Then lStopSearch = Err
   RegCloseKey hKey
End Sub

'Also, one more:
'Was
Public Sub DoSearch()
    If mvarRootKey <> HKEY_ALL Then
       Call EnumRegKeys(mvarRootKey, mvarSubKey)
    Else
......................

'Should be
Public Sub DoSearch()
    If mvarRootKey <> HKEY_ALL Then
       If (mvarSearchFlags And VALUE_NAME) = VALUE_NAME Or (mvarSearchFlags And VALUE_VALUE) = VALUE_VALUE Then
          Call EnumRegValues(mvarRootKey, mvarSubKey)
       End If
       Call EnumRegKeys(mvarRootKey, mvarSubKey)
    Else
......................

Reason - before it didn't enumerate values of passing key, only its subkeys and their values.
Unfortunatelly, my mail server is dawn for last two days and I can not send correction to FreeVBCode.

Cheers
ASKER CERTIFIED SOLUTION
Avatar of Ark
Ark
Flag of Russian Federation image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial