We help IT Professionals succeed at work.

Problems with dll - win98 and winXP

antenor
antenor asked
on
Medium Priority
851 Views
Last Modified: 2010-08-05
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.
Comment
Watch Question

Melih SARICAMelih SARICA
CERTIFIED EXPERT

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

...

Author

Commented:

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;


Software Engineer, Advisory
CERTIFIED EXPERT
Top Expert 2005
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
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"

Author

Commented:
ahhh....


The error code is "8"

Russell LibbySoftware Engineer, Advisory
CERTIFIED EXPERT
Top Expert 2005

Commented:

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
Russell LibbySoftware Engineer, Advisory
CERTIFIED EXPERT
Top Expert 2005

Commented:
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.


Author

Commented:
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.
Russell LibbySoftware Engineer, Advisory
CERTIFIED EXPERT
Top Expert 2005

Commented:

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

Author

Commented:
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.

Russell LibbySoftware Engineer, Advisory
CERTIFIED EXPERT
Top Expert 2005

Commented:

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

Russell

Author

Commented:
ok, tank's.

Antenor
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.