Solved

Problems with dll - win98 and winXP

Posted on 2004-04-02
12
822 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.
0
Comment
Question by:antenor
  • 6
  • 5
12 Comments
 
LVL 19

Expert Comment

by:Melih SARICA
ID: 10740126
Post the Source of ur dll calling code and Dll's initialize code

...
0
 

Author Comment

by:antenor
ID: 10740215

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;


0
 
LVL 26

Accepted Solution

by:
Russell Libby earned 500 total points
ID: 10740964
Try calling GetLastError before going further in your app, just to make sure the code is not being reset by another api (behind the scenes).

eg

var
   DLLHandle : hwnd;
   dwError: DWORD;
   FullLibraryName : string;

begin
...

          FullLibraryName := DiretorioTMP+LibraryName;
          DLLHandle := LoadLibrary(Pchar(LowerCase(FullLibraryName)));
         if (DLLHandle = 0) then
         begin
            dwError:=GetLastError;
            ShowMessage(SysErrorMessage(dwError));
         end
         else
            ShowMessage('Handle: '+IntToStr(DLLHandle));

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

I have never seen a case where LoadLibrary fails, and GetLastError returns 0. (Have never seen anything documented on this in the MSDN either). Let us know what the results are....

Regards,
Russell



0
 

Author Comment

by:antenor
ID: 10741100
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"

0
 

Author Comment

by:antenor
ID: 10741144
ahhh....


The error code is "8"

0
 
LVL 26

Expert Comment

by:Russell Libby
ID: 10741166

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
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 26

Expert Comment

by:Russell Libby
ID: 10741197
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.


0
 

Author Comment

by:antenor
ID: 10742514
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.
0
 
LVL 26

Expert Comment

by:Russell Libby
ID: 10742734

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

0
 

Author Comment

by:antenor
ID: 10744004
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.

0
 
LVL 26

Expert Comment

by:Russell Libby
ID: 10744046

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

Russell
0
 

Author Comment

by:antenor
ID: 10744185
ok, tank's.

Antenor
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now