Skip to content
⌘ NSIS Forum Archive

Download files with inetcurl

2 posts

Kuppy#

Download files with inetcurl

How do I download files using the plug inetcurl.dll?
Plugin: http://api.256file.com/inetcurl.dll/...ad-183881.html

# Test Inetcurl
Name "Inetcurl Test"  
Caption "Inetcurl Test"  
OutFile "Inetcurl Test.exe"  
InstallDir "$TEMP\Inetcurl Test"  
# COMPRESS  
SetCompressor /SOLID /FINAL lzma 
# RUN  
RequestExecutionLevel user  
# INCLUDES  
!include "MUI2.nsh"  
!include "nsDialogs.nsh"  
!include "FileFunc.nsh"  
!include "WinMessages.nsh"  
!insertmacro GetSize
# Icon & Stye  
BrandingText /TRIMRIGHT " "  
Page custom Page.Custom.Test /ENABLECANCEL   
Page instfiles   
# LANGUAGES  
!insertmacro MUI_LANGUAGE "English" # first language  
!insertmacro MUI_LANGUAGE "Romanian" # second language  
Function .onInit
  InitPluginsDir
  AllowSkipFiles off
  SetOverwrite ifnewer
  File "/oname=$PLUGINSDIR\curllib.dll" "Plugins\curllib.dll"
  File "/oname=$PLUGINSDIR\libsasl.dll" "Plugins\libsasl.dll"
  File "/oname=$PLUGINSDIR\\openldap.dll" "Plugins\openldap.dll"
  File "/oname=$PLUGINSDIR\libeay32.dll" "Plugins\libeay32.dll"
  File "/oname=$PLUGINSDIR\ssleay32.dll" "Plugins\ssleay32.dll"
  File "/oname=$PLUGINSDIR\rdata.dat" "Plugins\rdata.dat"
