 |
|
 |
Correct key to get default browser is as follow -
HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet
|
|
|
|
 |
|
 |
Hi, there,
I used the code of "Re: Improved browser path detection" third, and when Safari as default explorer, this code could open the Safari Explorer, but the weblink address dose not match what I want. Need your help.
Thanks,
Daniel
A lucky fish.
|
|
|
|
 |
|
 |
its giving following error... do u have modified code?
please help me...
'ShellExecute' : is not a member of '`global namespace''
|
|
|
|
 |
|
|
 |
|
 |
Hi!I used your code in a simple application (vc++.net 2005)(a Win32 with support of MFC).I made a setup(InstallShield 9) and..When I try to execute the setup on some other computers(other than mine)..It does'nt work properly..I mean when it is supposed to open a browser (IE or MOZILLA)(I have applied the modified version..),nothing happens...no difference in the installed operating system...I don't no the issue.. I'll appreciate your comments on problem ...tnx!
|
|
|
|
 |
|
 |
hi
how to use cURL library in c#?
thanks
|
|
|
|
 |
|
 |
Not sure - I don't use C#. div style='display:none;' class='CPhogPost'>
Kicking squealing Gucci little piggy.
|
|
|
|
 |
|
 |
Hi,
did anyone manage to tweak firefox (1.0.7, WinXPSP2) to open the URL in a NEW WINDOW?
The Docu on MozillaZine lists a "-new" switch to do so. However it does not seem to work in conjunction with a supplied URL i.e. "-url" switch. So you have to call ShellExecute twice; first with the "-new" argument to open a new window and second with "-url http://[destinationpage]"!
It is really annoying to consider every version of Firefox seperatly in the code !
Bye
Semmel
|
|
|
|
 |
|
 |
How could we upgrade this code for opening a URL in a new window with no toolbar, scrollbar...?
Thanks.
|
|
|
|
 |
|
 |
I am also looking for open URL browser with out Toolbar. I am currently working on the Online Help. I would like to have this feature. Please help me.
Mike
|
|
|
|
 |
|
 |
I think this might be a bit better way of extracting the path from the registry string. It seems to work with IE6, Netscape, Firefox, and Opera. (The only ones I have installed on my system). I also rewrote it a bit for those who, like me, don't use MFC. <pre> #pragma once //to open URL in new browser window //Declare CURL curl; //Call curl.Open(_T("http://wwww.mozilla.org")); //This macro compares three pointers (presumably string pointers) and returns / /the lowest (first) one #define GetFirstPointer(p1,p2,p3) (( (p1<p2||!p2)&&(p1<p3||!p3)&&p1>0)?(p1) ((p2<p3||!p3)&&(p2<p1||!p1)&&p2>0)?(p2) p3>0)?(p3) p1>0)?(p1):(p2))))) class CURL { private: // The default browser char* m_strBrowser; public: CURL() //constructor { m_strBrowser = new char[1]; *m_strBrowser = 0; } ~CURL() //destructor { delete [] m_strBrowser; m_strBrowser = 0; } // Open a URL void Open(LPCTSTR lpszURL, bool bNewWindow = true) { if (bNewWindow) ::ShellExecute(NULL, NULL, GetBrowser(), lpszURL, NULL, SW_SHOWNORMAL); else ::ShellExecute(NULL, NULL, lpszURL, NULL, NULL, SW_SHOWNORMAL); } // Get the default browser from the registry LPCTSTR GetBrowser(void) { // Have we already got the browser? DWORD cbData = 0; HKEY hKey = NULL; if (!(*m_strBrowser) && ::RegOpenKeyEx(HKEY_CLASSES_ROOT, _T("http\\shell\\open\\command"), 0, KEY_READ, &hKey) == ERROR_SUCCESS && ::RegQueryValueEx(hKey, NULL, NULL, NULL, NULL, &cbData) == ERROR_SUCCESS && cbData > 0) { // Allocate a suitable buffer TCHAR* psz = new TCHAR [cbData+1]; // Success? if (psz != NULL && ::RegQueryValueEx(hKey, NULL, NULL,NULL, (LPBYTE)psz, &cbData) == ERROR_SUCCESS) { // Success! if (m_strBrowser) delete [] m_strBrowser; m_strBrowser = new char[strlen(psz)+1]; strcpy(m_strBrowser,psz); } if (psz) delete [] psz; } if (hKey) ::RegCloseKey(hKey); // Do we have the browser? if (*m_strBrowser) { // Strip the full path from the string // C:\PROGRAM FILES\NETSCAPE\COMMUNICATOR\PROGRAM\NETSCAPE.EXE -h "%1" char* ppath = _tcsspnp(m_strBrowser,"\\\" "); //find first char not of these char* pbeg = GetFirstPointer(strpbrk(m_strBrowser,"\""), strpbrk(m_strBrowser,"\\"),strpbrk(m_strBrowser," ")); if (pbeg > ppath) pbeg = ppath; char* pend = pbeg; char* pqoute = pbeg; while (pqoute && (pqoute = strpbrk(pqoute,"\\"))) pend = pqoute++; //find last slash pend = strpbrk(pend," \""); //find last space or " after last slash while (*pbeg == '\"' && *pend == ' ') //if starting qoute and stopped at space, find next char pend++; if (*pbeg=='\"' || *pbeg==' ') pbeg++; //move past leading qoutes and leading spaces char tmpstr[MAX_PATH+1] = {0}; strncpy(tmpstr,pbeg,pend-pbeg); if (strpbrk(tmpstr," ")) //determine if there are spaces in the name sprintf(m_strBrowser,"\"%s\"",tmpstr); //if there are spaces, add qoutes else strcpy(m_strBrowser,tmpstr); *tmpstr = 0; } // Done return m_strBrowser; } }; </pre> M. N. Jackson
|
|
|
|
 |
