Windows opens a batch of pages in a breath

Source: Internet
Author: User

Storm

Mail: [Email protected]

This blog address:http://www.cnblogs.com/fengbohello/p/4374450.html

1. Core function description

Core function: ShellExecute

The function prototypes are as follows:

ShellExecute (HWND hwnd,//parent Window handle (for example, Null,handle, etc.)LPCSTR lpoperation,//type of operation (for example: "Open") * Double quotation marks are added in EnglishLPCSTR Lpfile,//the file or path to be manipulatedLPCSTR Lpparameters,//Specifies the parameter to pass when Lpoperation is "explore", usually set to nullLPCSTR Lpdirectory,//Specify a default directory, usually set to nullINT nShowCmd//How the file is opened, in the usual way or maximized or minimized, typically sw_shownormal)

Detailed documentation on the ShellExecute function in Baidu Encyclopedia:http://baike.baidu.com/link?url= 9FY8BHOJHZCPPFXYWFVFMAL53JMONHC4PKMDYD7JMD7K5BJDPC4XU9DAD59U0W_-ZLO-R8KC_ONFE5LGCFBVTQ and another blog Park blog:http ://www.cnblogs.com/xubin0523/archive/2012/11/01/2749729.html

2. Program Description

1) first read the same directory with the program default file, Sitepage.txt file, this file content is to open the address of the Web page, one address per line.

2) If there is no default file, then the error

3) If you want to open a non-default file, drag the file with the mouse to the program can be

3. Code

#include <windows.h>#include<shellapi.h>#include<stdio.h>#include<vector>#include<string>using namespacestd;intLOADADDR (vector<string> & Vecaddr,stringstrFileName) {    if(Strfilename.empty ()) {printf ("file [%s] does not exist \ n", Strfilename.c_str ()); return-1; } FILE* fp =NULL; if(fp = fopen (Strfilename.c_str (),"R")) ==NULL) {printf ("failed to open file [%s], please check if file exists \ n", Strfilename.c_str ()); return-1; }    Charszaddr[1024x768] = {0};  while(Fgets (SZADDR,1023, FP)) {        stringSTRADDR =szaddr;    Vecaddr.push_back (STRADDR);    } fclose (FP); return 0;}intOpenpage (vector<string> &vecaddr) {    inti =0; intIsize =vecaddr.size ();  for(i =0; i < isize; i++)    {        Const Char* Paddr =Vecaddr[i].c_str (); ShellExecute (NULL,"Open", paddr, NULL, NULL, SW_SHOWNORMAL); }    return 0;}intMainintargcChar*argv[]) {    stringstrFileName; if(ARGC <2) {strFileName="Sitepage.txt"; }    Else{strFileName=string(argv[1]); } Vector<string>vecaddr; if(0!=loadaddr (vecaddr, strFileName)) {printf ("Press ENTER (enter) to exit the program \ n");        GetChar (); return 0; }    if(0!=openpage (VECADDR)) {printf ("Press ENTER (enter) to exit the program \ n");        GetChar (); return 0; }    return 0;}

4. Binary Address of program

Baidu Network disk:http://pan.baidu.com/s/1CVx4i

Windows opens a batch of pages in a breath

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.