FunctionEnd
Function Page.Custom.Test  
  var /GLOBAL Dialog 
  var /GLOBAL Btn_Down
  var /GLOBAL PATH.LINK
  var /GLOBAL PATH.PACK
  var /GLOBAL PATH.SAVE
  var /GLOBAL Btn_Save
  var /GLOBAL Lbl.Link 
  var /GLOBAL Lbl.Pack 
  var /GLOBAL Lbl.Save 
  var /GLOBAL Lbl.Info.1
  var /GLOBAL Lbl.Info.2
  var /GLOBAL Lbl.Info.3
  GetDlgItem $0 $HWNDPARENT 1  
  ShowWindow $0 ${SW_HIDE}  
  GetDlgItem $0 $HWNDPARENT 2  
  ShowWindow $0 ${SW_HIDE}  
  GetDlgItem $0 $HWNDPARENT 3  
  ShowWindow $0 ${SW_HIDE}  
  GetDlgItem $0 $HWNDPARENT 1990  
  ShowWindow $0 ${SW_HIDE}  
  GetDlgItem $0 $HWNDPARENT 1991  
  ShowWindow $0 ${SW_HIDE}  
  GetDlgItem $0 $HWNDPARENT 1992  
  ShowWindow $0 ${SW_HIDE}  
  System::Call "user32::SetWindowPos(i$HWNDPARENT,i,i,i,i 632,i 466,i 0x16)"   
  nsDialogs::Create /NOUNLOAD 1044   
  Pop $Dialog   
  ${If} $Dialog == error   
   Abort   
  ${EndIf}   
  System::Call "user32::MoveWindow(i$Dialog,i0,i0,i 632,i 466,i0)"   
  SetCtlColors $Dialog 0xbbbbbb 0x323232 
  # ...:: ADD LINK ::... # 
  nsDialogs::CreateControl /NOUNLOAD STATIC 0x40000000|0x10000000|0x04000000|0x00000100 0x00000020 2% 2% 165u 15u "Add Your Link:" 
  pop $Lbl.Link 
  SetCtlColors $Lbl.Link 0xbbbbbb 0x323232 
  CreateFont $0 "MV Boli" "12" "100" 
  SendMessage $Lbl.Link ${WM_SETFONT} $0 0  
  nsDialogs::CreateControl /NOUNLOAD EDIT 0x40000000|0x10000000|0x04000000|0x00010000|0x00000080 0 2% 7% 79% 15u "" 
  Pop $PATH.LINK 
  Strcpy $1 $PATH.LINK
  GetFunctionAddress $0 "on.Click.Add.Link"
  nsDialogs::OnChange /NOUNLOAD $1 $0
  CreateFont $0 "MV Boli" "12" "100" 
  SendMessage $PATH.LINK ${WM_SETFONT} $0 0  
  SetCtlColors $PATH.LINK 0xbbbbbb 0x424242 
  # ...:: ADD PACK ::... # 
  nsDialogs::CreateControl /NOUNLOAD STATIC 0x40000000|0x10000000|0x04000000|0x00000100 0x00000020 2% 15% 165u 15u "Add Your Pack:" 
  pop $Lbl.Pack 
  SetCtlColors $Lbl.Pack 0xbbbbbb 0x323232 
  CreateFont $0 "MV Boli" "12" "100" 
  SendMessage $Lbl.Pack ${WM_SETFONT} $0 0  
  nsDialogs::CreateControl /NOUNLOAD EDIT 0x40000000|0x10000000|0x04000000|0x00010000|0x00000080 0 2% 20% 79% 15u "" 
  Pop $PATH.PACK
  Strcpy $1 $PATH.PACK
  GetFunctionAddress $0 "on.Click.Add.Pack"
  nsDialogs::OnChange /NOUNLOAD $1 $0
  CreateFont $0 "MV Boli" "12" "100" 
  SendMessage $PATH.PACK ${WM_SETFONT} $0 0  
  SetCtlColors $PATH.PACK 0xbbbbbb 0x424242  
  # ...:: SAVE PACK ::... # 
  nsDialogs::CreateControl /NOUNLOAD STATIC 0x40000000|0x10000000|0x04000000|0x00000100 0x00000020 2% 27% 165u 15u "Save Your Pack:" 
  pop $Lbl.Save
  SetCtlColors $Lbl.Save 0xbbbbbb 0x323232 
  CreateFont $0 "MV Boli" "12" "100" 
  SendMessage $Lbl.Save ${WM_SETFONT} $0 0  
  nsDialogs::CreateControl /NOUNLOAD EDIT 0x40000000|0x10000000|0x04000000|0x00010000|0x00000080 0 2% 32% 79% 15u "" 
  Pop $PATH.SAVE
  CreateFont $0 "MV Boli" "12" "100" 
  SendMessage $PATH.SAVE ${WM_SETFONT} $0 0  
  SetCtlColors $PATH.SAVE 0xbbbbbb 0x424242 
  nsDialogs::CreateControl /NOUNLOAD BUTTON 0x40000000|0x10000000|0x04000000|0x00010000 0 82% 32% 65u 15u "" 
  Pop $Btn_Save
  Strcpy $1 $Btn_Save 
  GetFunctionAddress $3 "on.Click.Save" 
  nsDialogs::onClick $1 $3 
  SetCtlColors $Btn_Save 0xbbbbbb 0x323232 
  CreateFont $0 "MV Boli" "10" "400" 
  SendMessage $Btn_Save ${WM_SETFONT} $0 0  
  SendMessage $Btn_Save '${WM_SETTEXT}' '0' "STR:Save ..." 
  # ...:: INFO ::... # 
  nsDialogs::CreateControl /NOUNLOAD STATIC 0x40000000|0x10000000|0x04000000|0x00000100 0x00000020 2% 45% 95% 15u "" 
  Pop $Lbl.Info.1
  SetCtlColors $Lbl.Info.1 0xbbbbbb 0x323232 
  CreateFont $0 "MV Boli" "10" "100" 
  SendMessage $Lbl.Info.1 ${WM_SETFONT} $0 0  
  nsDialogs::CreateControl /NOUNLOAD STATIC 0x40000000|0x10000000|0x04000000|0x00000100 0x00000020 2% 50% 95% 15u "" 
  Pop $Lbl.Info.2
  SetCtlColors $Lbl.Info.2 0xbbbbbb 0x323232 
  CreateFont $0 "MV Boli" "10" "100" 
  SendMessage $Lbl.Info.2 ${WM_SETFONT} $0 0  
  nsDialogs::CreateControl /NOUNLOAD STATIC 0x40000000|0x10000000|0x04000000|0x00000100 0x00000020 2% 55% 95% 15u "" 
  Pop $Lbl.Info.3
  SetCtlColors $Lbl.Info.3 0xbbbbbb 0x323232 
  CreateFont $0 "MV Boli" "10" "100" 
  SendMessage $Lbl.Info.3 ${WM_SETFONT} $0 0  
  # ...:: BTN DOWNLOAD ::... # 
  nsDialogs::CreateControl /NOUNLOAD BUTTON 0x40000000|0x10000000|0x04000000|0x00010000 0 145u 245u 120u 18u "Download  Now ..." ; Download  
  Pop $Btn_Down 
  StrCpy $1 $Btn_Down 
  GetFunctionAddress $3 "On.Click.Download" 
  nsDialogs::onClick $1 $3 
  SetCtlColors $Btn_Down 0xbbbbbb 0x323232 
  CreateFont $0 "MV Boli" "12" "100" 
  SendMessage $Btn_Down  0x0030 $0 0 
  nsDialogs::Show 