|
 |
Where is "GetFirstPointer" defined?
|
|
|
|
 |
|
 |
Sorry, forgot to include this define, It is something I use in a lot of my code. There is probably a lot of better ways to do this, I wrote it a long time ago and never have bothered to update it to a more efficient system. #define GetFirstPointer(p1,p2,p3) (( (p1<p2||!p2)&&(p1<p3||!p3)&&p1>0)?(p1) : ( ((p2<p3||!p3)&&(p2<p1||!p1)&&p2>0)?(p2) : ((p3>0)?(p3) : ((p1>0)?(p1) : (p2)))))
|
|
|
|
 |
|
 |
I've slightly fixed code to make it Unicode compatible (all chars were replaced to TCHARS, and all non-unicode functions were changed to TCHAR.h equivalents).
Dima
www.mmexplorer.com
#pragma once
//to open URL in new browser window
//Declare CURL curl;
//Call curl.Open(_T("http://wwww.mozilla.org"));
//This macro compares three pointers (presumably string pointers) and returns
//the lowest (first) one
#define GetFirstPointer(p1,p2,p3) (( (p10)?(p1):( ((p20)?(p2):((p3>0)?(p3):((p1>0)?(p1):(p2)))))
class CURL
{
private:
// The default browser
TCHAR* m_strBrowser;
public:
CURL() //constructor
{
m_strBrowser = new TCHAR[1];
*m_strBrowser = 0;
}
~CURL() //destructor
{
delete [] m_strBrowser;
m_strBrowser = 0;
}
// Open a URL
void Open(LPCTSTR lpszURL, bool bNewWindow = true)
{
if (bNewWindow)
::ShellExecute(NULL, NULL, GetBrowser(), lpszURL, NULL, SW_SHOWNORMAL);
else
::ShellExecute(NULL, NULL, lpszURL, NULL, NULL, SW_SHOWNORMAL);
}
// Get the default browser from the registry
LPCTSTR GetBrowser(void)
{
// Have we already got the browser?
DWORD cbData = 0;
HKEY hKey = NULL;
if (!(*m_strBrowser) &&
::RegOpenKeyEx(HKEY_CLASSES_ROOT, _T("http\\shell\\open\\command"),
0, KEY_READ, &hKey) == ERROR_SUCCESS &&
::RegQueryValueEx(hKey, NULL, NULL, NULL, NULL, &cbData)
== ERROR_SUCCESS && cbData > 0)
{
// Allocate a suitable buffer
TCHAR* psz = new TCHAR [cbData+1];
// Success?
if (psz != NULL &&
::RegQueryValueEx(hKey, NULL, NULL,NULL,
(LPBYTE)psz, &cbData) == ERROR_SUCCESS)
{
// Success!
if (m_strBrowser) delete [] m_strBrowser;
m_strBrowser = new TCHAR[_tcsclen(psz)+1];
_tcscpy(m_strBrowser, psz);
}
if (psz) delete [] psz;
}
if (hKey) ::RegCloseKey(hKey);
// Do we have the browser?
if (*m_strBrowser)
{
// Strip the full path from the string
// C:\PROGRAM FILES\NETSCAPE\COMMUNICATOR\PROGRAM\NETSCAPE.EXE -h "%1"
TCHAR* ppath = _tcsspnp(m_strBrowser, _T("\\\" ")); //find first char not of these
TCHAR* pbeg = GetFirstPointer(_tcspbrk(m_strBrowser, _T("\"")),
_tcspbrk(m_strBrowser, _T("\\")),_tcspbrk(m_strBrowser, _T(" ")));
if (pbeg > ppath) pbeg = ppath;
TCHAR* pend = pbeg;
TCHAR* pqoute = pbeg;
while (pqoute && (pqoute = _tcspbrk(pqoute, _T("\\")))) pend = pqoute++; //find last slash
pend = _tcspbrk(pend, _T(" \"")); //find last space or " after last slash
while (*pbeg == _T('\"') && *pend == _T(' ')) //if starting qoute and stopped at space, find next char
pend++;
if (*pbeg==_T('\"') || *pbeg==_T(' ')) pbeg++; //move past leading qoutes and leading spaces
TCHAR tmpstr[MAX_PATH+1] = {0};
_tcsncpy(tmpstr,pbeg,pend-pbeg);
if (_tcspbrk(tmpstr, _T(" "))) //determine if there are spaces in the name
_stprintf(m_strBrowser,_T("\"%s\""),tmpstr); //if there are spaces, add qoutes
else
_tcscpy(m_strBrowser,tmpstr);
*tmpstr = 0;
}
// Done
return m_strBrowser;
}
};
|
|
|
|
 |
