Pergunta

I was working on win7 and delphi 2010. Here is my code.

library CFGFunc;

uses
sysUtils
Un_ExFuncDll in "base\Un_ExFuncDll.pas"
...

exports
LoadExFuncsInDLL,
...

and Un_ExFuncDll.pas is here

unit Un_ExFuncDll;
interface    
uses
  Classes;
  procedure LoadexfuncsIndll(); stdcall;
  ...

After compiled, the dll doesn't work. However I replaced LoadexfuncsIndll() with LoadExFuncsInDLL()(exactly match what is in exports) in Un_ExFuncDll.pas. It then worked.

Delphi is case-insensitive. But it seems that exports in dll are case sensitive. So, what's the deal with them?

Foi útil?

Solução

Importing/exporting DLL functions IS case-sensitive, and always has been. That behavior is tied to the OS DLL loader, which is case-sensitive. That is one of the only areas of the Delphi language that is case-sensitive. This is documented behavior, at least in part:

Writing Dynamically Loaded Libraries

A name specifier consists of the directive name followed by a string constant. If an entry has no name specifier, the routine is exported under its original declared name, with the same spelling and case. Use a name clause when you want to export a routine under a different name.

Procedures and Functions (Delphi)

In your importing declaration, be sure to match the exact spelling and case of the routine's name. Later, when you call the imported routine, the name is case-insensitive.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top