Print Page | Close Window

How to set Default Browser?

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Controls
Forum Description: Topics Related to Codejock Controls
URL: http://forum.codejock.com/forum_posts.asp?TID=13563
Printed Date: 23 November 2024 at 6:33am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: How to set Default Browser?
Posted By: shipwreck
Subject: How to set Default Browser?
Date 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



Replies:
Posted By: Oleg
Date Posted: 04 March 2009 at 3:41am
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


Posted By: shipwreck
Date Posted: 04 March 2009 at 5:27am
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


Posted By: dentor
Date Posted: 05 March 2009 at 2:37am
Originally posted by shipwreck shipwreck wrote:

I'm not familiar with MFC, any way to translate that into VB6?
 
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
 
http://support.microsoft.com/kb/299853/en-us - http://support.microsoft.com/kb/299853/en-us
 
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


Posted By: shipwreck
Date Posted: 05 March 2009 at 5:38am
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


Posted By: dentor
Date Posted: 05 March 2009 at 5:42am
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


Posted By: shipwreck
Date Posted: 05 March 2009 at 5:56am
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


Posted By: shipwreck
Date Posted: 10 December 2009 at 7:14am
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


Posted By: dentor
Date Posted: 10 December 2009 at 7:43am
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


Posted By: shipwreck
Date Posted: 10 December 2009 at 8:37am
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



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net