|
 |
an easier way will be to use:
PathUnquoteSpaces and PathStripPath
// Do we have the browser?
if (*m_strBrowser)
{
PathUnquoteSpaces(m_strBrowser);
PathStripPath(m_strBrowser);
}
|
|
|
|
 |
|
 |
Firefox and IE7 create more complex registry values, such as:
"C:\Program Files\Mozilla Firefox\firefox.exe" -requestPending -osint -url "%1"
The double pair of quotes confuses the code in this project because it looks for the first and the last quote:
int nStart = m_strBrowser.Find('"');
int nEnd = m_strBrowser.ReverseFind('"');
A better way to do this is to look for the first and SECOND quote:
int nStart = m_strBrowser.Find('"');
int nEnd = m_strBrowser.Find('"', nStart+1);
I've found this to work for IE6, IE7 and FF3.
|
|
|
|
 |
|
 |
In my tests Opera 7.51 and Mozilla 1.72 are always opening
URLs in separate tabs(windows), whatever I call consecutively:
either
ShellExecute(hWnd,NULL,lpszURL,NULL,NULL,SW_SHOWNORMAL);
or
ShellExecute(NULL, NULL, GetBrowser(), lpszURL, NULL, SW_SHOWNORMAL);
So, can somone tell me how did you make Opera 7.51 and Mozilla 1.72 open URLs in the same window, anyway, by calling consecutively ShellExecute in either way?
I tested on my computer running. Windows 98
|
|
|
|
 |
|
 |
I need to know the executable of an AVI file. Then what to write at the place of _T("http\\shell\\open\\command". I have used FindExecutable() API, but it does not give the full path of Media player9.So plz help me to identify the Regestry value of .avi file.
|
|
|
|
 |
|
 |
For the 1% of us out there....
if (nStart >= 0 && nEnd >= 0)
{
m_strBrowser.MakeUpper();
int dFoundFireFox = m_strBrowser.Find("FIREFOX.EXE");
if(dFoundFireFox < 0) // IE
{
// Are they the same?
if (nStart != nEnd)
{
// Get the full path
m_strBrowser = m_strBrowser.Mid(nStart + 1, nEnd - nStart - 1);
}
}
else // FireFox
m_strBrowser = m_strBrowser.Left(m_strBrowser.Find(" -URL"));
}
Edit : Typo changed -url to -URL
I feel like I'm diagonally parked in a parallel universe
Jerry Davis
http://www.astad.org http://www.jvf.co.uk
|
|
|
|
 |
|
 |
Thanks! I use Firefox too but I had totally forgotten about this article!
The Rob Blog
|
|
|
|
 |
|
 |
else // FireFox
m_strBrowser = m_strBrowser.Left(m_strBrowser.Find(" -URL"));
}
this works great except for Netscape 4.8 (though I haven't check every version), the path contains "-h" instead of "-URL"
I think a more general solution would be
int nStart = m_strBrowser.Find('"');
int nEnd = m_strBrowser.ReverseFind('"');
if (nStart>=0 && nEnd>=0)
{
m_strBrowser.MakeUpper();
if(nEnd-nStart>3)
{ // IE & Opera, their pathnames do not include "%1"
m_strBrowser = m_strBrowser.Mid(nStart + 1, nEnd - nStart - 1);
}
else // FireFox & Netscape & Mozilla
{
m_strBrowser = m_strBrowser.Left(m_strBrowser.Find(".EXE")+4);
}
|
|
|
|
 |
|
 |
Hi,
Could anyone send me a dll I could open a new window/url with without being blocked by the google toolbar ?
I could write a registry key, passing the url.
I have a sweet code, works on opera, but not on IE
(for info, it's like the "search with google" feature in opera, but with maps)
|
|
|
|
 |
|
 |
doesn't work in BCB6, can you make a version of the url header that will work with it ?
|
|
|
|
 |
|
 |
I don't have BCB6 nor do I want it! Any chance of some more information on this? Does BCB6 actually support ATL/WTL (and have a CString class?).
The Rob Blog
|
|
|
|
 |
|
 |
Rather than read the registry for paths use FindExecutable():
char browser_path[MAX_PATH];
ZeroMemory(browser_path,sizeof(browser_path));
if(FindExecutable("C:\\temp\\t.htm","",browser_path)<(HINSTANCE)32){
AfxMessageBox("Couldn't find default browser.");
return;
}
|
|
|
|
 |