HELP, Calling a DLL (TWAIN.DLL)

Hello everybody

I'm a new programmer in delphi and I need a little help. I have to call
a function that is in a DLL. The definition of the function in the DLL is as
follow.
this is the original declaration on C, it is defined in a file .h

typedef LPVOID         TW_MEMREF;

typedef struct {
   TW_UINT32  Id;              /* Unique number.  In Windows, app hWnd      */
   .
   .
   .
   TW_STR32   ProductName;     /* Product name, e.g. "ScanJet Plus"         */
   } TW_IDENTITY, FAR * pTW_IDENTITY;

/* Numeric types. */
typedef unsigned short TW_UINT16, FAR *pTW_UINT16;
typedef unsigned long  TW_UINT32, FAR *pTW_UINT32;

TW_UINT16 FAR PASCAL DSM_Entry
     ( pTW_IDENTITY   pOrigin,    // source of message
       pTW_IDENTITY   pDest,      // destination of message
       TW_UINT32      DG,         // data group ID: DG_xxxx
       TW_UINT16      DAT,        // data argument type: DAT_xxxx
       TW_UINT16      MSG,        // message ID: MSG_xxxx
       TW_MEMREF      pData       // pointer to data
      );

pOrigin  this a pointer to an structure
pDest    this a pointer to an structure, sometimes it has to take a NULL
         value
pData    this a pointer to an structure
         Refers to the TW_xxxx structure or variable that will be used
         during the operation.  Its type is specified by the DAT_xxxx.
         This parameter should always be typecast to TW_MEMREF when it
         is being referenced.

how can I define this function in delphi, and call it?
I have tried diferent ways of defining it, but when i call the function DSM_entry
I get an error that I don't understand. I think the error is because the way
I make the definition in delphi
Well, I think I need a lot of help.

If someone can help me, please answer to

lte...@udc.es

A lot of thanks in advance

Luis Temes