Link to home
Start Free TrialLog in
Avatar of antenor
antenorFlag for Brazil

asked on

Problems with dll - win98 and winXP

hi,

I have a dll (Delphi 5) compiled in Win2k environment. If a copy in win98 machines - don't work. In a Win2k or WinXP machines - no problems.

The Handle returned after loadlibrary is 0 and error code is 0.


Tank's.
Avatar of Melih SARICA
Melih SARICA
Flag of Türkiye image

Post the Source of ur dll calling code and Dll's initialize code

...
Avatar of antenor

ASKER


DLL code:
======

library Material;
...

procedure LibInit;
begin
     {Código de inicialização da Dll}
     F_PesquisaGlobal  := TF_PesquisaGlobal.Create(Application);
     F_PesquisaGlobal2 := TF_PesquisaGlobal2.Create(Application);
     F_Erro := TF_Erro.Create(Application);
     ShortDateFormat   := 'dd/mm/yyyy';
end;
...

BEGIN
     LibInit;
END.

Calling code:
========
var
   DLLHandle : hwnd;
   FullLibraryName : string;

begin
...

           FullLibraryName := DiretorioTMP+LibraryName;
           DLLHandle := LoadLibrary(Pchar(LowerCase(FullLibraryName)));

  ShowMessage('Handle: '+IntToStr(DLLHandle));
  ShowMessage('Error: '+IntToStr(GetLastError));

     end;
end;


ASKER CERTIFIED SOLUTION
Avatar of Russell Libby
Russell Libby
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of antenor

ASKER

my windows 98 language is brazilian portuguese, but message are:

"Espaço Insuficiente de armazenamento para processar este comando"

in english are

"Insuficient space for processing command"

Avatar of antenor

ASKER

ahhh....


The error code is "8"


Thats a help, but can you can tell me what dwError is set to as well?  This will help me narrow down the problem to the exact cause.

Thanks,
Russell
Ahh.....

that helps. From the msdn, there a few notations of why a dll may work on xp (NT core systems), and not on 95/98.

------------------

Size of In-Memory Resource Table Exceeds 64 KB

When a 32-bit DLL is loaded on a computer that is running Windows 95 or Windows 98, the operating system creates an in-memory resource table to index the various types of resources that are contained within the DLL. The maximum size for this table is 65,535 bytes. If the table size exceeds this limit, the LoadLibrary function call fails with error code 8 (ERROR_OUT_OF_MEMORY).

The in-memory table requires 16 bytes for each resource within the DLL. A named resource requires an additional number of bytes equal to the length of the string plus one. Finally, about 100 bytes is required for alignment and indexing within the table. Thus, a DLL has an upper limit of about 4089 resources on Windows 95 and Windows 98, assuming none are named.

The sample code in the "More Information" section of this article can be used to compile a utility that determines the required size of the in-memory resource table that is generated for a given DLL.

Name Offset Exceeds 64 KB

When a DLL is generated, the resource compiler stores the names of all named resources in a contiguous block of memory in the DLL. This block of memory makes up the resource Names Table. Another portion of the file is used to index all resources (both named and unnamed). This part of the file is the Resource Directory. For each named resource, the entry in the directory contains an offset value that points to the name of the resource in the Names Table. If any of these offset values exceed 65,535 bytes, the LoadLibrary function call fails with error code 8 (ERROR_OUT_OF_MEMORY).

The generation of this table is completely handled by the resource compiler and cannot be controlled by the developer. For this reason, it is best to avoid named resources.

The sample code in the "More Information" section of this article can be used to compile a utility that determines whether the name offsets within a given DLL are valid.


CAUSE
All of these limitations are necessary to support backward compatibility with 16-bit versions of Windows. They do not apply to Windows NT or Windows 2000. However, for compatibility across Windows platforms, it is best to ensure that all 32-bit DLLs conform to the constraints of Windows 95 and Windows 98.


Avatar of antenor

ASKER

ok,

But, a resource mencioned in article, are a export clausules ? or exists another soluction for this problem?

I delete some lines in the "exports" but... the error is showed.

Resources meaning resource strings, bitmaps, etc. Use a resource editor to take a look at the dll (you could also use the one in the {delphi}\demos\resxplor to view it) to determine how many resource names you have in there.

Because you are using a form in the dll, and carrying along the vcl baggage, you most likely have a quite a few resources in the dll. According to the msdn notes,

<quote>
The in-memory table requires 16 bytes for each resource within the DLL. A named resource requires an additional number of bytes equal to the length of the string plus one. Finally, about 100 bytes is required for alignment and indexing within the table. Thus, a DLL has an upper limit of about 4089 resources on Windows 95 and Windows 98, assuming none are named.
<end quote>

So 4089 is the max limit, and will be even less for those resources that have names.

---------

Russell

Avatar of antenor

ASKER

ok, tank you for help.

Do exists an application for a calculate the resource table size?  the "resxplor" don't give the total size, but amount of the resources.


I can't really say one way or the other, as I don't know. Sorry I can't help further.

Russell
Avatar of antenor

ASKER

ok, tank's.

Antenor