Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting a file from internet

Status
Not open for further replies.

dakkarin

Instructor
Nov 11, 2005
76
TR
Hi im trying to design a program that will download a zip file that i write the url of.
Is something like that possible with borland if it is how?
Thanks
 
sorry i mean i want to download it from a ftp server which requires anonymous as username and password
how can i do it?
 
Look at the WSA function in the Windows SDK. The Windows Sockets WSAStartup function initiates use of the Windows Sockets DLL by a process.

Should be a good place to start.
 
Here is how you can download/upload a file to a ftp server:

Code:
HINTERNET hNetSes ;
     HINTERNET hFTP;
     BOOL bResult;

 	hNetSes=InternetOpen ("Microsoft Internet Explorer",INTERNET_OPEN_TYPE_DIRECT,"",NULL,0);
          if (hNetSes==NULL)
	    {
                 //error
            return;}

	hFTP = InternetConnect (hNetSes,EditFtpServer->Text.c_str(),INTERNET_INVALID_PORT_NUMBER,EditFtpUser->Text.c_str(),EditFtpPass->Text.c_str(),INTERNET_SERVICE_FTP,0,(DWORD)0);
	  if (hFTP==NULL)
          {//error connecting ...
            return;}

//put file on ftp
bResult=FtpPutFile(hFTP,EditLocaPath->Text.c_str(),cBuff.c_str(),FTP_TRANSFER_TYPE_BINARY,0);
	if (!bResult)
        { //error transfering ...
      }
//get file
bResult=FtpGetFile(hFTP,EditLocaPath->Text.c_str(),EditUploaded->Text.c_str(),false,FILE_ATTRIBUTE_NORMAL,FTP_TRANSFER_TYPE_BINARY,0);
	if (!bResult)
        { //error transfering ...
         }


    InternetCloseHandle(hFTP);
    InternetCloseHandle(hNetSes);
dont forget to #include <wininet.h>
more details about ftp sesions you can find on MSDN:
good luck!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top