Board index » delphi » Resource File headache

Resource File headache

Hi guys,

As kind of a Delphi newbie, I have stumbled across a rather poorly
documented feature in some code that I am trying to maintain.  This centers
around a resource file, whose actual contents are a binary for a flash
loader for an embedded device.  The code originally worked...however, when I
try it, it blows up every time (at run time, not compile time).

I am using Delphi 5.  (This project was originally done in Delphi 4, if that
makes a difference...)

Here, the resource file is loaded:

unit MC68332;

interface

uses Windows, SysUtils, Classes, Forms, Async32, SerialDeviceImpl,
TerminalGroupXControl_TLB, Dialogs;

function ProgramMC68332(ImageStream: TStream; Device: TSerialDevice;
UserMode: Boolean): erErrorCode;

implementation

uses ProgressF;

// Link in the compilied FORTH assembly code module as a 'BINARY'
resource...
{$R 'E:\Firm\Term\T5\Boot\fs512K.res'}

<SNIP>

And here is where it is used in the code:

function ProgramMC68332(ImageStream: TStream; Device: TSerialDevice;
UserMode: Boolean): erErrorCode;
var
  LastTick: Cardinal;
  FinishedKey: Boolean;
begin
  Result := erInvalidPointer;
  { Load the FLASH upgrader from the control's resources }
  ControlModule := GetModuleHandle('TerminalGroupXControl.ocx');
  UpgraderResource := FindResource(ControlModule, '#201', 'BINARY');
  if UpgraderResource = 0 then
    MessageDlg('An error occured while programming the new firmware.'+#13+
     'The ActiveX control was unable to locate the terminals binary loader
file!',
     mtError, [mbOK], 0);
    Exit;
<SNIP>

I added the dialog box before the exit myself...and when the code blows up,
my dialog box gets added, so we know that the FindResource function is the
complaining party.

A hex editor reveals the following contents of the resource file header (for
those souls brave enough to debug a resource file: documentation on .res
file format available at multiple locations online):

 0000:0000  00 00 00 00 20 00 00 00 FF FF 00 00 FF FF 00 00   ....
...??..??..
 0000:0010  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
................
 0000:0020  62 02 00 00 2C 00 00 00 42 00 49 00 4E 00 41 00
b...,...B.I.N.A.
 0000:0030  52 00 59 00 00 00 FF FF C9 00 00 00 00 00 00
R.Y...??......

Any ideas?

Thanks, I'm at whit's end here...

Brent Boswell
Leppo Instruments, Inc.

To e-mail: replace nowhere with leppo and net with com

 

Re:Resource File headache


Quote
> Hi guys,

> As kind of a Delphi newbie, I have stumbled across a rather poorly

Try a delphi group. This one's for Dos based Borland Turbo Pascal.
See the MFAQ in this group for Delphi groups.

Femme

Other Threads