ple103
ple103

Reputation: 2110

The procedure entry point <function> could not be located in the dynamic link library <dll>

I have converted all of the VB.NET DLL declarations

Declare Function SFileOpenArchive Lib "Storm.dll" Alias "#266" (ByVal lpFileName As String, ByVal dwPriority As Integer, ByVal dwFlags As Integer, ByRef hMPQ As Integer) As Boolean

over into Delphi.

function SFileOpenArchive(lpFileName: String; dwPriority, dwFlags, hMPQ: Integer): Boolean; stdcall; external 'Storm.dll';

However, when I call the functions and compile the program I get the following error:

The procedure entry point SFileOpenArchive could not be located in the dynamic link library Storm.dll.

I have ensured that:

  1. the DLL is stored in the same directory as the application
  2. the functions I have declared exist (I was given the source code which was coded in VB.NET)

What can I do to fix this error?

Thank you in advanced.

Upvotes: 2

Views: 4200

Answers (1)

David Heffernan
David Heffernan

Reputation: 613461

You have the following problems that I can see:

  1. The function has been exported by ordinal rather than name. You need to specify the ordinal in your Delphi code.
  2. The first parameter should be PAnsiChar rather than a Delphi string. The VB code uses string to instruct the marshaller to pass a null-terminated string. As a rule of thumb, it's almost always a mistake to include a Delphi managed stype like string in a DLL import or export.
  3. The final parameter is passed by reference. That's a Delphi var parameter.
  4. The return value should be BOOL, I think, but that probably won't be causing you trouble.

Put it all together like this:

function SFileOpenArchive(lpFileName: PAnsiChar; 
    dwPriority, dwFlags: Integer; var hMPQ: Integer): BOOL; 
    stdcall; external 'Storm.dll' index 266;

Note that I'm not 100% sure that the text encoding is ANSI. However, the main blockage for you was the ordinal import. I hope I've cleared that for you. I trust you can resolve the remaining details.

Upvotes: 4

Related Questions