Access the web page by calling a browser in vc6.0

Source: Internet
Author: User

Access the web page by calling a browser in vc6.0Author: Xiaohui

I. Preface

Many software works are added to the [help] menu to [access our homepage...]. Look at some of its implementation methods, and I think it is too complicated. During the design of "Xiaohui desktop Wang-jiujing method photo album series", Xiaohui successfully implemented [Access to Xiaohui's homepage...] in the program. (The fourth button in the right figure), the code segment is very simple, and now the setting idea and implementation code are attached. Xiaohui desktop Wang-jiujing method photo album is a small tool written by Xiaohui. Interested readers can download the source code (498kb) from here ).

Ii. Design Ideas

Xiao Hui's implementation method is: first, obtain the path name of the Windows default browser by reading the Registry, and then execute the default browser with parameters. The parameters included are the Homepage Address to be called. -- To put it bluntly, it is actually very simple.
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:

Iii. Code Design

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 );
}

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.