Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Problems with dll - win98 and winXP

Posted on 2004-04-02
12
Medium Priority
?
834 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1500 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

636 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