How to set Default Browser? |
Post Reply |
Author | |
shipwreck
Senior Member Joined: 18 April 2008 Location: United States Status: Offline Points: 308 |
Post Options
Thanks(0)
Posted: 03 March 2009 at 7:14am |
Hello Codejock Community!
I have question: I'm working on a web browser using your web browser control, and I was wondering how can I implement the feature "Set as default browser" like alot of other web browsers do? Please help out. lol. |
|
Product: Xtreme Suite Pro (Active-X), Version 15.3.1
Platform: Windows 7 Ultimate SP1 (64Bit) & Windows XP Mode SP3 (32Bit) Language: Visual Basic 6.0 SP6 |
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Hi,
Here code from our MFC StylerBrowser sample...
void SetDefault(LPCTSTR lpszKey, BOOL = TRUE)
{ HKEY hKey, hSubKey, hSubKey2; if(RegOpenKey(HKEY_CLASSES_ROOT, lpszKey, &hKey) == ERROR_SUCCESS)
{ DWORD dwRes; TCHAR lpszModule[_MAX_PATH]; HINSTANCE hInstance = AfxGetInstanceHandle(); RegSetValueEx(hKey, _T(""), NULL, REG_SZ, (LPBYTE)(_T("Styler")), 7 * sizeof(TCHAR)); //open RegCreateKeyEx(hKey, _T("open"), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hSubKey, &dwRes); RegCreateKeyEx(hSubKey, _T("command"), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hSubKey2, &dwRes); if (GetModuleFileName(hInstance, lpszModule + 1, _MAX_PATH)) { *lpszModule = _T('\"'); #if (_MSC_VER > 1310) // VS2005 _tcscat_s(lpszModule, _MAX_PATH, _T("\" \"%1\"")); #else _tcscat(lpszModule, _T("\" \"%1\"")); #endif RegSetValueEx(hSubKey2, _T(""), NULL, REG_SZ, (LPBYTE)(lpszModule), ((int)_tcsclen(lpszModule) + 1) * sizeof(TCHAR)); } RegCloseKey(hSubKey); RegCloseKey(hSubKey2); //myie RegCreateKeyEx(hKey, _T("Styler"), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hSubKey, &dwRes); RegCloseKey(hKey); RegCreateKeyEx(hSubKey, _T("command"), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwRes); if (GetModuleFileName(hInstance, lpszModule+1, _MAX_PATH)) { *lpszModule = _T('\"'); #if (_MSC_VER > 1310) // VS2005 _tcscat_s(lpszModule, _MAX_PATH, _T("\" \"%1\"")); #else _tcscat(lpszModule, _T("\" \"%1\"")); #endif RegSetValueEx(hKey, _T(""), NULL, REG_SZ, (LPBYTE)(lpszModule), ((int)_tcsclen(lpszModule) + 1) * sizeof(TCHAR)); } RegCloseKey(hSubKey); RegCloseKey(hKey); } }
void CMainFrame::OnSetDefault()
{ SetDefault(_T("htmlfile\\shell")); SetDefault(_T("InternetShortcut\\shell")); SetDefault(_T("mhtmlfile\\shell")); SetDefault( _T("http\\shell")); SetDefault( _T("https\\shell")); SetDefault( _T("file\\shell")); SetDefault( _T("ftp\\shell")); } |
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
shipwreck
Senior Member Joined: 18 April 2008 Location: United States Status: Offline Points: 308 |
Post Options
Thanks(0)
|
I'm not familiar with MFC, any way to translate that into VB6?
|
|
Product: Xtreme Suite Pro (Active-X), Version 15.3.1
Platform: Windows 7 Ultimate SP1 (64Bit) & Windows XP Mode SP3 (32Bit) Language: Visual Basic 6.0 SP6 |
|
dentor
Senior Member Joined: 30 November 2005 Location: France Status: Offline Points: 102 |
Post Options
Thanks(0)
|
Hello Shipwreck,
Here's a link to a microsoft webpage that explain with vb6 code the way to :
Modify the default Web browser and e-mail client programmatically in Windows XP
Hoping it will be useful for you.
|
|
Product: Xtreme SuitePro (ActiveX) version 13.0.0
Platform: Windows XP (32bit) - SP 3 Language: Visual Basic 6.0 SP 6 |
|
shipwreck
Senior Member Joined: 18 April 2008 Location: United States Status: Offline Points: 308 |
Post Options
Thanks(0)
|
Seems to be what I was looking for.
But, will this function work on Vista also? or is there another for that? |
|
Product: Xtreme Suite Pro (Active-X), Version 15.3.1
Platform: Windows 7 Ultimate SP1 (64Bit) & Windows XP Mode SP3 (32Bit) Language: Visual Basic 6.0 SP6 |
|
dentor
Senior Member Joined: 30 November 2005 Location: France Status: Offline Points: 102 |
Post Options
Thanks(0)
|
I think there is no difference for the Vista version.
|
|
Product: Xtreme SuitePro (ActiveX) version 13.0.0
Platform: Windows XP (32bit) - SP 3 Language: Visual Basic 6.0 SP 6 |
|
shipwreck
Senior Member Joined: 18 April 2008 Location: United States Status: Offline Points: 308 |
Post Options
Thanks(0)
|
Alrighty, I'll test to see.
|
|
Product: Xtreme Suite Pro (Active-X), Version 15.3.1
Platform: Windows 7 Ultimate SP1 (64Bit) & Windows XP Mode SP3 (32Bit) Language: Visual Basic 6.0 SP6 |
|
shipwreck
Senior Member Joined: 18 April 2008 Location: United States Status: Offline Points: 308 |
Post Options
Thanks(0)
|
Okay. Has anyone actually found a way to detect the default browser and how to change it using VB6?
|
|
Product: Xtreme Suite Pro (Active-X), Version 15.3.1
Platform: Windows 7 Ultimate SP1 (64Bit) & Windows XP Mode SP3 (32Bit) Language: Visual Basic 6.0 SP6 |
|
dentor
Senior Member Joined: 30 November 2005 Location: France Status: Offline Points: 102 |
Post Options
Thanks(0)
|
Hello Shipwreck,
Default Web browser settings is stored in registry and you can find the registry entry for your default browser at :
HKEY_LOCAL_MACHINE\Software\Clients\StartMenuInternet Default value indicate the default web browser.
|
|
Product: Xtreme SuitePro (ActiveX) version 13.0.0
Platform: Windows XP (32bit) - SP 3 Language: Visual Basic 6.0 SP 6 |
|
shipwreck
Senior Member Joined: 18 April 2008 Location: United States Status: Offline Points: 308 |
Post Options
Thanks(0)
|
Long time no talk eh' dentor? How have you been?
Also, I need it to be able to recognize that on XP Vista, and Windows 7. Do you think you can give me a sample or a code listing? I'd really appreciate it. Like I said earlier, I'm still completely lost on this one. lol. |
|
Product: Xtreme Suite Pro (Active-X), Version 15.3.1
Platform: Windows 7 Ultimate SP1 (64Bit) & Windows XP Mode SP3 (32Bit) Language: Visual Basic 6.0 SP6 |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |