MFC opens Web page with default browser

Source: Internet
Author: User
MFC/////Open Web page with default browser//if default browser is not found, the default is open with IE on void OpenURL (const CString & OpenURL) {if (OpenURL = = "") Retu
    Rn   Hkey Hkroot, Hsubkey;
    Registry root keyword and sub-keyword CString valuename;
    unsigned char Datavalue[max_path];
    unsigned long cbvaluename = MAX_PATH;    
unsigned long cbdataname = MAX_PATH;
    <pre name= "code" class= "CPP" ><pre name= "code" class= "CPP" > CString shellchar;//define command line DWORD dwtype; Open the Registry root keyword if (regopenkey (hkey_classes_root,null,&hkroot) = = ERROR_SUCCESS) {//Open the Child keyword if (Re
        Gopenkeyex (hkroot,l "Htmlfile\\shell\\open\\command", 0, key_all_access, &hsubkey) = = ERROR_SUCCESS)            {
. RegEnumValue (Hsubkey, 0, (LPWSTR) Valuename.getbuffer (MAX_PATH), &cbvaluename, NULL, &AMP;DW
             Type, DataValue, &cbdatavalue);
             Valuename.releasebuffer ();
             Call parameter Assignment Shellchar = (char *) DataValue;
 if (Shellchar = = "" ")            {ShellExecute (NULL, L "open", (LPWSTR) Openurl.getbuffer (MAX_PATH), NULL, NULL, SW_SHOWNORMAL);
             Openurl.releasebuffer ();
                 else {Shellchar = Shellchar + OpenURL;
                 WinExec ((LPCSTR) Shellchar.getbuffer (MAX_PATH), sw_show);
             Shellchar.releasebuffer ();
             } else {RegCloseKey (hsubkey);             RegCloseKey (Hroot); <pre name= "code" class= "CPP" ><pre name= "code" class= "CPP" > ShellExecute (NULL, L "open", (LPWSTR) Open
Url.getbuffer (MAX_PATH), NULL, NULL, SW_SHOWNORMAL); <pre name= "code" class= "CPP" ><pre name= "code" class= "CPP" ><pre name= "code" class= "CPP" > Open Url.releasebuffer ();
}
}


}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.