[Zz] use Windows default browser to open a webpage

Source: Internet
Author: User

The default key value of the windows browser is 'HKEY _ classes_root/htmlfile/Shell/Open/command' in the registry '.
The implementation code is as follows:

Void cxh1_dlg: onbtnweb ()
{
Hkey hkroot, hsubkey; // defines the root keyword and subkeyword of the Registry.
Char valuename [256];
Unsigned char datavalue [256];
Unsigned long cbvaluename = 256;
Unsigned long cbdatavalue = 256;
Char shellchar [256]; // defines the command line
DWORD dwtype;

// Open the Registry root keyword
If (regopenkey (hkey_classes_root, null, & hkroot) = error_success)
{
// Open the subkeyword
If (regopenkeyex (hkroot,
"Htmlfile // shell // open // command ",
0,
Key_all_access,
& Hsubkey) = error_success)
{
// Read the registry and obtain the command line of the default browser
Regenumvalue (hsubkey,
0,
Valuename,
& Cbvaluename,
Null,
& Dwtype,
Datavalue,
& Cbdatavalue );
// Call parameter (Home Address) Assignment
Strcpy (shellchar, (char *) datavalue );
Strcat (shellchar, "www.neaase.net /~ Xiaohui ");
// Start the browser
Winexec (shellchar, sw_show );

}
Else
MessageBox ("An error occurred while opening the web browser! "," Error ", mb_ OK );
}
Else
MessageBox ("An error occurred while opening the web browser! "," Error ", mb_ OK );
// Close the registry
Regclosekey (hsubkey );
Regclosekey (hkroot );
}

 

Related Article

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.