Announcement

Collapse
No announcement yet.

DLL DECLARE Issue

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • DLL DECLARE Issue

    I've used PBCC60 to access DLLs before, but I'm having trouble correctly forming a DECLARE to (and/or CALLing) a DLL (Arby.dll).
    I'm told it's a standard DLL (not a COM) written in C or C#. The DLL controls (via TCP/IP) a servo hydraulic loading system
    made by Instron Corp. I was given the following information (for calls using C) for the two key functions I want to use from PBCC60.
    PSTR is presumably pointer to string. IDevice is just 0.

    BOOL WINAPI Arby_SendString(int iDevice, PSTR sCommand)
    // Send a null-terminated string to device
    // Parameters: iDevicedevice index
    // sCommand null-terminated command string
    // Returns: TRUE if successful, FALSE if any type of error

    BOOL WINAPI Arby_QueryString(int iDevice, PSTR sQuery, PSTR sReply, long lRLen)
    // Perform a query: Send query string to device & get a return reply
    // Parameters: iDevice device index
    // sQuery null-terminated query string
    // sReplybuffer for reply
    // lRLenbuffer size
    // Returns: TRUE if successful
    // sReply null-terminated reply

    Focusing on the first (Arby_SendString), I've tried about 30 variations for DECLARE and usage without success.
    An example of the key (but incomplete) code is below.
    I don't get a compiler error; rather the function returns zero, indicating failure.
    Consistent with return value (zero), the command (to change the load) has no effect. The "C3,2,0.1" is the correct command.
    The possible issues I see are:
    1 - the nature of the parameters and return value (BOOL, int and PSTR) which seem clear enough.
    2 - the calling sequence (I've tried CDECL).

    Any ideas what I'm missing? Arby.dll is 1.4 MB, if examining it can clarify the issue.

    DECLARE Function iCmd LIB "Arby.dll" ALIAS "Arby_SendString" (ByVal IDevice As INTEGER, BYVAL sCommand AS STRING POINTER) As BYTE
    GLOBAL A$, C?
    A$="C3,2,0.1"+CHR$(0): C?=7
    C?= iCmd (0, STRPTR(A$))
    IF C?<>1 THEN PRINT"Error from Arby_QSendString when sending "; A$; " Response ="; C?

  • #2
    Code:
    for -
    BOOL WINAPI Arby_SendString(int iDevice, PSTR sCommand)
    try -
    DECLARE Function iCmd LIB "Arby.dll" ALIAS "Arby_SendString" (ByVal IDevice As LONG, BYVAL sCommand AS STRING POINTER) As LONG
    See Help for LONG type for about "int", and Help for BYTE type noting difference between "bool" and "BOOL".

    Cheers,
    Dale

    Comment

    Working...
    X