FunctionEnd 
# ...:: LINK ::... # 
var /Global LINK
var /Global PACK
Function "on.Click.Add.Link"
  Pop $PATH.LINK
  ${NSD_GetText} $PATH.LINK $0
  Strcpy $LINK '$0'
  ${If} $LINK != "Link"
   SendMessage $Lbl.Info.1 ${WM_SETTEXT} 0 "STR:$LINK"
  ${EndIf}
FunctionEnd
# ...:: PACK ::... # 
Function "on.Click.Add.Pack"
  Pop $PATH.PACK
  ${NSD_GetText} $PATH.PACK $0
  Strcpy $PACK '$0'
  ${If} $PACK != "Pack"
   SendMessage $Lbl.Info.2 ${WM_SETTEXT} 0 "STR:$PACK"
  ${EndIf}
FunctionEnd
# ...:: SAVE PACK ::... # 
var /global MYDESTDIR 
Function "on.Click.Save" 
  nsDialogs::SelectFolderDialog /NOUNLOAD "Select Save Location:" "c:\"
  Pop $0 
  StrCpy $MYDESTDIR "$0" 
  ${NSD_SetText} $PATH.SAVE "$MYDESTDIR" 
  ${If} $MYDESTDIR != "Dest"
   SendMessage $Lbl.Info.3 ${WM_SETTEXT} 0 "STR:$MYDESTDIR"
  ${EndIf}
