Fourth, download (just to deal with the secondary directory) Global Type F_Connect_ftpcopyFile from Function_Objectnd Type
Forward PrototypeSGlobal Function Integer F_Connect_ftpcopyFile (HProgressBar HPB_1, Long Al_copyCount) End Prototype
Global Function Integer F_Connect_ftpcopyFile (HProgressBar HPB_1, Long Al_copyCount); do while yield () loop
String ls_directorya1 // Remote Directory String Ls_directorya2 // Local Contents String Ls_FileName, LS_File
// Local directory ls_directorya2 = GS_Application_Path
String ls_directoryb1 // Remote Directory String Ls_directoryb2 // Local Directory
String ls_filename1 // Remote file string ls_filename2 // Local file
Long ll_hretlong ll_hftp1long ll_hftp2long ll_fftp1long LL_FFTP2LONG LL_MLONG LL_FILEHANDLE1, LL_FILEHANDLE2
Integer li_ret
Boolean LB_SuccessBoolean LB_Find
S_WIN32_FIND_DATA SS_FILE1, SS_FILE2
w_autodown_test.st_ts.text = 'is checking the number of updates to update software ...' li_ret = f_connect_ftpserver () if li_ret = -1 Ten Return -1w_autodun_test.st_ts.text = 'is updating software version ... // Establish a connection ll_hret = InternetOpenA (gs_application_name, 0, '', '', 0) choose case li_ret case 1 ls_directorya1 = GS_FTPDIR1 ll_hftp1 = InternetConnectA (ll_hret, GS_FTPSERVER1, GL_FTPLOGINPORT1, GS_FTPLOGINUSER1, GS_FTPLOGINPASS1,1,0,0) case 2 ls_directorya1 = GS_FTPDIR2 ll_hftp1 = InternetConnectA (ll_hret, GS_FTPSERVER2, GL_FTPLOGINPORT2, GS_FTPLOGINUSER2, GS_FTPLOGINPASS2,1,0,0) case 3 ls_directorya1 = GS_FTPDIR3 ll_hftp1 = InternetConnectA (ll_hret, GS_FTPSERVER3, GL_FTPLOGINPORT3, GS_FTPLOGINUSER3, GS_FTPLOGINPASS3,1,0,0) case else InternetCloseHandle (ll_hret) ; return -1end choose // the FTP directory lb_success = FtpSetCurrentDirectoryA (ll_hftp1, ls_directorya1) if not lb_success then InternetCloseHandle (ll_hret); InternetCloseHandle (ll_hftp1); return -1end IF // Get the first file ll_fftp1 = FtpFindFirstFileA (ll_hftp1, ' ', SS_FILE1, 0) IF LL_FFTP1 = 0 THEN INTERNETCLOSEHANDLE (LL_H ret); InternetCloseHandle (ll_hftp1); InternetCloseHandle (ll_fftp1); return 0end if // initialization prompt box hpb_1.position = 0ll_m = 0 // directory if ss_file1.dwFileAttributes = 16 then // remote directory ls_directoryb1 = ls_directorya1 '/' ss_file1.cfilename // local directory ls_directoryb2 = ls_directorya2 '/' ss_file1.cfilename // local directory does not exist to create the directory if directoryexists (ls_directoryb2) = false then CreateDirectory (ls_directoryb2) ll_m hpb_1.position = ll_m / al_copycount * 100 END IF / / Create a second directory handle Choose Case Li_Ret Case 1 LL_HFTP2 =
InternetConnectA (ll_hret, GS_FTPSERVER1, GL_FTPLOGINPORT1, GS_FTPLOGINUSER1, GS_FTPLOGINPASS1,1,0,0) case 2 ll_hftp2 = InternetConnectA (ll_hret, GS_FTPSERVER2, GL_FTPLOGINPORT2, GS_FTPLOGINUSER2, GS_FTPLOGINPASS2,1,0,0) case 3 ll_hftp2 = InternetConnectA (ll_hret, GS_FTPSERVER3, GL_FTPLOGINPORT3, GS_FTPLOGINUSER3, GS_FTPLOGINPASS3,1,0,0) end choose // transferred to a second level directory lb_success = FtpSetCurrentDirectoryA (ll_hftp2, ls_directoryb1) if lb_success then // directory browsing ll_fftp2 = FtpFindFirstFileA (ll_hftp2, '', ss_file1,0 , 0) // local file ls_filename2 = ls_directoryb2 '/' ss_file1.cfilename if fileexists (ls_filename2) = false then // local file does not exist, direct access FtpGetFileA (ll_hftp2, ss_file1.cfilename, ls_filename2, false, 0, 0,0) ll_m hpb_1.position = ll_m / al_copycount * 100 else // presence of local files, compare file time ll_filehandle2 = FindFirstFileA (ls_filename2, ss_file2) FindClose (ll_filehandle2) choose case CompareFileTime (ss_file1.ftlastwritetime, ss_file2.ftlastwritetime) case 0 // two times, return zero case 1 //, such as lpfiletime2 less than LP FileTime1, return 1 // download FtpGetFileA (ll_hftp2, ss_file1.cfilename, ls_filename2, false, 0,0,0) ll_m hpb_1.position = ll_m / al_copycount * 100 case -1 // lpFileTime1 as less than lpFileTime2, return -1 end choose end if // traverse directories do while InternetFindnextFileA (ll_fftp2, ss_file1) yield () // local file ls_filename2 = '/' ss_file1.cfilename if fileexists (ls_filename2) = false then // local file does not exist, direct access ls_directoryb2 FTPGETFILEA (LL_HFTP2, SS_FILE1.CFILENAME, LS_FILENAME2, FALSE, 0, 0, 0) LL_M HPB_1.Position = LL_M / AL_COPYCOUNT * 100 ELSE // Local file exists,
Comparative Documents ll_filehandle2 = FindFirstFileA (ls_filename2, ss_file2) FindClose (ll_filehandle2) choose case CompareFileTime (ss_file1.ftlastwritetime, ss_file2.ftlastwritetime) case 0 // two equal time, zero is returned as lpFileTime2 case 1 // less than lpFileTime1, returns 1 // Download FtpGetFileA (ll_hftp2, ss_file1.cfilename, ls_filename2, false, 0,0,0) ll_m hpb_1.position = ll_m / al_copycount * 100 case -1 // lpFileTime1 as less than lpFileTime2, return -1 end choose end if loop InternetCloseHandle (ll_hftp2); InternetCloseHandle (ll_fftp2); end ifelse // // file is a local file ls_filename2 = ls_directorya2 '/' ss_file1.cfilename if fileexists (ls_filename2) = false then // local file does not exist, direct access lb_find = FtpGetFileA (ll_hftp1, ss_file1.cfilename, ls_filename2, false, 0,0,0) ll_m hpb_1.position = ll_m / al_copycount * 100 else // local file exists, the file comparison time ll_filehandle2 = FindFirstFileA (ls_filename2, ss_file2) FindClose (ll_filehandle2 ) Choose Case CompareFileTime (SS_FILE1.FTLASTWRITIME, SS_FILE2.FTLASTWRITIME) CASE 0 // Two time, return zero case 1 // If lpfiletime2 is less than lpfiletime1, return 1 // download lb_find = ftpGetfilea (LL_HFTP1, SS_FILE1.CFILENAME, LS_FILENAME2, FALSE, 0, 0) LL_M HPB_1.Position = LL_M / al_copycount * 100 case -1 // lpFileTime1 as less than lpFileTime2, return -1 end choose end ifend if // traverse directories do while InternetFindnextFileA (ll_fftp1, ss_file1) yield () // directory if ss_file1.dwFileAttributes = 16 then // Remote directory LS_Directoryb1 = ls_directorya1 '/' ss_file1.cfilename // Local Directory LS_DirectoryB2 = LS_DIRECTORYA2 '/'
ss_file1.cfilename // Create a directory if directoryexists local directory does not exist (ls_directoryb2) = false then CreateDirectory (ls_directoryb2) ll_m hpb_1.position = ll_m / al_copycount * 100 end if // create a second directory handle choose case li_ret case 1 ll_hftp2 = InternetConnectA (ll_hret, GS_FTPSERVER1, GL_FTPLOGINPORT1, GS_FTPLOGINUSER1, GS_FTPLOGINPASS1,1,0,0) case 2 ll_hftp2 = InternetConnectA (ll_hret, GS_FTPSERVER2, GL_FTPLOGINPORT2, GS_FTPLOGINUSER2, GS_FTPLOGINPASS2,1,0,0) case 3 ll_hftp2 = InternetConnectA (ll_hret, GS_FTPSERVER3 , GL_FTPLOGINPORT3, GS_FTPLOGINUSER3, GS_FTPLOGINPASS3,1,0,0) end choose // transferred to the second level directory lb_success = FtpSetCurrentDirectoryA (ll_hftp2, ls_directoryb1) if lb_success then // directory browsing ll_fftp2 = FtpFindFirstFileA (ll_hftp2, '', ss_file1, 0,0) // local file ls_filename2 = '/' ss_file1.cfilename if fileexists (ls_filename2) = false then // local file does not exist, direct access ls_directoryb2 lb_find = FtpGetFileA (ll_hftp2, ss_file1.cfilename, ls_filename2, false , 0, 0, 0) LL_M HPB_1.Position = LL_M / AL_COP ycount * 100 else // local file exists, the file comparison time ll_filehandle2 = FindFirstFileA (ls_filename2, ss_file2) FindClose (ll_filehandle2) choose case CompareFileTime (ss_file1.ftlastwritetime, ss_file2.ftlastwritetime) case 0 // two equal time, zero is returned Case 1 // lpFileTime2 as less than lpFileTime1, 1 // returns download lb_find = FtpGetFileA (ll_hftp2, ss_file1.cfilename, ls_filename2, false, 0,0,0) ll_m hpb_1.position = ll_m / al_copycount * 100 case -1 // as LPFileTime1 is less than lpfiletime2,
Return -1 end choose end if // traverse directories do while InternetFindnextFileA (ll_fftp2, ss_file1) yield () // local file ls_filename2 = ls_directoryb2 '/' ss_file1.cfilename if fileexists (ls_filename2) = false then // local file does not the existence of direct access lb_find = FtpGetFileA (ll_hftp2, ss_file1.cfilename, ls_filename2, false, 0,0,0) exists ll_m hpb_1.position = ll_m / al_copycount * 100 else // local file, compare file time ll_filehandle2 = FindFirstFileA ( ls_filename2, ss_file2) FindClose (ll_filehandle2) choose case CompareFileTime (ss_file1.ftlastwritetime, ss_file2.ftlastwritetime) case is equal to two time 0 //, // returns zero as Case 1 is less than lpFileTime2 lpFileTime1, 1 // returns download lb_find = FtpGetFileA ( ll_hftp2, ss_file1.cfilename, ls_filename2, false, 0,0,0) ll_m hpb_1.position = ll_m / al_copycount * 100 case -1 // lpFileTime1 as less than lpFileTime2, return -1 end choose end if loop InternetCloseHandle (ll_hftp2); InternetCloseHandle (ll_fftp2); End if else // is the file // local file ls_filename2 = ls_directorya2 '/' ss_file1.cfilename if fileexists (ls_filename2) = false then // local file does not exist, direct access lb_find = FtpGetFileA (ll_hftp1, ss_file1.cfilename, ls_filename2, false, 0,0,0) ll_m hpb_1. position = ll_m / al_copycount * 100 else // local file exists, the file comparison time ll_filehandle2 = FindFirstFileA (ls_filename2, ss_file2) FindClose (ll_filehandle2) choose case CompareFileTime (ss_file1.ftlastwritetime, ss_file2.ftlastwritetime) case 0 // two equal time , Return zero case 1 // If lpfiletime2 is less than lpfiletime1, return 1 // download lb_find =
FtpGetFileA (ll_hftp1, ss_file1.cfilename, ls_filename2, false, 0,0,0) ll_m hpb_1.position = ll_m / al_copycount * 100 case -1 // lpFileTime1 as less than lpFileTime2, return -1 end choose end if end ifloopInternetCloseHandle (ll_hret) INTERNETCLOSEHANDLE (LL_HFTP1); InternetCloseHandle (LL_FFTP1); Return 1END FUNCTION