Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8324343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:02:02+00:00 2026-06-09T00:02:02+00:00

I have a Dll function with this signature: UInt32 Authenticate(uint8 *Key); I’m doing this

  • 0

I have a Dll function with this signature:

UInt32 Authenticate(uint8 *Key);

I’m doing this on Delphi:

function Authenticate(Key:string) : UInt32; external 'mylib.dll' name 'Authenticate';

But always, the function return 10 (error code) and the application brakes :\

There is a way to do this right?

UPDATE: thanks guys! you’re the best!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T00:02:06+00:00Added an answer on June 9, 2026 at 12:02 am

    There are some problems with your code.

    1) uint8 is the equivilent of Byte in Delphi, not String.

    2) the C code is using the compiler’s default calling convention, which is usually __cdecl. Delphi’s default calling convention, on the other hand, is register instead. They are not compatible with each other. If you mismatch the calling convention, the stack and CPU registers will not be managed correctly during the function call at runtime.

    A literal translation of the C code would be this instead:

    function Authenticate(Key: PByte) : UInt32; cdecl; external 'mylib.dll';
    

    However, assuming the function is actually expecting a null-terminated string then do this instead:

    // the function is expecting a pointer to 8-bit data,
    // so DO NOT use `PChar`, which is 16-bit in Delphi 2009+...
    function Authenticate(Key: PAnsiChar) : UInt32; cdecl; external 'mylib.dll';
    

    I would stick with the first declaration, as it matches the original C code. Even if the function is expecting a null-terminated string as input, you can still pass it in using PByte via a type-cast:

    var
      S: AnsiString;
    begin
      Authenticate(PByte(PAnsiChar(S)));
    end;
    

    Or, if the function allows NULL input for empty strings:

    var
      S: AnsiString;
    begin
      Authenticate(PByte(Pointer(S)));
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have DLL and application that will call some function in this dll. For
My C++ DLL have a function like this: void func1(int& count, int* pValue); this
Have found a function address in a DLL. Have no source code for this
I want to send my C# string to a C++ DLL function. I have
I need a function in Delphi to verify the digital signature of an external
I have a vc++ dll which has a funciton call like this : typedef
Hi I have a plugin.dll which contains this all npp functions I have embeded
I have a dll with a function that takes PyObject as argument something like
I have an application that I make a call to a DLL function that
I have a .dll library which exports a function in the following format: _Java_folder1_folder2_folder3_JavaClassName_javamethodname@16

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.