Help with DLL

Help with DLL

Hi all,
I am trying to access a function in C from a DLL. The function is defined like this:

int32_t __cdecl AnalyseFile (STRCTYPE filename);

and STRCTYPE is defined as LPCWSTR in C. How do I declare this in Delphi?

I tried this but ti doesn't seem to work:

function AnalyseFile(newPath: PWideChar): LongWord; cdecl;

and I call it like this: AnalyseFile(PWideChar('Mypath'));

Anyone can spot what I am doing wrong?

Thanks

UPDATE: I had mistakenly written that the initial C declarion was stdcall instead of cdecl. I correct it now

Comments

  1. Your calling convention is wrong. STDCALL is different than cdecl. Change cdecl to STDCALL.

    ReplyDelete
  2. Yes experience is important. Understanding too. Trial and error not so much. Don't ever rely on that. That way leads to pain.

    ReplyDelete

Post a Comment