Programming with BITS in Delphi

BITS is Microsoft’s Background Intelligent Download Service. It was added in XP to allow downloading of security patches in the background. In the Platform SDK Microsoft provided a COM interface to allow developers to work with BITS. Unfortunately it is a bit of a pain to actually get to the interface, especially if you are not using Visual Studio. To make it easier for Delphi developers to work with BITS, I am providing my imported Type Library for the BackgroundCopyManager.

Alternatively you can use the JEDI Win32 API Library available on Sourceforge. It has the Bits interface (version 1.5) split into a few different files (JwaBits1_5.pas, JwaBits.pas, JwaBitscfg.pas, and JwaBitsMsg.pas [although they reference other included files]) and cleaned up a little bit. In addition it includes a number of other useful Delphi wrappers for Win32 API’s. I recommend this library over the raw TLB import. My demo will work with either one.

UPDATE: I recreated the demo and added it to the archive!

Contents of the BITS-README.txt included in the zip

Microsoft BITS - Background Intelligent Transfer Service
Delphi Type Library wrapper

The only real file you need is BackgroundCopyManager_TLB.pas. The other files are intermediary files created in the generation process and are only included in case you want to regenerated the TLB wrapper.

The Windows XP SP2 Platform SDK includes the BITS.IDL. To get the TLB file (which I have included for you) you must use the MIDL compiler. I have also included the BackgroundCopyManager_TLB.pas file which Delphi generates. You DO NOT need the IDL or the Platform SDK installed to develop with the Background Copy Manager. All you need is the Background Intelligent Transfer Service version 1.5 or greater installed and running. This comes pre-installed on Windows XP SP2 and Vista. I believe you can also get it for Windows 2000, but I wouldn’t guarantee that.

I did not include any of the files that are included in the Platform SDK, only files that are generated from those. Therefor this should not be in violation of and copyrights.

Files:

Generated by the MIDL from the BITS.IDL file
Bits.tlb    <-- If you want to regenerate BackgroundCopyManager_TLB.pas
Bits.h      <-- C header file
Bits_i.c    <--
Bits_p.c    <----- Other C related files - Not needed for Delphi.
dlldata.c   <--/Generated by Delphi from the TLB file
BackgroundCopyManager_TLB.pas  <-- This is the only one Delphi needs

UPDATE: Get the BITS 3.0 header files.

Tags: , , , , ,

3 Responses to “Programming with BITS in Delphi”

  1. smile Says:

    hi, thanks for your works.

    but i have a question: where is your demo ?

  2. Jim Says:

    The demo was in the virtual machine on a hard drive that crashed. :-( Hopefully I will get a chance to recreate it.

  3. DaVinci Unlimited Software » Blog Archive » BITSAdmin Says:

    [...] you are doing much development with BITS, then I suggest you download the BITSAdmin tool.  It comes with Vista and the XP SP 2 Platform [...]

Leave a Reply