Image Map of Navigational Panel to Home / Contents / Search Distributing Application Updates

Distributing Executables

Image of line

One other problem we encountered was the distribution of exe files. I mentioned before that we were going to package them inside a memo field in an Access database. The biggest problem was that some of the files could be greater than 64K. Since distributing only half an exe was not really an option, we needed to come up with a way of slicing and dicing the files, and then piecing them back together at the other end.

The code below demonstrated how we did it.

  ' Dim a few variables.
  Dim NumChunks As Integer
  Dim TotalSize As Long
  Dim ChunkSize
  
  ' Set maximum chunk size to 16K.
  ChunkSize = 16384

  ' Save the record required for this form to the new database.
  DistribDyn.AddNew
   
  ' Loop through each field saving to new table as we go.
  For t = 0 To snpDistrib.Fields.Count - 1
    If snpDistrib.Fields(t).Name = "FrmForm" Then
      TotalSize = snpDistrib!FrmForm.FieldSize()
      NumChunks = TotalSize \ ChunkSize - (TotalSize Mod ChunkSize <> 0)
      DistribDyn!FrmForm = ""
      For X = 1 To NumChunks
        DistribDyn!FrmForm.AppendChunk snpDistrib!
                   FrmForm.GetChunk((X-1) * ChunkSize, ChunkSize)
      Next X
    Else
      DistribDyn.Fields(t) = snpDistrib.Fields(t)
    End If
  Next t
    
  ' Update
  DistribDyn.Update

OK, so basically we are reading in chunks of data from the file and saving them to fields in the record in the database. Make sure that you have enough fields to cope or save each chunk in its own separate record.

One problem, well, not really, is that if the file is 16.5K in size, we are actually going to save 32K instead. However, this didn't really bother us at the time and we will probably get around to rectifying that when and if.

At the other end :

  ' Dim a couple of variables.
  Dim TotalSize As Long
  Dim NumChunks As Integer
  Dim ChunkSize
     
  ChunkSize = 16384
      
  For t = 5 To 13
    TotalSize = snpDistrib!frmForm.FieldSize()
    NumChunks = TotalSize \ ChunkSize - (TotalSize Mod ChunkSize <> 0)
    For X = 1 To NumChunks
      dynFormInstance!frmForm.AppendChunk 
                      "C:\Test.MDB".GetChunk((X - 1) * 
                                              ChunkSize, ChunkSize)
    Next X
  Next t

Most of the code for opening the tables etc has been removed, but you can see that we are simply now moving through all 13 of my Chunks in the database and appending them to the hard drive. This effectively re-creates the original file, if not a little larger. The most you are ever likely to be out by is probably around 8K.

Increasing the size of the exe, interestingly enough, has no effect on the actual program at all. We have now distributed Calc.Exe and Notepad.Exe, both of which increased in size by around 7 to 8 K, and both ran as advertised. In fact, I'm still using those files on my PC and have had no problems. Did cause a few interesting problems with my virus checker however.<g>


Image of arrow to previous article Image of arrow to next article

Image of line

[HOME] [TABLE OF CONTENTS] [SEARCH]