Internal Downloader - Counterstrikewi

posted 24 May 2010, 12:15 by Delphi Basics   [ updated 8 Jun 2010, 18:39 ]
{
    Coder: Counterstrikewi
    Website: www.delphibasics.info
    Compiled: Delphi 2007
    For: Viotto :)
}

This code is standard code to produce a small downloader ( 15Kb ) which downloads the google logo from the internet using urldownloadtofilea and executes it using shellexecute windows api. Api's are dynamically imported to reduce the final size of the application.

program Downloader;

uses
  Windows;

const
  szSourceFile = 'http://www.google.co.za/intl/en_com/images/srpr/logo1w.png';
  szDestFile = 'C:\GoogleLogo.png';
  szUrlmon = 'urlmon.dll';
  szUrlDownloadToFileA = 'URLDownloadToFileA';
  szShell32 = 'shell32.dll';
  szShellExecuteA = 'ShellExecuteA';
  szOpen = 'open';
var
 hUrlmon, hShell32 : Cardinal;
 xURLDownloadToFileA : function(Caller: Pointer; URL: PAnsiChar; FileName: PAnsiChar; Reserved: Cardinal; StatusCB: Pointer): Cardinal; stdcall;
 xShellExecuteA      : function(hWnd: Cardinal; Operation, FileName, Parameters, Directory: PAnsiChar; ShowCmd: Cardinal): Cardinal; stdcall;

begin
  hUrlmon := LoadLibraryA(szUrlmon);
  @xURLDownloadToFileA := GetProcAddress(hUrlMon, szUrlDownloadToFileA);
  xUrlDownloadToFileA(nil, szSourceFile, szDestFile, 0, nil);
  hShell32 := LoadLibraryA(szShell32);
  @xShellExecuteA := GetProcAddress(hShell32, szShellExecuteA);
  xShellExecuteA(0, szOpen, szDestFile, nil, nil, 2);
end.

More Delphi downloader source codes:
External Downloader - Counterstrikewi
Wininet Downloader - 3.0 KB
Tiny Downloader - 2.5 KB
Comments