Outlook vs Outlook Express

  • Thread starter Thread starter MariaG
  • Start date Start date
M

MariaG

Does anyone know the code to tell if a user is using
Outlook or Outlook Express from within Excel's VBA modules?

I am sure there is something in the registry keys - would
that method okay?

Many thanks in advance.

MariaG
 
does this get you on your way?

Option Explicit


'ADVAPI32
Private Declare Function RegOpenKey Lib "advapi32.dll" _
Alias "RegOpenKeyA" (ByVal hKey As Long, _
ByVal lpSubKey As String, phkResult As Long) As Long

Private Declare Function RegCloseKey Lib "advapi32.dll" ( _
ByVal hKey As Long) As Long

Private Declare Function RegQueryValueEx Lib "advapi32.dll" _
Alias "RegQueryValueExA" (ByVal hKey As Long, _
ByVal lpValueName As String, ByVal lpReserved As Long, _
lpType As Long, lpData As Any, lpcbData As Long) As Long


'***************************************************************
'* REGISTRY FUNCTIONS *
'***************************************************************

Function GetRegString(hKey As Long, sPath As String, _
sValue As String) As String
Dim lRet&, sRet$
RegOpenKey hKey, sPath, lRet
If lRet <> 0 Then
sRet = GetRegQuery(lRet, sValue)
RegCloseKey lRet
GetRegString = sRet
Else
GetRegString = "error"
End If
End Function

Private Function GetRegQuery(ByVal hKey As Long, _
ByVal sValue As String) As String
Dim lRet&, sBuf$, cb&
cb = 256
sBuf = Space(cb)
lRet = RegQueryValueEx(hKey, sValue, 0, 0, ByVal sBuf, cb)
If lRet = 0 Then
'Remove trailing chr(0)
If InStr(sBuf, vbNullChar) > 0 Then sBuf = Left(sBuf, _
InStr(sBuf, vbNullChar) - 1)
'Then trim spaces
GetRegQuery = Trim(sBuf)
End If
End Function


Function GetMailer() As String
Const HKCR = &H80000000
Dim sReg$

sReg = GetRegString(HKCR, "mailto\shell\open\command", "")
If InStr(sReg, "msimn.exe") Then
GetMailer = "Outlook Express"
ElseIf InStr(sReg, "outlook.exe") Then
GetMailer = "Outlook"
ElseIf InStr(sReg, "hmmapi.dll") Then
GetMailer = "Hotmail"
Else
GetMailer = "Unknown : " & sReg
End If

End Function




keepITcool

< email : keepitcool chello nl (with @ and .) >
< homepage: http://members.chello.nl/keepitcool >
 
keepITcool,

yes it does.
Thank you so much!!

MariaG



'=================================================
Subject: Re: Outlook vs Outlook Express
From: "keepITcool" <[email protected]> Sent:
9/25/2004 5:07:58 AM




does this get you on your way?

Option Explicit


'ADVAPI32
Private Declare Function RegOpenKey Lib "advapi32.dll" _
Alias "RegOpenKeyA" (ByVal hKey As Long, _
ByVal lpSubKey As String, phkResult As Long) As Long

Private Declare Function RegCloseKey Lib "advapi32.dll" ( _
ByVal hKey As Long) As Long

Private Declare Function RegQueryValueEx
Lib "advapi32.dll" _
Alias "RegQueryValueExA" (ByVal hKey As Long, _
ByVal lpValueName As String, ByVal lpReserved As Long,
_
lpType As Long, lpData As Any, lpcbData As Long) As
Long


'**********************************************************
*****
'* REGISTRY
FUNCTIONS *
'**********************************************************
*****

Function GetRegString(hKey As Long, sPath As String, _
sValue As String) As String
Dim lRet&, sRet$
RegOpenKey hKey, sPath, lRet
If lRet <> 0 Then
sRet = GetRegQuery(lRet, sValue)
RegCloseKey lRet
GetRegString = sRet
Else
GetRegString = "error"
End If
End Function

Private Function GetRegQuery(ByVal hKey As Long, _
ByVal sValue As String) As String
Dim lRet&, sBuf$, cb&
cb = 256
sBuf = Space(cb)
lRet = RegQueryValueEx(hKey, sValue, 0, 0, ByVal sBuf,
cb)
If lRet = 0 Then
'Remove trailing chr(0)
If InStr(sBuf, vbNullChar) > 0 Then sBuf = Left(sBuf, _
InStr(sBuf, vbNullChar) - 1)
'Then trim spaces
GetRegQuery = Trim(sBuf)
End If
End Function


Function GetMailer() As String
Const HKCR = &H80000000
Dim sReg$

sReg = GetRegString
(HKCR, "mailto\shell\open\command", "")
If InStr(sReg, "msimn.exe") Then
GetMailer = "Outlook Express"
ElseIf InStr(sReg, "outlook.exe") Then
GetMailer = "Outlook"
ElseIf InStr(sReg, "hmmapi.dll") Then
GetMailer = "Hotmail"
Else
GetMailer = "Unknown : " & sReg
End If

End Function




keepITcool

< email : keepitcool chello nl (with @ and .) >
< homepage: http://members.chello.nl/keepitcool >


MariaG said:
Does anyone know the code to tell if a user is using
Outlook or Outlook Express from within Excel's VBA modules?

I am sure there is something in the registry keys - would
that method okay?

Many thanks in advance.

MariaG

..
 
Hello,

It does not work the way I expected. I get the following restult from the
GetMailer function;

Unknown : "C:\Program\MICROS~2\Office\OUTLOOK.EXE" -c IPM.Note /m "%1"

I was expecting "Outlook"
 
that's only a capitalization problem...

change to
sReg = LCASE$(GetRegString(HKCR, "mailto\shell\open\command", ""))
If InStr(sReg, "msimn.exe") Then



keepITcool

< email : keepitcool chello nl (with @ and .) >
< homepage: http://members.chello.nl/keepitcool >


=?Utf-8?B?VGhvcg==?= wrote in message
 
Thanks a lot!

keepITcool said:
that's only a capitalization problem...

change to
sReg = LCASE$(GetRegString(HKCR, "mailto\shell\open\command", ""))
If InStr(sReg, "msimn.exe") Then



keepITcool

< email : keepitcool chello nl (with @ and .) >
< homepage: http://members.chello.nl/keepitcool >


=?Utf-8?B?VGhvcg==?= wrote in message
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top