Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

run firefox from c++ program

dule88dule88 Member Posts: 9
How can I open web address from C++ program? I can open firefox with function WinExec("C:\Program Files\Mozilla Firefox\firefox", SW_SHOWNORMAL) but if I try to open address directly with WinExec("http://www.google.com", SW_SHOWNORMAL) it doesn't work.
And is there a way to start download from my c++ program, if I have a rapidshare link or something like that can I write a code that will open that address and start downloading (the problem may be the window that opens and you need to click save file) ?

Comments

  • furbearntroutfurbearntrout Member Posts: 1
    : How can I open web address from C++ program? I can open firefox with
    : function WinExec("C:\Program Files\Mozilla Firefox\firefox",
    : SW_SHOWNORMAL) but if I try to open address directly with
    : WinExec("http://www.google.com", SW_SHOWNORMAL) it doesn't work.
    : And is there a way to start download from my c++ program, if I have
    : a rapidshare link or something like that can I write a code that
    : will open that address and start downloading (the problem may be the
    : window that opens and you need to click save file) ?
    :
    try
    [code]WinExec("C:\Program Files\Mozilla Firefox\firefox -u 'http://www.google.com'", SW_SHOWNORMAL)[/code]
    we need to tell firefox to open the url (-u) for us. IFACT, WinExec only opens programs, not urls
  • dule88dule88 Member Posts: 9
    Thanks, I have learned to open url with my program. But there is another problem. To be precise I want to tell my program to open certain rapidshare link and click on free user button :) ! I can open link but what then... I tried to find the link to that button but I can't. How can i make my program do that?
  • Malcolm_McLeanMalcolm_McLean Member Posts: 254 ✭✭
    : Thanks, I have learned to open url with my program. But there is
    : another problem. To be precise I want to tell my program to open
    : certain rapidshare link and click on free user button :) ! I can
    : open link but what then... I tried to find the link to that button
    : but I can't. How can i make my program do that?
    :
    [code]
    #include
    #include

    void abc(char *p)
    {
    char *ptr;

    p[1000] = 0;
    ptr = strchr(p, "

    ");
    if(ptr)
    ptr[4] =0;
    printf("%s", p);
    }

    int main(void)
    {

    WSADATA ws;
    int d;
    char aa[1001];
    struct sockaddr_in a;
    SOCKET s;
    int ii;
    HOSTENT *he;
    int i;

    char ipaddr[64];
    d = WSAStartup(0x101,&ws);
    he = gethostbyname("www.personal.leeds.ac.uk");
    if(he == 0)
    {
    printf("bad host
    ");
    goto abortme;
    }
    for(i=0;he->h_addr_list[i];i++)
    {
    sprintf(ipaddr,"%d.%d.%d.%d", (unsigned char) he->h_addr_list[i][0], (unsigned char) he->h_addr_list[i][1],
    (unsigned char) he->h_addr_list[i][2], (unsigned char) he->h_addr_list[i][3]);
    }
    printf("%s
    ", ipaddr);
    s = socket(AF_INET,SOCK_STREAM,0);
    sprintf(aa," SOCKET = %d",s);
    abc(aa);
    a.sin_family = AF_INET;
    a.sin_port = htons(80);
    a.sin_addr.s_addr = inet_addr("202.54.1.18");
    a.sin_addr.s_addr = inet_addr("208.77.188.166");
    a.sin_addr.s_addr = inet_addr(ipaddr);
    d = connect(s, (struct sockaddr *)&a, sizeof( a));
    printf("connection %d
    ", d);
    strcpy(aa,"GET /~bgy1mm/index.html
    ");
    strcat(aa,"HTTP 1.0

    ");
    send(s,aa,sizeof(aa),0);
    ii = 1;
    while (ii != 0)
    {
    ii = recv(s,aa,1000,0);
    aa[ii] = 0;
    abc(aa);
    }
    closesocket(s);
    abortme:
    WSACleanup();
    }
    [/code]

    Here's a little winsock program that opens a web address and prints it out.

    It may be what you are looking for, or you might want to handle things at a higher level.
Sign In or Register to comment.