FunctionEnd 
LangString LSTR_45 1033 "Downloading "
LangString LSTR_46 1033 "Installation of "
LangString LSTR_47 1033 "Download interrupted due no internet connection. Check your connection or use the Internet Explorer browser"
LangString LSTR_48 1033 " (%d %s%s remaining)"
LangString LSTR_49 1033 "%dkB (%d%%) from %dkB have been downloaded."
LangString LSTR_50 1033 "s"
LangString LSTR_51 1033 "h"
LangString LSTR_52 1033 "min"
LangString LSTR_53 1033 "sec"
LangString LSTR_54 1033 "Downloading..."
LangString LSTR_55 1033 "Downloading the %s file"
LangString LSTR_56 1033 "Download file failed!"
LangString LSTR_57 1033 "Download succesfully!"
LangString LSTR_58 1033 "Size:"
LangString LSTR_45 1048 "Descărcare "
LangString LSTR_46 1048 "Instalare din "
LangString LSTR_47 1048 "Descărcarea a fost întreruptă,verifică dacă ai o conexiune la internet. Verifică conexiunea sau foloseste browser-ul Internet Explorer"
LangString LSTR_48 1048 " (%d %s%s rămase)"
LangString LSTR_49 1048 "%dkB (%d%%) din %dkB au fost descărcate."
LangString LSTR_50 1048 " "
LangString LSTR_51 1048 "ore"
LangString LSTR_52 1048 "minute"
LangString LSTR_53 1048 "secunde"
LangString LSTR_54 1048 "Se descarcă..."
LangString LSTR_55 1048 "Descarc acest %s fisier"
LangString LSTR_56 1048 "Descărcarea fisierului a esuat!"
LangString LSTR_57 1048 "Descărcărcat cu succes!"
LangString LSTR_58 1048 "Dimensiune:"
Function "On.Click.Download" 
  GetDlgItem $0 $HWNDPARENT 2
  EnableWindow $0 1
  inetcurl::get /TRANSLATE $(LSTR_55) $(LSTR_54) $(LSTR_53) $(LSTR_52) $(LSTR_51) $(LSTR_50) $(LSTR_49) $(LSTR_48) /NOCANCEL /THREADS 4 /CONNECTTIMEOUT 3000000 /RECEIVETIMEOUT 3000000 /RESUME $(LSTR_47) /WEAKSECURITY "$LINK" "$MYDESTDIR\$PACK"    ;  "Downloading the %s file" Downloading... sec min h "%dkB (%d%%) from %dkB have been downloaded." " (%d %s%s remaining)" "Download interrupted due no internet connection. Check your connection or use the Internet Explorer browser"
  Pop $0
  StrCmp $0 OK label_689
  inetc::get /TRANSLATE $(LSTR_55) $(LSTR_54) $(LSTR_53) $(LSTR_52) $(LSTR_51) $(LSTR_50) $(LSTR_49) $(LSTR_48) /NOCANCEL /CONNECTTIMEOUT 3000000 /RECEIVETIMEOUT 3000000 /RESUME $(LSTR_47) /WEAKSECURITY "$LINK" "$MYDESTDIR\$PACK"    ;  "Downloading the %s file" Downloading... sec min h "%dkB (%d%%) from %dkB have been downloaded." " (%d %s%s remaining)" "Download interrupted due no internet connection. Check your connection or use the Internet Explorer browser"
  Pop $0
  label_689:
  StrCmp $0 OK +3
  StrCmp $0 "URL Parts Error" +3
  StrCmp $PACK 1 0 label_699
  FileOpen $4 "$TEMP\NSSIDownloadError.txt" w
  FileWrite $4 "Error:$0 $\r$\n"
  FileWrite $4 "URL  :$LINK $\r$\n"
label_699:
  IfFileExists "$MYDESTDIR\$PACK" "NSIS.Successfully.Download" "NSIS.Failed.Download"
  StrCmp $0 1 "NSIS.Successfully.Download" "NSIS.Failed.Download"
  ${If} $0 == "1"
    NSIS.Successfully.Download:
    ${GetSize} "$MYDESTDIR" "/M=$PACK /S=0K" $0 $1 $2
    IfErrors 0 +2
    StrCpy $0 $0 * 1024
    IntCmp $0 100 +3 0 +3
      IntCmp $0 0 +2 +2 0
      IntOp $0 103 + 0
    IntOp $0 $0 * 10
    IntOp $0 $0 / 1024
    StrCpy $1 "$0" "" -1
    IntCmp $0 9 +3 +3 0
      StrCpy $0 "$0" -1 ""
      Goto +2
      StrCpy $0 "0"
     MessageBox MB_OK "$(LSTR_57) $(LSTR_58) $0.$1 Mib"
     Quit
  ${ElseIf} $0 == "0"
    NSIS.Failed.Download:
    MessageBox MB_OK "$(LSTR_56)"
    Quit
  ${Endif}
FunctionEnd 
Section "Main" SEC01 
SectionEnd 
Function .onGUIEnd 
FunctionEnd 
Anders#
Why do you insist on using a custom font when it only complicates your example code?

If this is a new plug-in then you should make a wiki page.