Is seven and download file

Is seven and download file

Postby Silvio.Falconi » 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: Select all  Expand view  RUN

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: Select all  Expand view  RUN
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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7063
Joined: Thu Oct 18, 2012 7:17 pm

Re: Is seven and download file

Postby Marc Venken » Sat Jan 15, 2022 12:58 pm

Maybe this can be of help : this is saving at the program location


Code: Select all  Expand view  RUN


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.04 with Harbour
User avatar
Marc Venken
 
Posts: 1434
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Is seven and download file

Postby Silvio.Falconi » Sat Jan 15, 2022 2:44 pm

Marc Venken wrote:Maybe this can be of help : this is saving at the program location


Code: Select all  Expand view  RUN


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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7063
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 87 guests