FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Is seven and download file
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Is seven and download file
Posted: Sat Jan 15, 2022 10:43 AM
there is a function return me if is a win Seven ?
now I made If val(cWinVersion())=7 but I not know if it's correct

this because I have problem to download a file from a website with Windows Seven
with GETURLTOFILE(cUrl,cZipFile)


Code (fw): Select all Collapse
STATIC FUNCTION GETURLTOFILE( cUrl, cFile, cUsr, cPsw )
    LOCAL lOk := .F.

    LOCAL oHtp, oStr, ex

    DEFAULT cFile := CFILENAME( STRTRAN( cUrl, "/", "\" ) )

    //TRY
        oHtp = CREATEOBJECT( "Msxml2.XMLHTTP.6.0" )

        oHtp:Open( "POST", cUrl, .F., cUsr, cPsw )

        oHtp:Send()


        IF oHtp:Status != 200 THEN BREAK
        MemoWrit(cFile,oHtp:ResponseBody)
        //oStr = CREATEOBJECT( "ADODB.Stream" )
        //oStr:Open()
        //oStr:Type = 1
        //oStr:Write( oHtp:ResponseBody )
        //oStr:SaveToFile( cFile, 2 )
        //oStr:Close()

        lOk = .T.
    //CATCH ex
    //        ? ex:message
    //END

    RETURN lOk



while on win10 I can use GETURLTOFILE(cUrl,cZipFile)

on widows seven I must use
Code (fw): Select all Collapse
 FUNCTION Download( cUrl )
       cUrl := IF( "@" $ cUrl, "mailto:" + cUrl, cUrl )
   // ? cUrl
   IF Empty( cUrl )
      MsgInfo( "Introdurre URL Correta", "Attenzione" )
   ELSE
      CURSORWAIT()
      IF IsWinNT() .OR. isWin2000() // XP/2000/NT
         WinExec( "rundll32.exe url.dll, FileProtocolHandler " + cUrl, 0 )
      ELSE
         WinExec( "Start " + cUrl, 0 )
      ENDIF
      CURSORARROW()
   ENDIF
   RETURN NIL


only I cannot copy the file into a my folder but it save the file on folder download of window
is there a solution ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: Is seven and download file
Posted: Sat Jan 15, 2022 12:58 PM
Maybe this can be of help : this is saving at the program location


Code (fw): Select all Collapse
if URLDOWNLOADTOFILE( 0, "https:\\yourdomain/fivewin/fivewin.zip", "fivewin.zip" ) = 0  
   oRs:versie = system_version
   oRs:Save()
   msginfo("Update found")
endif

DLL FUNCTION URLDOWNLOADTOFILE( pCaller AS LONG, cUrl AS LPSTR, cFileName AS LPSTR, nReserved AS DWORD, nFnCB AS LONG ) AS LONG;
    PASCAL FROM "URLDownloadToFileA" LIB "urlmon.dll"
Marc Venken

Using: FWH 23.08 with Harbour
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Is seven and download file
Posted: Sat Jan 15, 2022 02:44 PM
Marc Venken wrote:Maybe this can be of help : this is saving at the program location


Code (fw): Select all Collapse
if URLDOWNLOADTOFILE( 0, "https:\\yourdomain/fivewin/fivewin.zip", "fivewin.zip" ) = 0  
   oRs:versie = system_version
   oRs:Save()
   msginfo("Update found")
endif

DLL FUNCTION URLDOWNLOADTOFILE( pCaller AS LONG, cUrl AS LPSTR, cFileName AS LPSTR, nReserved AS DWORD, nFnCB AS LONG ) AS LONG;
    PASCAL FROM "URLDownloadToFileA" LIB "urlmon.dll"


I tried not happen nothing
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com

Continue the discussion