|
-
Jul 18th, 2006, 03:20 PM
#1
Thread Starter
Frenzied Member
[RESOLVED] Find Default Mail Client?
Is there a way I can test to see what the default mail client is?
Thanks
-
Jul 18th, 2006, 03:31 PM
#2
Re: Find Default Mail Client?
There might be some other way of doing it, but the first thing that hit me was to read the default string from the following key in the registry:
HKEY_CLASSES_ROOT\mailto\shell\open\command
-
Jul 19th, 2006, 07:23 AM
#3
Thread Starter
Frenzied Member
Re: Find Default Mail Client?
hmm not sure how to do that... any ideas?
-
Jul 19th, 2006, 11:17 AM
#4
Thread Starter
Frenzied Member
Re: Find Default Mail Client?
I guess this can't be done?
-
Jul 19th, 2006, 11:25 AM
#5
Re: Find Default Mail Client?
VB Code:
Private Declare Function RegCloseKey Lib "advapi32.dll" ( _
ByVal hKey As Long _
) As Long
Private Declare Function RegOpenKeyEx _
Lib "advapi32.dll" Alias "RegOpenKeyExA" ( _
ByVal hKey As Long, _
ByVal lpSubKey As String, _
ByVal ulOptions As Long, _
ByVal samDesired As Long, _
ByRef phkResult 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, _
ByRef lpType As Long, _
ByRef lpData As Any, _
ByRef lpcbData As Long _
) As Long
Private Const HKEY_CLASSES_ROOT As Long = &H80000000
Private Const REG_SZ As Long = 1
Private Const KEY_QUERY_VALUE = &H1
Private Const KEY_SET_VALUE = &H2
Private Const KEY_CREATE_SUB_KEY = &H4
Private Const KEY_ENUMERATE_SUB_KEYS = &H8
Private Const KEY_NOTIFY = &H10
Private Const KEY_CREATE_LINK = &H20
Private Const STANDARD_RIGHTS_ALL = &H1F0000
Private Const SYNCHRONIZE = &H100000
Private Const ERROR_SUCCESS As Long = 0&
Private Const KEY_ALL_ACCESS = ((STANDARD_RIGHTS_ALL Or KEY_QUERY_VALUE Or _
KEY_SET_VALUE Or KEY_CREATE_SUB_KEY Or KEY_ENUMERATE_SUB_KEYS _
Or KEY_NOTIFY Or KEY_CREATE_LINK) And (Not SYNCHRONIZE))
Public Function DefaultMail() As String
Dim hKey As Long
Dim sRetVal As String
Const MAX_PATH = 260&
If RegOpenKeyEx(HKEY_CLASSES_ROOT, "\mailto\shell\open\command\", _
0, KEY_ALL_ACCESS, hKey) = ERROR_SUCCESS Then
sRetVal = String(MAX_PATH + 1, vbNullChar)
If RegQueryValueEx(hKey, vbNullString, 0&, REG_SZ, _
ByVal sRetVal, MAX_PATH + 1) = ERROR_SUCCESS Then
DefaultMail = Left$(sRetVal, InStr(sRetVal, vbNullChar) - 1)
End If
Call RegCloseKey(hKey)
End If
End Function
You have to parse the return value of the DefaultMail function since it will return the path to the mail client including information on how to open it to mail someone... Just run it and you'll see what you need to do.
-
Jul 19th, 2006, 01:05 PM
#6
Thread Starter
Frenzied Member
Re: Find Default Mail Client?
Awesome, just need to figure out a good way to deal with the string. thanks alot for the help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|