Yet another header translation from C!

Giganews Newsgroups
Subject:Yet another header translation from C!
Posted by: David Taylor (david-tayl…@blueyonder.co.not-this-bit.nor-this-part.uk)
Date:Sat, 29 Nov 2008

Given:

  #ifdef DW_EXPORTS
  #define DW_API __declspec(dllexport)
  #else
  #define DW_API __declspec(dllimport)
  #endif

how would this translate into Delphi..

  // DW_QuerySignal
  // Param: nQuality [out] return signal Quality
  //    nStreagth [out] return signal Streagth
  //    nLock  [out] return locked or not
  //      nLock>0:locked
  // Return Value: 0 - succeed, 1 - fail
  extern DW_API int _stdcall DW_QuerySignal(int *nQuality, int *nStrength,
int *nLock);

to import a function from a DLL?

I've left the comments in in case they help.  I am confused by the single
underscore in "_stdcall".  Here is what I came up with:

imterface
function DW_QuerySignal (var nQuality, nStrength, nLock: DWORD): Longint;
stdcall;

implementation
function DW_QuerySignal; external 'DWUSBAPI.dll' index 19;

In the Dependency Walker the function shows as:

Ordinal: 19
Hint: 18
Function: ?DW_QuerySignal@@YGHPAH00@Z
Entry point: 0x00001750

Thanks,
David

Replies