hi all
i was a able to create a .def file from lt360lib.dll using Borland C++ (impdef.exe)

LIBRARY     LT360LIB.DLL

EXPORTS
    LT360LIB_CloseLink             @3   
    LT360LIB_Cmd                   @7   
    LT360LIB_CmdIndexValue         @9   
    LT360LIB_CmdString             @10  
    LT360LIB_CmdValue              @8   
    LT360LIB_GetDllVerDate         @1   
    LT360LIB_GetUsbFirmwareVerDate @6   
    LT360LIB_LinkedCnt             @2   
    LT360LIB_OpenLinkCOM           @5   
    LT360LIB_OpenLinkUSB           @4   
    LT360LIB_ReadBinary            @12  
    LT360LIB_WriteBinary           @11

how can i convert this .def into a .lib file.
I use Microsoft visual studio 6.0, and since it was created using borland are there any changes that must be done on it before using it in VC++

hi all
i was a able to create a .def file from lt360lib.dll using Borland C++ (impdef.exe)

LIBRARY     LT360LIB.DLL

EXPORTS
    LT360LIB_CloseLink             @3   
    LT360LIB_Cmd                   @7   
    LT360LIB_CmdIndexValue         @9   
    LT360LIB_CmdString             @10  
    LT360LIB_CmdValue              @8   
    LT360LIB_GetDllVerDate         @1   
    LT360LIB_GetUsbFirmwareVerDate @6   
    LT360LIB_LinkedCnt             @2   
    LT360LIB_OpenLinkCOM           @5   
    LT360LIB_OpenLinkUSB           @4   
    LT360LIB_ReadBinary            @12  
    LT360LIB_WriteBinary           @11

how can i convert this .def into a .lib file.
I use Microsoft visual studio 6.0, and since it was created using borland are there any changes that must be done on it before using it in VC++

Assuming .def file name is LT360LIB.def, try MS's LIB utility as follows:

LIB /DEF:LT360LIB.def

was created using borland are there any changes that must be done on it before using it in VC++

Just occurred to me that probably you'll have to do some changes before using LIB.exe. Apparently the .DLL functions use __stdcall calling convention, so you'll have to modify each function so that they'll conform to the MS's name decoration convention. In practice, every function is to be appended an '@', followed by the number of bytes taken by the arguments.

I.e. if you have a library function void __stdcall function(char *, char *, char *); it would be function@12 in the .def file.

Furthermore, in your project which will include the generated .lib + its accompanying header,
1) use extern "C" {} in the header file to wrap all the exported functions.
2) make sure that the exported functions are seen as __stdcall , either use the /Gz switch or explicitly add the __stdcall to each function prototype.

Note that LIB.exe will additionally prefix every function with an underscore. So if you'll look into the .LIB's exports by e.g. dumpbin.exe /EXPORTS LT360LIB.lib you'll see something like _LT360LIB_CloseLink@0 (assuming LT360LIB_CloseLink does not arguments)

If you end up having mixed-up calling conventions, your program will crash at run-time.

I used a program called implib32 i created a.lib file directly from the dll and i linked it with my project but i got this error message

"
lt360.obj : error LNK2001: unresolved external symbol _LT360LIB_OpenLinkUSB
Debug/lt360.exe : fatal error LNK1120: 1 unresolved externals
"

i think it is due to to the header file maybe , the company that i bought my product from and supplied the dll and header files said that the header file may require modification depending on the particualr compiler/linker being used.

but im still new to the world of c++ i hope you can help me mitrmkar.
Im gonna use your advice of using the "C" after extern and __stdcall.

JUST TO MAKE SURE IF i have a function like this

extern LONGINT LT360LIB_LinkedCnt(void);

i edit it like this

extern "C" LONGINT __stdcall LT360LIB_LinkedCnt(void);

is that correct ?
thanks for all

Its worth noting too that i had problem with the header file as can be seen in a previous thread http://www.daniweb.com/forums/thread130896.htmldue to the declerations LONGBOOL and LONGINT which my compiler didnt understand , it only understands "bool" and "long int" so tried to overcome this by using

typedef  long int LONGINT;
typedef  bool LONGBOOL;

ill post the header file again for reference , any help is greatly appreciated.

// Header file for Exported Functions in LT360 control library: LT360LIB.DLL
// =========================================================================
// (C)2006 LinearX Systems Inc, Mar-01-2006, Chris N. Strahm
// =========================================================================
// This DLL provides a high level interface for controlling one or more
// LT360 turntables. Up to a maximum of 128 units are managed by the DLL.
//
// NOTE: See the DLL Programming Manual for details on using this interface.
//
// All functions communicate to the LT360 units by numeric index handle.
// Therefore the application program can manage units by keeping track of
// the index handle for each LT360 unit linked.
//
// Linking is provided either through the RS-232 COM ports or the USB bus
// of the PC.  The application program can choose which method to attempt
// a link with an LT360.
//
// All strings passed to or from the functions are ASCIIZ strings.  It is
// the responsibility of the calling program to allocate the char buffers.
// All functions use the Windows standard calling convention, passing
// parameters from right to left on the stack. The routines cleanup the stack.
// ========================================================================

// ============================================================================
// After the link is established, commands can be sent using a single function,
// LT360LIB_CmdValue.  This function takes 3 parameters. Both string and numeric
// parameters are passed using an ASCIIZ string.  Return values are passed to
// the same parameter for the Get commands.  Commands are selected by using
// different identifier constants as listed below.
// ============================================================================

// ============================================================================
// NOTE: The LT360LIB_WriteBinary and LT360LIB_ReadBinary functions are only
//       used by the LT360.EXE Win32 application for updating firmware.
//       They are not needed and should not be called by customer applications.
// ============================================================================

#ifndef LT360LIB_H
#define LT360LIB_H

#include <windows.h>

// 		=========================================================================================
// 		Identifier         		   Cmd    USB COM Data Address  Description
// 		-------------------------- ---    --- --- ---- -------  ------------------------------------------
//
// WriteBinary calls
#define lt_EnterRAM   	          0x11  /* X   -     0     11h  Enter RAM mode for Flash Programming		*/
#define lt_ExitRAM    	          0x12  /* X   -     0     12h  Exit  RAM mode, return to normal op		*/
#define lt_WriteRamData	          0x15  /* X   -    32    nnnn  Write data to flash buffer		*/
#define lt_EraseFlash	          0x16  /* X   -     0  SecNum  Erase Flash Sector, by SecNum		*/
#define lt_RamToFlash	          0x17  /* X   -     0  RomAdr  Copy Buffer RAM to RomAdr		*/
#define lt_FlashToRam             0x18  /* X   -     0  RomAdr  Copy from RomAdr to Buffer RAM (1024)		*/
#define lt_ReBoot                 0x19  /* X   -     0     19h  ReBoot LT360		*/
// SetCmd calls
#define lt_Goto_CCW               0x1C  /* X   X    16       0  Goto by CCW pos str eg. '45.0' '-135.0'		*/
#define lt_Goto_CW                0x1D  /* X   X    16       0  Goto by CW  pos str eg. '45.0' '-135.0'		*/
#define lt_Step_CCW               0x1E  /* X   X     0       0  Step by CCW		*/
#define lt_Step_CW                0x1F  /* X   X     0       0  Step by CW		*/
#define lt_SetSmartTorque         0x20  /* X   X     4       0  Set SmartTorque Str: "ON", "OFF"		*/
#define lt_SetBaudRate	          0x21  /* X   X     8       0  Set Baudrate Str: "9600"		*/
#define lt_SetOrigin	          0x22  /* X   X     0       0  Set current position as origin 0.0		*/
#define lt_SetPulseDir            0x23  /* X   X     4       0  Set Pulse Dir Str: "CCW", "CW"		*/
#define lt_SetPulseEdge           0x24  /* X   X     4       0  Set Pulse Edge Trigger Str: "RISE", "FALL"		*/
#define lt_SetStepSize 	          0x25  /* X   X    10       0  Set Degrees per Step Str: "5.0"  "0.1"		*/
#define lt_SetVelocity	          0x26  /* X   X    10       0  Set Velocity RPM Str: "1.00"  "3.00"		*/
#define lt_SetTorque              0x27  /* X   X    10       0  Set Torque % Str: "100.0"  "50.0"		*/
#define lt_SetAccelFunc           0x28  /* X   X     2       0  Set Accel Func Num Str: "0" ... "4"		*/
#define lt_SetName                0x29  /* X   X    32       0  Set Unit Name Str: "xxxxxxx"		*/
#define lt_SetProdDate            0x2A  /* X   X    12       0  Set Production Date Str: "Jan-15-2005"		*/
#define lt_SetCalDate             0x2B  /* X   X    12       0  Set Calibration Date Str: "Jan-15-2005"		*/
#define lt_SetDueDate             0x2C  /* X   X    12       0  Set Cal Due Date Str: "Jan-15-2005"		*/
#define lt_SetBacklash            0x2D  /* X   X    10       0  Set Backlash, Deg Str: "0.055"		*/
#define lt_SetMaxTorque           0x2E  /* X   X    10       0  Set MaxTorque, N*M Str: "43.5"		*/
#define lt_SetDacNoise            0x2F  /* X   X    10       0  Set DacNoise, uVrms Str: "21.3"		*/
#define lt_SetDacVhi              0x30  /* X   X    10       0  Set DacVhi, VDC Str: "3.666555"		*/
#define lt_SetDacVlo              0x31  /* X   X    10       0  Set DacVlo, VDC Str: "-1.265768"		*/
#define lt_SetPulseInput          0x32  /* X   X     4       0  Set Pulse Input Str: "OFF" "ON"		*/
#define lt_SetAnalogInput         0x33  /* X   X     4       0  Set Analog Input Str: "OFF" "ON"		*/
#define lt_SetDisplayPolarity     0x34  /* X   X    10       0  Set Display Polarity Str: "UNIPOLAR" "BIPOLAR"		*/
#define lt_SetInputPolarity       0x35  /* X   X    10       0  Set Input   Polarity Str: "UNIPOLAR" "BIPOLAR"		*/
#define lt_SetOutputPolarity      0x36  /* X   X    10       0  Set Output  Polarity Str: "UNIPOLAR" "BIPOLAR"		*/
#define lt_SetSerialNumber        0x37  /* X   X    10       0  Set Serial Number Str: "712345"		*/
#define lt_SetMoveAbort           0x38  /* X   X     0       0  Set MoveAbort, stops movement		*/
#define lt_SetMotorHomeChk        0x39  /* X   X     4       0  Set Motor Home Check, OFF/ON		*/
#define lt_SetRevCode             0x3A  /* X   X     4       0  Set PCB Revision Code, '65'=A		*/
#define lt_SetOutputMode          0x3B  /* X   X     6       0  Set OutputMode: 0=CONT, 1=START, 2=STOP		*/
#define lt_SetDacUnipolarScale    0x40  /* X   X     6       0  Set DAC Unipolar Scale Str: "FFFF" (Analog Output)		*/
#define lt_SetDacUnipolarOffset   0x41  /* X   X     6       0  Set DAC Unipolar Offset Str: "FFFF" (Analog Output)		*/
#define lt_SetDacBipolarScale     0x42  /* X   X     6       0  Set DAC Bipolar Scale Str: "FFFF" (Analog Output)		*/
#define lt_SetDacBipolarOffset    0x43  /* X   X     6       0  Set DAC Bipolar Offset Str: "FFFF" (Analog Output)		*/
#define lt_SetAdcUnipolarScale    0x44  /* X   X     6       0  Set ADC Unipolar Scale Str: "FFFF" (Analog Input)		*/
#define lt_SetAdcUnipolarOffset   0x45  /* X   X     6       0  Set ADC Unipolar Offset Str: "FFFF" (Analog Input)		*/
#define lt_SetAdcBipolarScale     0x46  /* X   X     6       0  Set ADC Bipolar Scale Str: "FFFF" (Analog Input)		*/
#define lt_SetAdcBipolarOffset    0x47  /* X   X     6       0  Set ADC Bipolar Offset Str: "FFFF" (Analog Input)		*/
#define lt_SetDacUniErrorValue    0x48  /* X   X    16       0  Set DAC Unipolar Error Value nnn at index:[0..255] Str: "nnn NNN"		*/
#define lt_SetDacBipErrorValue    0x49  /* X   X    16       0  Set DAC Bipolar Error Value nnn at index:[0..255] Str: "nnn NNN"		*/
#define lt_SetZeroDacUniError     0x4A  /* X   X     0       0  Set Zero's the DAC Unipolar Error Array		*/
#define lt_SetZeroDacBipError     0x4B  /* X   X     0       0  Set Zero's the DAC Unipolar Error Array		*/
#define lt_SetCalMode             0x4C  /* X   X     4       0  Set Calibration Mode Str: "OFF" "ON"		*/
#define lt_SetDacPosition         0x4D  /* X   X     8       0  Set DAC position in Microsteps [0..115200-1] str: "nnnnnn"		*/
#define lt_SetDacDirect           0x4E  /* X   X     8       0  Set DAC value directly [0..65535] str: "nnnnn"		*/
#define lt_SetDacCorrect          0x4F  /* X   X     4       0  Set DAC Correction Str: "OFF" "ON"		*/
#define lt_SetDebug               0x70  /* X   X     4       0  Set Special Debug mode or command		*/
#define lt_SetWriteRead           0x7F  /* X        32   CmdID  Set WriteRead for RS232, adrcmd for read		*/
// ReadBinary calls
#define lt_ReadRamData	          0x90  /* X   -    32    nnnn  Read data from flash buffer at Adr (1024)		*/
// GetCmd calls
#define lt_GetName                0x91  /* X   X    32       0  Get NAME str		*/
#define lt_GetTitle		          0x92  /* X   X    25       0  Get TITLE str "LT360 Precision Turntable"		*/
#define lt_GetAuthor	          0x93  /* X   X    15       0  Get AUTHOR str "Chris N. Strahm"		*/
#define lt_GetCopyright	          0x94  /* X   X    28       0  Get COPYRIGHT str "(C)2005 LinearX Systems Inc"		*/
#define lt_GetVerCode	          0x95  /* X   X    12       0  Get VerCode str "1.00"		*/
#define lt_GetVerDate	          0x96  /* X   X    12       0  Get VerDate str "JAN-01-2005"		*/
#define lt_GetProdDate	          0x97  /* X   X    12       0  Get ProductionDate str "JAN-01-2005"		*/
#define lt_GetCalDate	          0x98  /* X   X    12       0  Get CalibrationDate str "JAN-01-2005"		*/
#define lt_GetDueDate	          0x99  /* X   X    12       0  Get Calibration Due Date str "JAN-01-2005"		*/
#define lt_GetSerialNumber        0x9A  /* X   X    10       0  Get SerialNumber str "700001"		*/
#define lt_GetBaudRate	          0x9B  /* X   X    10       0  Get BaudRate str "9600", "19200"		*/
#define lt_GetPosition	          0x9C  /* X   X    10       0  Get Position str "15.0", "-45.0"		*/
#define lt_GetPulseDir	          0x9D  /* X   X     4       0  Get Pulse Dir str "CCW", "CW"		*/
#define lt_GetPulseEdge           0x9E  /* X   X     4       0  Get Pulse trigger Edge str "RISE", "FALL"		*/
#define lt_GetStepSize            0x9F  /* X   X    10       0  Get Step Size str "5.0", "0.1"		*/
#define lt_GetVelocity            0xA0  /* X   X    10       0  Get Velocity, RPM str "1.0", "0.1"		*/
#define lt_GetTorque              0xA1  /* X   X    10       0  Get Torque, % str "100.0", "50.0"		*/
#define lt_GetAccelFunc           0xA2  /* X   X     2       0  Get Accel Func str "0", "1" .. "3" number		*/
#define lt_GetMoving              0xA3  /* X   X     4       0  Get Moving Cond str "CCW", "NO", "CW"		*/
#define lt_GetBacklash            0xA4  /* X   X    10       0  Get Backlash, +/-Deg "0.055"		*/
#define lt_GetMaxTorque           0xA5  /* X   X    10       0  Get MaxTorque, N*M "43.5"		*/
#define lt_GetDacNoise            0xA6  /* X   X    10       0  Get DacNoise, uVrms "21.5"		*/
#define lt_GetDacVhi              0xA7  /* X   X    10       0  Get DacVhi, VDC "3.666555"		*/
#define lt_GetDacVlo              0xA8  /* X   X    10       0  Get DacVlo, VDC "-1.2666555"		*/
#define lt_GetPulseInput          0xA9  /* X   X     4       0  Get Pulse Input Status: "OFF" "ON"		*/
#define lt_GetAnalogInput         0xAA  /* X   X     4       0  Get Analog Input Status: "OFF" "ON"		*/
#define lt_GetSmartTorque         0xAB  /* X   X     4       0  Get Smart Torque Status: "OFF" "ON"		*/
#define lt_GetDisplayPolarity     0xAC  /* X   X    10       0  Get Display Polarity Status: "BIPOLAR" "UNIPOLAR"		*/
#define lt_GetInputPolarity       0xAD  /* X   X    10       0  Get Input Polarity Status: "BIPOLAR" "UNIPOLAR"		*/
#define lt_GetOutputPolarity      0xAE  /* X   X    10       0  Get Output Polarity Status: "BIPOLAR" "UNIPOLAR"		*/
#define lt_GetCalMode             0xAF  /* X   X     6       0  Get Cal Mode: "OFF" "ON"		*/
#define lt_GetDacUnipolarScale    0xB0  /* X   X     6       0  Get DAC Unipolar Scale Hex Value: "FFFF"		*/
#define lt_GetDacUnipolarOffset   0xB1  /* X   X     6       0  Get DAC Unipolar Offset Hex Value: "FFFF"		*/
#define lt_GetDacBipolarScale     0xB2  /* X   X     6       0  Get DAC Bipolar Scale Hex Value: "FFFF"		*/
#define lt_GetDacBipolarOffset    0xB3  /* X   X     6       0  Get DAC Bipolar Offset Hex Value: "FFFF"		*/
#define lt_GetAdcUnipolarScale    0xB4  /* X   X     6       0  Get Adc Unipolar Scale Hex Value: "FFFF"		*/
#define lt_GetAdcUnipolarOffset   0xB5  /* X   X     6       0  Get ADC Unipolar Offset Hex Value: "FFFF"		*/
#define lt_GetAdcBipolarScale     0xB6  /* X   X     6       0  Get ADC Bipolar Scale Hex Value: "FFFF"		*/
#define lt_GetAdcBipolarOffset    0xB7  /* X   X     6       0  Get ADC Bipolar Offset Hex Value: "FFFF"		*/
#define lt_GetAdcPosition         0xB8  /* X   X    10       0  Get ADC Position in Microsteps:: "0..115200-1" (analog input) (cal)		*/
#define lt_GetAdcVolt             0xB9  /* X   X    10       0  Get ADC voltage: 1.23345 (analog input)		*/
#define lt_GetAdcValue            0xBA  /* X   X    10       0  Get ADC Value : 0..65535 (analog input)		*/
#define lt_GetDacCorrect          0xBB  /* X   X     4       0  Get DAC Correction Status: "OFF" "ON"		*/
#define lt_GetDacDirect           0xBC  /* X   X     6       0  Get DAC value: "0..65535"		*/
#define lt_GetDacUniErrFunc       0xBD  /* X   X     4       0  Get DAC Unipolar Error value at current position: "nnn" (cal)		*/
#define lt_GetDacBipErrFunc       0xBE  /* X   X     4       0  Get DAC Bipolar Error value at current position: "nnn" (cal)		*/
#define lt_GetDacUniErrValue      0xBF  /* X   X     4       0  Get DAC Unipolar Error value at index [0..180]: "nnn" (cal)		*/
#define lt_GetDacBipErrValue      0xC0  /* X   X     4       0  Get DAC Bipolar Error value at index [0..180]: "nnn" (cal)		*/
#define lt_GetMotorHomeChk        0xC1  /* X   X     4       0  Get Motor Home Checking Status: "OFF" "ON"		*/
#define lt_GetRevCode             0xC2  /* X   X     4       0  Get PCB Revision Code, '65'=A		*/
#define lt_GetOutputMode          0xC3  /* X   X     6       0  Get OutputMode: 0=CONT, 1=START, 2=STOP		*/
#define lt_GetFlashBootLoader     0xD0  /* X   X     6       0  Get Flash Bootloader Version str: "1.52" "1.30", LPC2104		*/
#define lt_GetFlashPartID         0xD1  /* X   X    12       0  Get Flash Part ID str: "4293984018"		*/
#define lt_GetReadStr             0xF0  /* X        32       0  Get usb str from previous WriteRead from RS232 calls		*/
// ----------------------- ---    --- --- ---- -------  ------------------------------------------

// NOTE: All functions use Standard Calling Convention

//---------------------------------------------------------------------------
//  Function: 	LT360LIB_GetDllVersion
//  Abstract:   Returns the Version and Date strings of the DLL
//  Parameters: returns ver & date strs eg: nnn.nnn.nnn.nnn , Oct/11/1998
//  Returns:    None
//---------------------------------------------------------------------------
extern void LT360LIB_GetDllVerDate(char *Ver, char *Date);


//---------------------------------------------------------------------------
//  Function: 	LT360LIB_LinkedCnt
//  Abstract:   Returns the number of LT360 with active links (0..128)
//  Parameters: None
//  Returns:    Number of LT360 units with active links via USB or RS-232
//---------------------------------------------------------------------------
extern LONGINT LT360LIB_LinkedCnt(void);


//---------------------------------------------------------------------------
//  Function: 	LT360LIB_OpenLinkUSB
//  Abstract:   Attempts to find and link one LT360 over the USB bus.
//              Since more than one LT360 may be on the USB bus,
//              this routine can be called repeatly until all of
//              the LT360 units on the USB bus are found (return=0).
//  Parameters: None
//  Returns:    LT360_Index > 0 if found, else 0 if no LT360 found.
//---------------------------------------------------------------------------
extern LONGINT LT360LIB_OpenLinkUSB(void);


//---------------------------------------------------------------------------
//  Function: 	LT360LIB_OpenLinkCOM
//  Abstract:   Attempts to find and link one LT360 over an RS-232 port.
//              Since only one LT360 can be on a single COM port,
//              this routine is called using different COM ports (1,2,3,4..)
//              for each LT360 unit to be linked. If not found, return=0.
//              Note: The BaudRate here must match what the LT360 is using.
//                    The LT360 uses 9600 by default unless it has been changed.
//  Parameters: ComNum (1,2,3,4...) , BaudRate (9600, 19200, etc)
//  Returns:    Handle > 0 if found, else 0 if no LT360 found.
//---------------------------------------------------------------------------
extern LONGINT LT360LIB_OpenLinkCOM(LONGINT ComNum, LONGINT BaudRate);


//---------------------------------------------------------------------------
//  Function: 	LT360LIB_CloseLink
//  Abstract:   Closes/Unlinks the LT360 given by index number (RS232 or USB)
//  Parameters: LT360_Index (1..LinkedCnt)
//  Returns:    Returns TRUE if link closed successfully
//---------------------------------------------------------------------------
extern LONGBOOL LT360LIB_CloseLink(LONGINT Handle);


//---------------------------------------------------------------------------
//  Function: 	LT360LIB_GetUsbFirmwareVerDate
//  Abstract:   Obtains the strings for the Version and Date of the USB
//              controller firmware inside the LT360.
//              The LT360 given by the index number must have USB link.
//  Parameters: LT360_Index, ptrs for Version and Date strings
//  Returns:    Returns TRUE if executed successfully
//---------------------------------------------------------------------------
extern LONGBOOL LT360LIB_GetUsbFirmwareVerDate(LONGINT LT360_Index, char *UsbFirmwareRev, char *UsbFirmwareDate);


//---------------------------------------------------------------------------
//  Function: 	LT360LIB_Cmd
//  Abstract:   Sends a Command to the LT360
//              Also dislays error message dialog if command fails
//  Parameters: Handle: LT360 Index returned from Link
//              CmdID : Command Identifier
//  Returns:    Returns TRUE if executed successfully
//---------------------------------------------------------------------------
extern LONGBOOL LT360LIB_Cmd(LONGINT Handle, LONGINT CmdID);


//---------------------------------------------------------------------------
//  Function: 	LT360LIB_CmdValue
//  Abstract:   Sends a Command to the LT360
//              Also dislays error message dialog if command fails
//  Parameters: Handle: LT360 Index returned from Link
//              CmdID : Command Identifier
//              ParamValue : Parameter String for Value, may be nil
//                           Get calls return strings in ParamValue
//  Returns:    Returns TRUE if executed successfully
//---------------------------------------------------------------------------
extern LONGBOOL LT360LIB_CmdValue(LONGINT Handle, LONGINT CmdID, char *ParamValue);


//---------------------------------------------------------------------------
//  Function: 	LT360LIB_CmdIndexValue
//  Abstract:   Sends a Command to the LT360
//              Also dislays error message dialog if command fails
//  Parameters: Handle: LT360 Index returned from Link
//              CmdID : Command Identifier
//              ParamIndex : Parameter String for Index, may be nil
//              ParamValue : Parameter String for Value, may be nil
//                           Get calls return strings in ParamValue
//  Returns:    Returns TRUE if executed successfully
//---------------------------------------------------------------------------
extern LONGBOOL LT360LIB_CmdIndexValue(LONGINT Handle, LONGINT CmdID, char *ParamIndex, char *ParamValue);


//---------------------------------------------------------------------------
//  Function: 	LT360LIB_CmdString
//  Abstract:   Returns the Cmd str used for COM port calls.
//  Parameters: CmdID
//  Returns:    Returns command str if executed successfully, empty if bad CmdIndex
//---------------------------------------------------------------------------
extern char *LT360LIB_CmdString(LONGINT CmdID);


//---------------------------------------------------------------------------
//  Function: 	LT360LIB_WriteBinary
//  Abstract:   USB binary data write command.
//              P is a pointer to the data array to be written.
//              Maximum DataByteCnt=32, Adr depends on command
//  Parameters: LT360_Index, CmdIndex, DataByteCnt, Adr
//  Returns:    Returns TRUE if executed successfully
//---------------------------------------------------------------------------
extern LONGBOOL LT360LIB_WriteBinary(LONGINT Handle, LONGINT CmdIndex, LONGINT DataByteCnt, LONGINT Adr, Pointer P);


//---------------------------------------------------------------------------
//  Function: 	LT360LIB_ReadBinary
//  Abstract:   USB binary data read command.
//              P is a pointer to the data array to be returned.
//              Maximum DataByteCnt=32, Adr depends on command
//  Parameters: LT360_Index, CmdIndex, DataByteCnt, Adr
//  Returns:    Returns TRUE if executed successfully
//---------------------------------------------------------------------------
extern LONGBOOL LT360LIB_ReadBinary(LONGINT Handle, LONGINT CmdIndex, LONGINT DataByteCnt, LONGINT Adr, Pointer P);

/*
Function LT360LIB_GetDllVerDate;			External 'LT360LIB.DLL' Index 01;
Function LT360LIB_LinkedCnt;	    	    External 'LT360LIB.DLL' Index 02;
Function LT360LIB_CloseLink;		        External 'LT360LIB.DLL' Index 03;
Function LT360LIB_OpenLinkUSB;	    	    External 'LT360LIB.DLL' Index 04;
Function LT360LIB_OpenLinkCOM;		        External 'LT360LIB.DLL' Index 05;
Function LT360LIB_GetUsbFirmwareVerDate;    External 'LT360LIB.DLL' Index 06;
Function LT360LIB_Cmd;  		            External 'LT360LIB.DLL' Index 07;
Function LT360LIB_CmdValue;		            External 'LT360LIB.DLL' Index 08;
Function LT360LIB_CmdIndexValue;            External 'LT360LIB.DLL' Index 09;
Function LT360LIB_CmdString;		        External 'LT360LIB.DLL' Index 10;
Function LT360LIB_WriteBinary;		        External 'LT360LIB.DLL' Index 11;
Function LT360LIB_ReadBinary;		        External 'LT360LIB.DLL' Index 12;
*/

#endif	// LT360LIB_H

hi agian i think your method work i used the lib.exe , now the project its compiling and building i got errors when i used the __stdcall but when i removed it it worked, but the "C" was the key thanks again . In the future you are the go to man thanks again

I used a program called implib32 i created a.lib file directly from the dll and i linked it with my project but i got this error message
"
lt360.obj : error LNK2001: unresolved external symbol _LT360LIB_OpenLinkUSB
Debug/lt360.exe : fatal error LNK1120: 1 unresolved externals
"

At compile time, the LT360LIB_OpenLinkUSB() is apparently seen as __cdecl but it is __stdcall.
So you probably have been missing the step(s) to modify the header so that every function prototype is: extern "C" <return type> __stdcall function(<args>);

now the project its compiling and building i got errors when i used the __stdcall but when i removed it it worked

Sounds as there's still some sort of mismatch if it seems to work without __stdcall prototypes. If you get run-time errors (in debug builds) complaining about a failure to save ESP properly, then you'll have to revise and fix this import library generation. With release builds, you'll probably get access violation errors.

About the LONGBOOL, I guess that it might be actually


typedef int LONGBOOL;


Anyway, try to check those typedefs with the software vendor. (Who really should provide a ready-to-use package).

unfortunately man what you said happened seems i tested it on one function and gave no problem , but when i tried another function what you said exactly happened "failure to save ESP properly" ill revise what i did and ill contact hopefully soon
thanks again my friend

by the way when i created th lib file i got a .exp file what is it for?

i tried to add __stdcall to the prototypes in the header file but still get the "failure to save ESP properly" message what should i do.

my edited header file is at the end ( i added the "C" and __stdcall to all the prototypes)

by the way there is also a pointer data type that the compiler didnt understand "the functions that used it are at the bottom and are in bold" ,so i used typedef

typedef int Pointer;

but the comments said
" P is a pointer to the data array to be written.
// Maximum DataByteCnt=32, Adr depends on command"

so should i have used a pointer declaration and if so how can i declare a new name to a pointer using typedef.
Thanks for continuous help

// Header file for Exported Functions in LT360 control library: LT360LIB.DLL
// =========================================================================
// (C)2006 LinearX Systems Inc, Mar-01-2006, Chris N. Strahm
// =========================================================================
// This DLL provides a high level interface for controlling one or more
// LT360 turntables. Up to a maximum of 128 units are managed by the DLL.
//
// NOTE: See the DLL Programming Manual for details on using this interface.
//
// All functions communicate to the LT360 units by numeric index handle.
// Therefore the application program can manage units by keeping track of
// the index handle for each LT360 unit linked.
//
// Linking is provided either through the RS-232 COM ports or the USB bus
// of the PC.  The application program can choose which method to attempt
// a link with an LT360.
//
// All strings passed to or from the functions are ASCIIZ strings.  It is
// the responsibility of the calling program to allocate the char buffers.
// All functions use the Windows standard calling convention, passing
// parameters from right to left on the stack. The routines cleanup the stack.
// ========================================================================

// ============================================================================
// After the link is established, commands can be sent using a single function,
// LT360LIB_CmdValue.  This function takes 3 parameters. Both string and numeric
// parameters are passed using an ASCIIZ string.  Return values are passed to
// the same parameter for the Get commands.  Commands are selected by using
// different identifier constants as listed below.
// ============================================================================

// ============================================================================
// NOTE: The LT360LIB_WriteBinary and LT360LIB_ReadBinary functions are only
//       used by the LT360.EXE Win32 application for updating firmware.
//       They are not needed and should not be called by customer applications.
// ============================================================================

#ifndef LT360LIB_H
#define LT360LIB_H

#include <windows.h>
typedef  long int LONGINT;
typedef  bool LONGBOOL;
typedef int Pointer;
// 		=========================================================================================
// 		Identifier         		   Cmd    USB COM Data Address  Description
// 		-------------------------- ---    --- --- ---- -------  ------------------------------------------
//
// WriteBinary calls
#define lt_EnterRAM   	          0x11  /* X   -     0     11h  Enter RAM mode for Flash Programming		*/
#define lt_ExitRAM    	          0x12  /* X   -     0     12h  Exit  RAM mode, return to normal op		*/
#define lt_WriteRamData	          0x15  /* X   -    32    nnnn  Write data to flash buffer		*/
#define lt_EraseFlash	          0x16  /* X   -     0  SecNum  Erase Flash Sector, by SecNum		*/
#define lt_RamToFlash	          0x17  /* X   -     0  RomAdr  Copy Buffer RAM to RomAdr		*/
#define lt_FlashToRam             0x18  /* X   -     0  RomAdr  Copy from RomAdr to Buffer RAM (1024)		*/
#define lt_ReBoot                 0x19  /* X   -     0     19h  ReBoot LT360		*/
// SetCmd calls
#define lt_Goto_CCW               0x1C  /* X   X    16       0  Goto by CCW pos str eg. '45.0' '-135.0'		*/
#define lt_Goto_CW                0x1D  /* X   X    16       0  Goto by CW  pos str eg. '45.0' '-135.0'		*/
#define lt_Step_CCW               0x1E  /* X   X     0       0  Step by CCW		*/
#define lt_Step_CW                0x1F  /* X   X     0       0  Step by CW		*/
#define lt_SetSmartTorque         0x20  /* X   X     4       0  Set SmartTorque Str: "ON", "OFF"		*/
#define lt_SetBaudRate	          0x21  /* X   X     8       0  Set Baudrate Str: "9600"		*/
#define lt_SetOrigin	          0x22  /* X   X     0       0  Set current position as origin 0.0		*/
#define lt_SetPulseDir            0x23  /* X   X     4       0  Set Pulse Dir Str: "CCW", "CW"		*/
#define lt_SetPulseEdge           0x24  /* X   X     4       0  Set Pulse Edge Trigger Str: "RISE", "FALL"		*/
#define lt_SetStepSize 	          0x25  /* X   X    10       0  Set Degrees per Step Str: "5.0"  "0.1"		*/
#define lt_SetVelocity	          0x26  /* X   X    10       0  Set Velocity RPM Str: "1.00"  "3.00"		*/
#define lt_SetTorque              0x27  /* X   X    10       0  Set Torque % Str: "100.0"  "50.0"		*/
#define lt_SetAccelFunc           0x28  /* X   X     2       0  Set Accel Func Num Str: "0" ... "4"		*/
#define lt_SetName                0x29  /* X   X    32       0  Set Unit Name Str: "xxxxxxx"		*/
#define lt_SetProdDate            0x2A  /* X   X    12       0  Set Production Date Str: "Jan-15-2005"		*/
#define lt_SetCalDate             0x2B  /* X   X    12       0  Set Calibration Date Str: "Jan-15-2005"		*/
#define lt_SetDueDate             0x2C  /* X   X    12       0  Set Cal Due Date Str: "Jan-15-2005"		*/
#define lt_SetBacklash            0x2D  /* X   X    10       0  Set Backlash, Deg Str: "0.055"		*/
#define lt_SetMaxTorque           0x2E  /* X   X    10       0  Set MaxTorque, N*M Str: "43.5"		*/
#define lt_SetDacNoise            0x2F  /* X   X    10       0  Set DacNoise, uVrms Str: "21.3"		*/
#define lt_SetDacVhi              0x30  /* X   X    10       0  Set DacVhi, VDC Str: "3.666555"		*/
#define lt_SetDacVlo              0x31  /* X   X    10       0  Set DacVlo, VDC Str: "-1.265768"		*/
#define lt_SetPulseInput          0x32  /* X   X     4       0  Set Pulse Input Str: "OFF" "ON"		*/
#define lt_SetAnalogInput         0x33  /* X   X     4       0  Set Analog Input Str: "OFF" "ON"		*/
#define lt_SetDisplayPolarity     0x34  /* X   X    10       0  Set Display Polarity Str: "UNIPOLAR" "BIPOLAR"		*/
#define lt_SetInputPolarity       0x35  /* X   X    10       0  Set Input   Polarity Str: "UNIPOLAR" "BIPOLAR"		*/
#define lt_SetOutputPolarity      0x36  /* X   X    10       0  Set Output  Polarity Str: "UNIPOLAR" "BIPOLAR"		*/
#define lt_SetSerialNumber        0x37  /* X   X    10       0  Set Serial Number Str: "712345"		*/
#define lt_SetMoveAbort           0x38  /* X   X     0       0  Set MoveAbort, stops movement		*/
#define lt_SetMotorHomeChk        0x39  /* X   X     4       0  Set Motor Home Check, OFF/ON		*/
#define lt_SetRevCode             0x3A  /* X   X     4       0  Set PCB Revision Code, '65'=A		*/
#define lt_SetOutputMode          0x3B  /* X   X     6       0  Set OutputMode: 0=CONT, 1=START, 2=STOP		*/
#define lt_SetDacUnipolarScale    0x40  /* X   X     6       0  Set DAC Unipolar Scale Str: "FFFF" (Analog Output)		*/
#define lt_SetDacUnipolarOffset   0x41  /* X   X     6       0  Set DAC Unipolar Offset Str: "FFFF" (Analog Output)		*/
#define lt_SetDacBipolarScale     0x42  /* X   X     6       0  Set DAC Bipolar Scale Str: "FFFF" (Analog Output)		*/
#define lt_SetDacBipolarOffset    0x43  /* X   X     6       0  Set DAC Bipolar Offset Str: "FFFF" (Analog Output)		*/
#define lt_SetAdcUnipolarScale    0x44  /* X   X     6       0  Set ADC Unipolar Scale Str: "FFFF" (Analog Input)		*/
#define lt_SetAdcUnipolarOffset   0x45  /* X   X     6       0  Set ADC Unipolar Offset Str: "FFFF" (Analog Input)		*/
#define lt_SetAdcBipolarScale     0x46  /* X   X     6       0  Set ADC Bipolar Scale Str: "FFFF" (Analog Input)		*/
#define lt_SetAdcBipolarOffset    0x47  /* X   X     6       0  Set ADC Bipolar Offset Str: "FFFF" (Analog Input)		*/
#define lt_SetDacUniErrorValue    0x48  /* X   X    16       0  Set DAC Unipolar Error Value nnn at index:[0..255] Str: "nnn NNN"		*/
#define lt_SetDacBipErrorValue    0x49  /* X   X    16       0  Set DAC Bipolar Error Value nnn at index:[0..255] Str: "nnn NNN"		*/
#define lt_SetZeroDacUniError     0x4A  /* X   X     0       0  Set Zero's the DAC Unipolar Error Array		*/
#define lt_SetZeroDacBipError     0x4B  /* X   X     0       0  Set Zero's the DAC Unipolar Error Array		*/
#define lt_SetCalMode             0x4C  /* X   X     4       0  Set Calibration Mode Str: "OFF" "ON"		*/
#define lt_SetDacPosition         0x4D  /* X   X     8       0  Set DAC position in Microsteps [0..115200-1] str: "nnnnnn"		*/
#define lt_SetDacDirect           0x4E  /* X   X     8       0  Set DAC value directly [0..65535] str: "nnnnn"		*/
#define lt_SetDacCorrect          0x4F  /* X   X     4       0  Set DAC Correction Str: "OFF" "ON"		*/
#define lt_SetDebug               0x70  /* X   X     4       0  Set Special Debug mode or command		*/
#define lt_SetWriteRead           0x7F  /* X        32   CmdID  Set WriteRead for RS232, adrcmd for read		*/
// ReadBinary calls
#define lt_ReadRamData	          0x90  /* X   -    32    nnnn  Read data from flash buffer at Adr (1024)		*/
// GetCmd calls
#define lt_GetName                0x91  /* X   X    32       0  Get NAME str		*/
#define lt_GetTitle		          0x92  /* X   X    25       0  Get TITLE str "LT360 Precision Turntable"		*/
#define lt_GetAuthor	          0x93  /* X   X    15       0  Get AUTHOR str "Chris N. Strahm"		*/
#define lt_GetCopyright	          0x94  /* X   X    28       0  Get COPYRIGHT str "(C)2005 LinearX Systems Inc"		*/
#define lt_GetVerCode	          0x95  /* X   X    12       0  Get VerCode str "1.00"		*/
#define lt_GetVerDate	          0x96  /* X   X    12       0  Get VerDate str "JAN-01-2005"		*/
#define lt_GetProdDate	          0x97  /* X   X    12       0  Get ProductionDate str "JAN-01-2005"		*/
#define lt_GetCalDate	          0x98  /* X   X    12       0  Get CalibrationDate str "JAN-01-2005"		*/
#define lt_GetDueDate	          0x99  /* X   X    12       0  Get Calibration Due Date str "JAN-01-2005"		*/
#define lt_GetSerialNumber        0x9A  /* X   X    10       0  Get SerialNumber str "700001"		*/
#define lt_GetBaudRate	          0x9B  /* X   X    10       0  Get BaudRate str "9600", "19200"		*/
#define lt_GetPosition	          0x9C  /* X   X    10       0  Get Position str "15.0", "-45.0"		*/
#define lt_GetPulseDir	          0x9D  /* X   X     4       0  Get Pulse Dir str "CCW", "CW"		*/
#define lt_GetPulseEdge           0x9E  /* X   X     4       0  Get Pulse trigger Edge str "RISE", "FALL"		*/
#define lt_GetStepSize            0x9F  /* X   X    10       0  Get Step Size str "5.0", "0.1"		*/
#define lt_GetVelocity            0xA0  /* X   X    10       0  Get Velocity, RPM str "1.0", "0.1"		*/
#define lt_GetTorque              0xA1  /* X   X    10       0  Get Torque, % str "100.0", "50.0"		*/
#define lt_GetAccelFunc           0xA2  /* X   X     2       0  Get Accel Func str "0", "1" .. "3" number		*/
#define lt_GetMoving              0xA3  /* X   X     4       0  Get Moving Cond str "CCW", "NO", "CW"		*/
#define lt_GetBacklash            0xA4  /* X   X    10       0  Get Backlash, +/-Deg "0.055"		*/
#define lt_GetMaxTorque           0xA5  /* X   X    10       0  Get MaxTorque, N*M "43.5"		*/
#define lt_GetDacNoise            0xA6  /* X   X    10       0  Get DacNoise, uVrms "21.5"		*/
#define lt_GetDacVhi              0xA7  /* X   X    10       0  Get DacVhi, VDC "3.666555"		*/
#define lt_GetDacVlo              0xA8  /* X   X    10       0  Get DacVlo, VDC "-1.2666555"		*/
#define lt_GetPulseInput          0xA9  /* X   X     4       0  Get Pulse Input Status: "OFF" "ON"		*/
#define lt_GetAnalogInput         0xAA  /* X   X     4       0  Get Analog Input Status: "OFF" "ON"		*/
#define lt_GetSmartTorque         0xAB  /* X   X     4       0  Get Smart Torque Status: "OFF" "ON"		*/
#define lt_GetDisplayPolarity     0xAC  /* X   X    10       0  Get Display Polarity Status: "BIPOLAR" "UNIPOLAR"		*/
#define lt_GetInputPolarity       0xAD  /* X   X    10       0  Get Input Polarity Status: "BIPOLAR" "UNIPOLAR"		*/
#define lt_GetOutputPolarity      0xAE  /* X   X    10       0  Get Output Polarity Status: "BIPOLAR" "UNIPOLAR"		*/
#define lt_GetCalMode             0xAF  /* X   X     6       0  Get Cal Mode: "OFF" "ON"		*/
#define lt_GetDacUnipolarScale    0xB0  /* X   X     6       0  Get DAC Unipolar Scale Hex Value: "FFFF"		*/
#define lt_GetDacUnipolarOffset   0xB1  /* X   X     6       0  Get DAC Unipolar Offset Hex Value: "FFFF"		*/
#define lt_GetDacBipolarScale     0xB2  /* X   X     6       0  Get DAC Bipolar Scale Hex Value: "FFFF"		*/
#define lt_GetDacBipolarOffset    0xB3  /* X   X     6       0  Get DAC Bipolar Offset Hex Value: "FFFF"		*/
#define lt_GetAdcUnipolarScale    0xB4  /* X   X     6       0  Get Adc Unipolar Scale Hex Value: "FFFF"		*/
#define lt_GetAdcUnipolarOffset   0xB5  /* X   X     6       0  Get ADC Unipolar Offset Hex Value: "FFFF"		*/
#define lt_GetAdcBipolarScale     0xB6  /* X   X     6       0  Get ADC Bipolar Scale Hex Value: "FFFF"		*/
#define lt_GetAdcBipolarOffset    0xB7  /* X   X     6       0  Get ADC Bipolar Offset Hex Value: "FFFF"		*/
#define lt_GetAdcPosition         0xB8  /* X   X    10       0  Get ADC Position in Microsteps:: "0..115200-1" (analog input) (cal)		*/
#define lt_GetAdcVolt             0xB9  /* X   X    10       0  Get ADC voltage: 1.23345 (analog input)		*/
#define lt_GetAdcValue            0xBA  /* X   X    10       0  Get ADC Value : 0..65535 (analog input)		*/
#define lt_GetDacCorrect          0xBB  /* X   X     4       0  Get DAC Correction Status: "OFF" "ON"		*/
#define lt_GetDacDirect           0xBC  /* X   X     6       0  Get DAC value: "0..65535"		*/
#define lt_GetDacUniErrFunc       0xBD  /* X   X     4       0  Get DAC Unipolar Error value at current position: "nnn" (cal)		*/
#define lt_GetDacBipErrFunc       0xBE  /* X   X     4       0  Get DAC Bipolar Error value at current position: "nnn" (cal)		*/
#define lt_GetDacUniErrValue      0xBF  /* X   X     4       0  Get DAC Unipolar Error value at index [0..180]: "nnn" (cal)		*/
#define lt_GetDacBipErrValue      0xC0  /* X   X     4       0  Get DAC Bipolar Error value at index [0..180]: "nnn" (cal)		*/
#define lt_GetMotorHomeChk        0xC1  /* X   X     4       0  Get Motor Home Checking Status: "OFF" "ON"		*/
#define lt_GetRevCode             0xC2  /* X   X     4       0  Get PCB Revision Code, '65'=A		*/
#define lt_GetOutputMode          0xC3  /* X   X     6       0  Get OutputMode: 0=CONT, 1=START, 2=STOP		*/
#define lt_GetFlashBootLoader     0xD0  /* X   X     6       0  Get Flash Bootloader Version str: "1.52" "1.30", LPC2104		*/
#define lt_GetFlashPartID         0xD1  /* X   X    12       0  Get Flash Part ID str: "4293984018"		*/
#define lt_GetReadStr             0xF0  /* X        32       0  Get usb str from previous WriteRead from RS232 calls		*/
// ----------------------- ---    --- --- ---- -------  ------------------------------------------


// NOTE: All functions use Standard Calling Convention

//---------------------------------------------------------------------------
//  Function: 	LT360LIB_GetDllVersion
//  Abstract:   Returns the Version and Date strings of the DLL
//  Parameters: returns ver & date strs eg: nnn.nnn.nnn.nnn , Oct/11/1998
//  Returns:    None
//---------------------------------------------------------------------------
extern "C" void __stdcall LT360LIB_GetDllVerDate(char *Ver, char *Date);


//---------------------------------------------------------------------------
//  Function: 	LT360LIB_LinkedCnt
//  Abstract:   Returns the number of LT360 with active links (0..128)
//  Parameters: None
//  Returns:    Number of LT360 units with active links via USB or RS-232
//---------------------------------------------------------------------------
extern "C" __stdcall LONGINT LT360LIB_LinkedCnt(void);


//---------------------------------------------------------------------------
//  Function: 	LT360LIB_OpenLinkUSB
//  Abstract:   Attempts to find and link one LT360 over the USB bus.
//              Since more than one LT360 may be on the USB bus,
//              this routine can be called repeatly until all of
//              the LT360 units on the USB bus are found (return=0).
//  Parameters: None
//  Returns:    LT360_Index > 0 if found, else 0 if no LT360 found.
//---------------------------------------------------------------------------
extern "C" LONGINT __stdcall LT360LIB_OpenLinkUSB(void);


//---------------------------------------------------------------------------
//  Function: 	LT360LIB_OpenLinkCOM
//  Abstract:   Attempts to find and link one LT360 over an RS-232 port.
//              Since only one LT360 can be on a single COM port,
//              this routine is called using different COM ports (1,2,3,4..)
//              for each LT360 unit to be linked. If not found, return=0.
//              Note: The BaudRate here must match what the LT360 is using.
//                    The LT360 uses 9600 by default unless it has been changed.
//  Parameters: ComNum (1,2,3,4...) , BaudRate (9600, 19200, etc)
//  Returns:    Handle > 0 if found, else 0 if no LT360 found.
//---------------------------------------------------------------------------
extern "C" LONGINT __stdcall LT360LIB_OpenLinkCOM(LONGINT ComNum, LONGINT BaudRate);


//---------------------------------------------------------------------------
//  Function: 	LT360LIB_CloseLink
//  Abstract:   Closes/Unlinks the LT360 given by index number (RS232 or USB)
//  Parameters: LT360_Index (1..LinkedCnt)
//  Returns:    Returns TRUE if link closed successfully
//---------------------------------------------------------------------------
extern "C" LONGBOOL __stdcall LT360LIB_CloseLink(LONGINT Handle);


//---------------------------------------------------------------------------
//  Function: 	LT360LIB_GetUsbFirmwareVerDate
//  Abstract:   Obtains the strings for the Version and Date of the USB
//              controller firmware inside the LT360.
//              The LT360 given by the index number must have USB link.
//  Parameters: LT360_Index, ptrs for Version and Date strings
//  Returns:    Returns TRUE if executed successfully
//---------------------------------------------------------------------------
extern "C" LONGBOOL __stdcall LT360LIB_GetUsbFirmwareVerDate(LONGINT LT360_Index, char *UsbFirmwareRev, char *UsbFirmwareDate);


//---------------------------------------------------------------------------
//  Function: 	LT360LIB_Cmd
//  Abstract:   Sends a Command to the LT360
//              Also dislays error message dialog if command fails
//  Parameters: Handle: LT360 Index returned from Link
//              CmdID : Command Identifier
//  Returns:    Returns TRUE if executed successfully
//---------------------------------------------------------------------------
extern "C" LONGBOOL  __stdcall LT360LIB_Cmd(LONGINT Handle, LONGINT CmdID);


//---------------------------------------------------------------------------
//  Function: 	LT360LIB_CmdValue
//  Abstract:   Sends a Command to the LT360
//              Also dislays error message dialog if command fails
//  Parameters: Handle: LT360 Index returned from Link
//              CmdID : Command Identifier
//              ParamValue : Parameter String for Value, may be nil
//                           Get calls return strings in ParamValue
//  Returns:    Returns TRUE if executed successfully
//---------------------------------------------------------------------------
extern "C" LONGBOOL _stdcall LT360LIB_CmdValue(LONGINT Handle, LONGINT CmdID, char *ParamValue);


//---------------------------------------------------------------------------
//  Function: 	LT360LIB_CmdIndexValue
//  Abstract:   Sends a Command to the LT360
//              Also dislays error message dialog if command fails
//  Parameters: Handle: LT360 Index returned from Link
//              CmdID : Command Identifier
//              ParamIndex : Parameter String for Index, may be nil
//              ParamValue : Parameter String for Value, may be nil
//                           Get calls return strings in ParamValue
//  Returns:    Returns TRUE if executed successfully
//---------------------------------------------------------------------------
extern "C" LONGBOOL __stdcall LT360LIB_CmdIndexValue(LONGINT Handle, LONGINT CmdID, char *ParamIndex, char *ParamValue);


//---------------------------------------------------------------------------
//  Function: 	LT360LIB_CmdString
//  Abstract:   Returns the Cmd str used for COM port calls.
//  Parameters: CmdID
//  Returns:    Returns command str if executed successfully, empty if bad CmdIndex
//---------------------------------------------------------------------------
extern "C" char * __stdcall LT360LIB_CmdString(LONGINT CmdID);


//---------------------------------------------------------------------------
//  Function: 	LT360LIB_WriteBinary
//  Abstract:   USB binary data write command.
//              P is a pointer to the data array to be written.
//              Maximum DataByteCnt=32, Adr depends on command
//  Parameters: LT360_Index, CmdIndex, DataByteCnt, Adr
//  Returns:    Returns TRUE if executed successfully
//---------------------------------------------------------------------------
[B]extern "C" LONGBOOL __stdcall LT360LIB_WriteBinary(LONGINT Handle, LONGINT CmdIndex, LONGINT DataByteCnt, LONGINT Adr, Pointer P);
[/B]

//---------------------------------------------------------------------------
//  Function: 	LT360LIB_ReadBinary
//  Abstract:   USB binary data read command.
//              P is a pointer to the data array to be returned.
//              Maximum DataByteCnt=32, Adr depends on command
//  Parameters: LT360_Index, CmdIndex, DataByteCnt, Adr
//  Returns:    Returns TRUE if executed successfully
//---------------------------------------------------------------------------
[B]extern "C" LONGBOOL __stdcall LT360LIB_ReadBinary(LONGINT Handle, LONGINT CmdIndex, LONGINT DataByteCnt, LONGINT Adr, Pointer P);
[/B]
/*
Function LT360LIB_GetDllVerDate;			External 'LT360LIB.DLL' Index 01;
Function LT360LIB_LinkedCnt;	    	    External 'LT360LIB.DLL' Index 02;
Function LT360LIB_CloseLink;		        External 'LT360LIB.DLL' Index 03;
Function LT360LIB_OpenLinkUSB;	    	    External 'LT360LIB.DLL' Index 04;
Function LT360LIB_OpenLinkCOM;		        External 'LT360LIB.DLL' Index 05;
Function LT360LIB_GetUsbFirmwareVerDate;    External 'LT360LIB.DLL' Index 06;
Function LT360LIB_Cmd;  		            External 'LT360LIB.DLL' Index 07;
Function LT360LIB_CmdValue;		            External 'LT360LIB.DLL' Index 08;
Function LT360LIB_CmdIndexValue;            External 'LT360LIB.DLL' Index 09;
Function LT360LIB_CmdString;		        External 'LT360LIB.DLL' Index 10;
Function LT360LIB_WriteBinary;		        External 'LT360LIB.DLL' Index 11;
Function LT360LIB_ReadBinary;		        External 'LT360LIB.DLL' Index 12;
*/

#endif	// LT360LIB_H

by the way when i created th lib file i got a .exp file what is it for?

.exp files contain information about exported items, used when your program both imports/exports from another one.

Post the output of the following command:

dumpbin /EXPORTS LT360LIB.lib


I guess the Pointer type is:

typedef unsigned char * Pointer;

and the LONGBOOL type is

typedef  int LONGBOOL;

Stressing again, try verifying these typedefs with the software vendor, so you don't have to be making guesses.

I think the header is otherwise OK.

E:\>dumpbin /exports lt360lib.lib
Microsoft (R) COFF Binary File Dumper Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.


Dump of file lt360lib.lib

File Type: LIBRARY

Exports

ordinal name

3 _LT360LIB_CloseLink
7 _LT360LIB_Cmd
9 _LT360LIB_CmdIndexValue
10 _LT360LIB_CmdString
8 _LT360LIB_CmdValue
1 _LT360LIB_GetDllVerDate
6 _LT360LIB_GetUsbFirmwareVerDate
2 _LT360LIB_LinkedCnt
5 _LT360LIB_OpenLinkCOM
4 _LT360LIB_OpenLinkUSB
12 _LT360LIB_ReadBinary
11 _LT360LIB_WriteBinary

Summary

C9 .debug$S
14 .idata$2
14 .idata$3
4 .idata$4
4 .idata$5
E .idata$6

i think you are right about the LONGBOOL and by the way for the .exp do i need it and how can i use it.
Thanks


"The intrinsic LongBool represents boolean values, but occupies the same memory space as a LongInt. It is used when you need to define a parameter or record that conforms to some external library or system specification."
quote from
http://www.mirrorservice.org/sites/www.gnu-pascal.de/gpc-hr/LongBool.html

and by the way for the .exp do i need it and how can i use it.
Thanks

The .def file you are using is wrong.
Given the prototype extern "C" LONGBOOL __stdcall LT360LIB_CloseLink(LONGINT Handle); The counterpart entry in the .def file must be

LT360LIB_CloseLink@4

i.e. function name, followed by '@', followed by the number of the bytes (in decimal) the function's arguments use.

After you've gone through and fixed all the function's in the .def file, then use LIB.exe to generate a new .LIB.

P.s somthing came up i edited the .def and once i finish ill link, be back soon.
here is what i did so far

i edited the .def file

LIBRARY     LT360LIB.DLL

EXPORTS
    LT360LIB_CloseLink             @4   
    LT360LIB_Cmd                   @8   
    LT360LIB_CmdIndexValue         @10   
    LT360LIB_CmdString             @4  
    LT360LIB_CmdValue              @9   
    LT360LIB_GetDllVerDate         @2   
    LT360LIB_GetUsbFirmwareVerDate @6   
    LT360LIB_LinkedCnt             @0   
    LT360LIB_OpenLinkCOM           @8   
    LT360LIB_OpenLinkUSB           @0   
    LT360LIB_ReadBinary            @17  
    LT360LIB_WriteBinary           @17

just to make sure if the function takes no arguments @0
and when i use

typedef unsigned char * Pointer;

pointer is equal to one byte right

i hope all the @value are correct

the edited header file (actually i just edited pointer in the typedef)

// Header file for Exported Functions in LT360 control library: LT360LIB.DLL
// =========================================================================
// (C)2006 LinearX Systems Inc, Mar-01-2006, Chris N. Strahm
// =========================================================================
// This DLL provides a high level interface for controlling one or more
// LT360 turntables. Up to a maximum of 128 units are managed by the DLL.
//
// NOTE: See the DLL Programming Manual for details on using this interface.
//
// All functions communicate to the LT360 units by numeric index handle.
// Therefore the application program can manage units by keeping track of
// the index handle for each LT360 unit linked.
//
// Linking is provided either through the RS-232 COM ports or the USB bus
// of the PC.  The application program can choose which method to attempt
// a link with an LT360.
//
// All strings passed to or from the functions are ASCIIZ strings.  It is
// the responsibility of the calling program to allocate the char buffers.
// All functions use the Windows standard calling convention, passing
// parameters from right to left on the stack. The routines cleanup the stack.
// ========================================================================

// ============================================================================
// After the link is established, commands can be sent using a single function,
// LT360LIB_CmdValue.  This function takes 3 parameters. Both string and numeric
// parameters are passed using an ASCIIZ string.  Return values are passed to
// the same parameter for the Get commands.  Commands are selected by using
// different identifier constants as listed below.
// ============================================================================

// ============================================================================
// NOTE: The LT360LIB_WriteBinary and LT360LIB_ReadBinary functions are only
//       used by the LT360.EXE Win32 application for updating firmware.
//       They are not needed and should not be called by customer applications.
// ============================================================================

#ifndef LT360LIB_H
#define LT360LIB_H

#include <windows.h>
typedef  long int LONGINT;
typedef  long int LONGBOOL;
typedef unsigned char * Pointer;
// 		=========================================================================================
// 		Identifier         		   Cmd    USB COM Data Address  Description
// 		-------------------------- ---    --- --- ---- -------  ------------------------------------------
//
// WriteBinary calls
#define lt_EnterRAM   	          0x11  /* X   -     0     11h  Enter RAM mode for Flash Programming		*/
#define lt_ExitRAM    	          0x12  /* X   -     0     12h  Exit  RAM mode, return to normal op		*/
#define lt_WriteRamData	          0x15  /* X   -    32    nnnn  Write data to flash buffer		*/
#define lt_EraseFlash	          0x16  /* X   -     0  SecNum  Erase Flash Sector, by SecNum		*/
#define lt_RamToFlash	          0x17  /* X   -     0  RomAdr  Copy Buffer RAM to RomAdr		*/
#define lt_FlashToRam             0x18  /* X   -     0  RomAdr  Copy from RomAdr to Buffer RAM (1024)		*/
#define lt_ReBoot                 0x19  /* X   -     0     19h  ReBoot LT360		*/
// SetCmd calls
#define lt_Goto_CCW               0x1C  /* X   X    16       0  Goto by CCW pos str eg. '45.0' '-135.0'		*/
#define lt_Goto_CW                0x1D  /* X   X    16       0  Goto by CW  pos str eg. '45.0' '-135.0'		*/
#define lt_Step_CCW               0x1E  /* X   X     0       0  Step by CCW		*/
#define lt_Step_CW                0x1F  /* X   X     0       0  Step by CW		*/
#define lt_SetSmartTorque         0x20  /* X   X     4       0  Set SmartTorque Str: "ON", "OFF"		*/
#define lt_SetBaudRate	          0x21  /* X   X     8       0  Set Baudrate Str: "9600"		*/
#define lt_SetOrigin	          0x22  /* X   X     0       0  Set current position as origin 0.0		*/
#define lt_SetPulseDir            0x23  /* X   X     4       0  Set Pulse Dir Str: "CCW", "CW"		*/
#define lt_SetPulseEdge           0x24  /* X   X     4       0  Set Pulse Edge Trigger Str: "RISE", "FALL"		*/
#define lt_SetStepSize 	          0x25  /* X   X    10       0  Set Degrees per Step Str: "5.0"  "0.1"		*/
#define lt_SetVelocity	          0x26  /* X   X    10       0  Set Velocity RPM Str: "1.00"  "3.00"		*/
#define lt_SetTorque              0x27  /* X   X    10       0  Set Torque % Str: "100.0"  "50.0"		*/
#define lt_SetAccelFunc           0x28  /* X   X     2       0  Set Accel Func Num Str: "0" ... "4"		*/
#define lt_SetName                0x29  /* X   X    32       0  Set Unit Name Str: "xxxxxxx"		*/
#define lt_SetProdDate            0x2A  /* X   X    12       0  Set Production Date Str: "Jan-15-2005"		*/
#define lt_SetCalDate             0x2B  /* X   X    12       0  Set Calibration Date Str: "Jan-15-2005"		*/
#define lt_SetDueDate             0x2C  /* X   X    12       0  Set Cal Due Date Str: "Jan-15-2005"		*/
#define lt_SetBacklash            0x2D  /* X   X    10       0  Set Backlash, Deg Str: "0.055"		*/
#define lt_SetMaxTorque           0x2E  /* X   X    10       0  Set MaxTorque, N*M Str: "43.5"		*/
#define lt_SetDacNoise            0x2F  /* X   X    10       0  Set DacNoise, uVrms Str: "21.3"		*/
#define lt_SetDacVhi              0x30  /* X   X    10       0  Set DacVhi, VDC Str: "3.666555"		*/
#define lt_SetDacVlo              0x31  /* X   X    10       0  Set DacVlo, VDC Str: "-1.265768"		*/
#define lt_SetPulseInput          0x32  /* X   X     4       0  Set Pulse Input Str: "OFF" "ON"		*/
#define lt_SetAnalogInput         0x33  /* X   X     4       0  Set Analog Input Str: "OFF" "ON"		*/
#define lt_SetDisplayPolarity     0x34  /* X   X    10       0  Set Display Polarity Str: "UNIPOLAR" "BIPOLAR"		*/
#define lt_SetInputPolarity       0x35  /* X   X    10       0  Set Input   Polarity Str: "UNIPOLAR" "BIPOLAR"		*/
#define lt_SetOutputPolarity      0x36  /* X   X    10       0  Set Output  Polarity Str: "UNIPOLAR" "BIPOLAR"		*/
#define lt_SetSerialNumber        0x37  /* X   X    10       0  Set Serial Number Str: "712345"		*/
#define lt_SetMoveAbort           0x38  /* X   X     0       0  Set MoveAbort, stops movement		*/
#define lt_SetMotorHomeChk        0x39  /* X   X     4       0  Set Motor Home Check, OFF/ON		*/
#define lt_SetRevCode             0x3A  /* X   X     4       0  Set PCB Revision Code, '65'=A		*/
#define lt_SetOutputMode          0x3B  /* X   X     6       0  Set OutputMode: 0=CONT, 1=START, 2=STOP		*/
#define lt_SetDacUnipolarScale    0x40  /* X   X     6       0  Set DAC Unipolar Scale Str: "FFFF" (Analog Output)		*/
#define lt_SetDacUnipolarOffset   0x41  /* X   X     6       0  Set DAC Unipolar Offset Str: "FFFF" (Analog Output)		*/
#define lt_SetDacBipolarScale     0x42  /* X   X     6       0  Set DAC Bipolar Scale Str: "FFFF" (Analog Output)		*/
#define lt_SetDacBipolarOffset    0x43  /* X   X     6       0  Set DAC Bipolar Offset Str: "FFFF" (Analog Output)		*/
#define lt_SetAdcUnipolarScale    0x44  /* X   X     6       0  Set ADC Unipolar Scale Str: "FFFF" (Analog Input)		*/
#define lt_SetAdcUnipolarOffset   0x45  /* X   X     6       0  Set ADC Unipolar Offset Str: "FFFF" (Analog Input)		*/
#define lt_SetAdcBipolarScale     0x46  /* X   X     6       0  Set ADC Bipolar Scale Str: "FFFF" (Analog Input)		*/
#define lt_SetAdcBipolarOffset    0x47  /* X   X     6       0  Set ADC Bipolar Offset Str: "FFFF" (Analog Input)		*/
#define lt_SetDacUniErrorValue    0x48  /* X   X    16       0  Set DAC Unipolar Error Value nnn at index:[0..255] Str: "nnn NNN"		*/
#define lt_SetDacBipErrorValue    0x49  /* X   X    16       0  Set DAC Bipolar Error Value nnn at index:[0..255] Str: "nnn NNN"		*/
#define lt_SetZeroDacUniError     0x4A  /* X   X     0       0  Set Zero's the DAC Unipolar Error Array		*/
#define lt_SetZeroDacBipError     0x4B  /* X   X     0       0  Set Zero's the DAC Unipolar Error Array		*/
#define lt_SetCalMode             0x4C  /* X   X     4       0  Set Calibration Mode Str: "OFF" "ON"		*/
#define lt_SetDacPosition         0x4D  /* X   X     8       0  Set DAC position in Microsteps [0..115200-1] str: "nnnnnn"		*/
#define lt_SetDacDirect           0x4E  /* X   X     8       0  Set DAC value directly [0..65535] str: "nnnnn"		*/
#define lt_SetDacCorrect          0x4F  /* X   X     4       0  Set DAC Correction Str: "OFF" "ON"		*/
#define lt_SetDebug               0x70  /* X   X     4       0  Set Special Debug mode or command		*/
#define lt_SetWriteRead           0x7F  /* X        32   CmdID  Set WriteRead for RS232, adrcmd for read		*/
// ReadBinary calls
#define lt_ReadRamData	          0x90  /* X   -    32    nnnn  Read data from flash buffer at Adr (1024)		*/
// GetCmd calls
#define lt_GetName                0x91  /* X   X    32       0  Get NAME str		*/
#define lt_GetTitle		          0x92  /* X   X    25       0  Get TITLE str "LT360 Precision Turntable"		*/
#define lt_GetAuthor	          0x93  /* X   X    15       0  Get AUTHOR str "Chris N. Strahm"		*/
#define lt_GetCopyright	          0x94  /* X   X    28       0  Get COPYRIGHT str "(C)2005 LinearX Systems Inc"		*/
#define lt_GetVerCode	          0x95  /* X   X    12       0  Get VerCode str "1.00"		*/
#define lt_GetVerDate	          0x96  /* X   X    12       0  Get VerDate str "JAN-01-2005"		*/
#define lt_GetProdDate	          0x97  /* X   X    12       0  Get ProductionDate str "JAN-01-2005"		*/
#define lt_GetCalDate	          0x98  /* X   X    12       0  Get CalibrationDate str "JAN-01-2005"		*/
#define lt_GetDueDate	          0x99  /* X   X    12       0  Get Calibration Due Date str "JAN-01-2005"		*/
#define lt_GetSerialNumber        0x9A  /* X   X    10       0  Get SerialNumber str "700001"		*/
#define lt_GetBaudRate	          0x9B  /* X   X    10       0  Get BaudRate str "9600", "19200"		*/
#define lt_GetPosition	          0x9C  /* X   X    10       0  Get Position str "15.0", "-45.0"		*/
#define lt_GetPulseDir	          0x9D  /* X   X     4       0  Get Pulse Dir str "CCW", "CW"		*/
#define lt_GetPulseEdge           0x9E  /* X   X     4       0  Get Pulse trigger Edge str "RISE", "FALL"		*/
#define lt_GetStepSize            0x9F  /* X   X    10       0  Get Step Size str "5.0", "0.1"		*/
#define lt_GetVelocity            0xA0  /* X   X    10       0  Get Velocity, RPM str "1.0", "0.1"		*/
#define lt_GetTorque              0xA1  /* X   X    10       0  Get Torque, % str "100.0", "50.0"		*/
#define lt_GetAccelFunc           0xA2  /* X   X     2       0  Get Accel Func str "0", "1" .. "3" number		*/
#define lt_GetMoving              0xA3  /* X   X     4       0  Get Moving Cond str "CCW", "NO", "CW"		*/
#define lt_GetBacklash            0xA4  /* X   X    10       0  Get Backlash, +/-Deg "0.055"		*/
#define lt_GetMaxTorque           0xA5  /* X   X    10       0  Get MaxTorque, N*M "43.5"		*/
#define lt_GetDacNoise            0xA6  /* X   X    10       0  Get DacNoise, uVrms "21.5"		*/
#define lt_GetDacVhi              0xA7  /* X   X    10       0  Get DacVhi, VDC "3.666555"		*/
#define lt_GetDacVlo              0xA8  /* X   X    10       0  Get DacVlo, VDC "-1.2666555"		*/
#define lt_GetPulseInput          0xA9  /* X   X     4       0  Get Pulse Input Status: "OFF" "ON"		*/
#define lt_GetAnalogInput         0xAA  /* X   X     4       0  Get Analog Input Status: "OFF" "ON"		*/
#define lt_GetSmartTorque         0xAB  /* X   X     4       0  Get Smart Torque Status: "OFF" "ON"		*/
#define lt_GetDisplayPolarity     0xAC  /* X   X    10       0  Get Display Polarity Status: "BIPOLAR" "UNIPOLAR"		*/
#define lt_GetInputPolarity       0xAD  /* X   X    10       0  Get Input Polarity Status: "BIPOLAR" "UNIPOLAR"		*/
#define lt_GetOutputPolarity      0xAE  /* X   X    10       0  Get Output Polarity Status: "BIPOLAR" "UNIPOLAR"		*/
#define lt_GetCalMode             0xAF  /* X   X     6       0  Get Cal Mode: "OFF" "ON"		*/
#define lt_GetDacUnipolarScale    0xB0  /* X   X     6       0  Get DAC Unipolar Scale Hex Value: "FFFF"		*/
#define lt_GetDacUnipolarOffset   0xB1  /* X   X     6       0  Get DAC Unipolar Offset Hex Value: "FFFF"		*/
#define lt_GetDacBipolarScale     0xB2  /* X   X     6       0  Get DAC Bipolar Scale Hex Value: "FFFF"		*/
#define lt_GetDacBipolarOffset    0xB3  /* X   X     6       0  Get DAC Bipolar Offset Hex Value: "FFFF"		*/
#define lt_GetAdcUnipolarScale    0xB4  /* X   X     6       0  Get Adc Unipolar Scale Hex Value: "FFFF"		*/
#define lt_GetAdcUnipolarOffset   0xB5  /* X   X     6       0  Get ADC Unipolar Offset Hex Value: "FFFF"		*/
#define lt_GetAdcBipolarScale     0xB6  /* X   X     6       0  Get ADC Bipolar Scale Hex Value: "FFFF"		*/
#define lt_GetAdcBipolarOffset    0xB7  /* X   X     6       0  Get ADC Bipolar Offset Hex Value: "FFFF"		*/
#define lt_GetAdcPosition         0xB8  /* X   X    10       0  Get ADC Position in Microsteps:: "0..115200-1" (analog input) (cal)		*/
#define lt_GetAdcVolt             0xB9  /* X   X    10       0  Get ADC voltage: 1.23345 (analog input)		*/
#define lt_GetAdcValue            0xBA  /* X   X    10       0  Get ADC Value : 0..65535 (analog input)		*/
#define lt_GetDacCorrect          0xBB  /* X   X     4       0  Get DAC Correction Status: "OFF" "ON"		*/
#define lt_GetDacDirect           0xBC  /* X   X     6       0  Get DAC value: "0..65535"		*/
#define lt_GetDacUniErrFunc       0xBD  /* X   X     4       0  Get DAC Unipolar Error value at current position: "nnn" (cal)		*/
#define lt_GetDacBipErrFunc       0xBE  /* X   X     4       0  Get DAC Bipolar Error value at current position: "nnn" (cal)		*/
#define lt_GetDacUniErrValue      0xBF  /* X   X     4       0  Get DAC Unipolar Error value at index [0..180]: "nnn" (cal)		*/
#define lt_GetDacBipErrValue      0xC0  /* X   X     4       0  Get DAC Bipolar Error value at index [0..180]: "nnn" (cal)		*/
#define lt_GetMotorHomeChk        0xC1  /* X   X     4       0  Get Motor Home Checking Status: "OFF" "ON"		*/
#define lt_GetRevCode             0xC2  /* X   X     4       0  Get PCB Revision Code, '65'=A		*/
#define lt_GetOutputMode          0xC3  /* X   X     6       0  Get OutputMode: 0=CONT, 1=START, 2=STOP		*/
#define lt_GetFlashBootLoader     0xD0  /* X   X     6       0  Get Flash Bootloader Version str: "1.52" "1.30", LPC2104		*/
#define lt_GetFlashPartID         0xD1  /* X   X    12       0  Get Flash Part ID str: "4293984018"		*/
#define lt_GetReadStr             0xF0  /* X        32       0  Get usb str from previous WriteRead from RS232 calls		*/
// ----------------------- ---    --- --- ---- -------  ------------------------------------------


// NOTE: All functions use Standard Calling Convention

//---------------------------------------------------------------------------
//  Function: 	LT360LIB_GetDllVersion
//  Abstract:   Returns the Version and Date strings of the DLL
//  Parameters: returns ver & date strs eg: nnn.nnn.nnn.nnn , Oct/11/1998
//  Returns:    None
//---------------------------------------------------------------------------
extern "C" void __stdcall LT360LIB_GetDllVerDate(char *Ver, char *Date);


//---------------------------------------------------------------------------
//  Function: 	LT360LIB_LinkedCnt
//  Abstract:   Returns the number of LT360 with active links (0..128)
//  Parameters: None
//  Returns:    Number of LT360 units with active links via USB or RS-232
//---------------------------------------------------------------------------
extern "C" __stdcall LONGINT LT360LIB_LinkedCnt(void);


//---------------------------------------------------------------------------
//  Function: 	LT360LIB_OpenLinkUSB
//  Abstract:   Attempts to find and link one LT360 over the USB bus.
//              Since more than one LT360 may be on the USB bus,
//              this routine can be called repeatly until all of
//              the LT360 units on the USB bus are found (return=0).
//  Parameters: None
//  Returns:    LT360_Index > 0 if found, else 0 if no LT360 found.
//---------------------------------------------------------------------------
extern "C" LONGINT __stdcall LT360LIB_OpenLinkUSB(void);


//---------------------------------------------------------------------------
//  Function: 	LT360LIB_OpenLinkCOM
//  Abstract:   Attempts to find and link one LT360 over an RS-232 port.
//              Since only one LT360 can be on a single COM port,
//              this routine is called using different COM ports (1,2,3,4..)
//              for each LT360 unit to be linked. If not found, return=0.
//              Note: The BaudRate here must match what the LT360 is using.
//                    The LT360 uses 9600 by default unless it has been changed.
//  Parameters: ComNum (1,2,3,4...) , BaudRate (9600, 19200, etc)
//  Returns:    Handle > 0 if found, else 0 if no LT360 found.
//---------------------------------------------------------------------------
extern "C" LONGINT __stdcall LT360LIB_OpenLinkCOM(LONGINT ComNum, LONGINT BaudRate);


//---------------------------------------------------------------------------
//  Function: 	LT360LIB_CloseLink
//  Abstract:   Closes/Unlinks the LT360 given by index number (RS232 or USB)
//  Parameters: LT360_Index (1..LinkedCnt)
//  Returns:    Returns TRUE if link closed successfully
//---------------------------------------------------------------------------
extern "C" LONGBOOL __stdcall LT360LIB_CloseLink(LONGINT Handle);


//---------------------------------------------------------------------------
//  Function: 	LT360LIB_GetUsbFirmwareVerDate
//  Abstract:   Obtains the strings for the Version and Date of the USB
//              controller firmware inside the LT360.
//              The LT360 given by the index number must have USB link.
//  Parameters: LT360_Index, ptrs for Version and Date strings
//  Returns:    Returns TRUE if executed successfully
//---------------------------------------------------------------------------
extern "C" LONGBOOL __stdcall LT360LIB_GetUsbFirmwareVerDate(LONGINT LT360_Index, char *UsbFirmwareRev, char *UsbFirmwareDate);


//---------------------------------------------------------------------------
//  Function: 	LT360LIB_Cmd
//  Abstract:   Sends a Command to the LT360
//              Also dislays error message dialog if command fails
//  Parameters: Handle: LT360 Index returned from Link
//              CmdID : Command Identifier
//  Returns:    Returns TRUE if executed successfully
//---------------------------------------------------------------------------
extern "C" LONGBOOL  __stdcall LT360LIB_Cmd(LONGINT Handle, LONGINT CmdID);


//---------------------------------------------------------------------------
//  Function: 	LT360LIB_CmdValue
//  Abstract:   Sends a Command to the LT360
//              Also dislays error message dialog if command fails
//  Parameters: Handle: LT360 Index returned from Link
//              CmdID : Command Identifier
//              ParamValue : Parameter String for Value, may be nil
//                           Get calls return strings in ParamValue
//  Returns:    Returns TRUE if executed successfully
//---------------------------------------------------------------------------
extern "C" LONGBOOL _stdcall LT360LIB_CmdValue(LONGINT Handle, LONGINT CmdID, char *ParamValue);


//---------------------------------------------------------------------------
//  Function: 	LT360LIB_CmdIndexValue
//  Abstract:   Sends a Command to the LT360
//              Also dislays error message dialog if command fails
//  Parameters: Handle: LT360 Index returned from Link
//              CmdID : Command Identifier
//              ParamIndex : Parameter String for Index, may be nil
//              ParamValue : Parameter String for Value, may be nil
//                           Get calls return strings in ParamValue
//  Returns:    Returns TRUE if executed successfully
//---------------------------------------------------------------------------
extern "C" LONGBOOL __stdcall LT360LIB_CmdIndexValue(LONGINT Handle, LONGINT CmdID, char *ParamIndex, char *ParamValue);


//---------------------------------------------------------------------------
//  Function: 	LT360LIB_CmdString
//  Abstract:   Returns the Cmd str used for COM port calls.
//  Parameters: CmdID
//  Returns:    Returns command str if executed successfully, empty if bad CmdIndex
//---------------------------------------------------------------------------
extern "C" char * __stdcall LT360LIB_CmdString(LONGINT CmdID);


//---------------------------------------------------------------------------
//  Function: 	LT360LIB_WriteBinary
//  Abstract:   USB binary data write command.
//              P is a pointer to the data array to be written.
//              Maximum DataByteCnt=32, Adr depends on command
//  Parameters: LT360_Index, CmdIndex, DataByteCnt, Adr
//  Returns:    Returns TRUE if executed successfully
//---------------------------------------------------------------------------
extern "C" LONGBOOL __stdcall LT360LIB_WriteBinary(LONGINT Handle, LONGINT CmdIndex, LONGINT DataByteCnt, LONGINT Adr, Pointer P);


//---------------------------------------------------------------------------
//  Function: 	LT360LIB_ReadBinary
//  Abstract:   USB binary data read command.
//              P is a pointer to the data array to be returned.
//              Maximum DataByteCnt=32, Adr depends on command
//  Parameters: LT360_Index, CmdIndex, DataByteCnt, Adr
//  Returns:    Returns TRUE if executed successfully
//---------------------------------------------------------------------------
extern "C" LONGBOOL __stdcall LT360LIB_ReadBinary(LONGINT Handle, LONGINT CmdIndex, LONGINT DataByteCnt, LONGINT Adr, Pointer P);

/*
Function LT360LIB_GetDllVerDate;			External 'LT360LIB.DLL' Index 01;
Function LT360LIB_LinkedCnt;	    	    External 'LT360LIB.DLL' Index 02;
Function LT360LIB_CloseLink;		        External 'LT360LIB.DLL' Index 03;
Function LT360LIB_OpenLinkUSB;	    	    External 'LT360LIB.DLL' Index 04;
Function LT360LIB_OpenLinkCOM;		        External 'LT360LIB.DLL' Index 05;
Function LT360LIB_GetUsbFirmwareVerDate;    External 'LT360LIB.DLL' Index 06;
Function LT360LIB_Cmd;  		            External 'LT360LIB.DLL' Index 07;
Function LT360LIB_CmdValue;		            External 'LT360LIB.DLL' Index 08;
Function LT360LIB_CmdIndexValue;            External 'LT360LIB.DLL' Index 09;
Function LT360LIB_CmdString;		        External 'LT360LIB.DLL' Index 10;
Function LT360LIB_WriteBinary;		        External 'LT360LIB.DLL' Index 11;
Function LT360LIB_ReadBinary;		        External 'LT360LIB.DLL' Index 12;
*/

#endif	// LT360LIB_H

There must be no space between the function name and the '@', if there is, the meaning of the '@' + the following number changes to mean a 'link ordinal'.

So, use it as below ...

LIBRARY     LT360LIB.DLL

EXPORTS
    LT360LIB_CloseLink@4   
    LT360LIB_Cmd@8   
    LT360LIB_CmdIndexValue@10   
    LT360LIB_CmdString@4  
    LT360LIB_CmdValue@9   
    LT360LIB_GetDllVerDate@2   
    LT360LIB_GetUsbFirmwareVerDate@6   
    LT360LIB_LinkedCnt@0   
    LT360LIB_OpenLinkCOM@8   
    LT360LIB_OpenLinkUSB@0   
    LT360LIB_ReadBinary@17  
    LT360LIB_WriteBinary@17

just to make sure if the function takes no arguments @0

Yes.

and when i use

typedef unsigned char * Pointer;

pointer is equal to one byte right

No, it is 4, not 1 (you are dealing with a pointer).

i hope all the @value are correct

If in doubt about the sizes, you can check by e.g.

printf("%u\n",sizeof(unsigned char *));

agrhh, i don't know what happened, please be patient with me.

anyway i edited the pointer to 4 bytes now here is the final .def

LIBRARY     LT360LIB.DLL

EXPORTS
    LT360LIB_CloseLink@4   
    LT360LIB_Cmd@8   
    LT360LIB_CmdIndexValue@10   
    LT360LIB_CmdString@4  
    LT360LIB_CmdValue@12   
    LT360LIB_GetDllVerDate@2   
    LT360LIB_GetUsbFirmwareVerDate@6   
    LT360LIB_LinkedCnt@0   
    LT360LIB_OpenLinkCOM@8   
    LT360LIB_OpenLinkUSB@0   
    LT360LIB_ReadBinary@20  
    LT360LIB_WriteBinary@20

i created a library file and my project compiles and build but when i run the program. i get

"the procedure entry point lt360lib_openlinkusb@0 could not be located in the dynamic link library lt360lib.dll "

this message came when i used

LT360LIB_OpenLinkUSB();

thanks (p.s i know maybe you got bored with the many thanks but for weeks i have been searching for answers, and you are the only one giving me straight to the point answers, i'm actually working on a grad project which contains many hardware devices and the lt360 turntable is one of them , all the other devices contained .dll , .h, .lib ready to use and had no problem with them but unfortunately the turntable came with a .h and a .dll files only ( unfortunately i already bought it) i tried to contact the company but they said that the .h and .dll files are sufficient, which i cant see how (maybe due to my lack in advanced programming knowledge), but it really gave me a headache)
thanks again my friend

by the way one more thring if i create a .def file for a .dll and from the def file i found out that a certain function takes 3bytes e.g@3, is it ok to edit the .def file to make it take 4 (as we did) e.g changing the @3 to @4 or shouldn't i change the header file to suite the .dll needs

by the way one more thring if i create a .def file for a .dll and from the def file i found out that a certain function takes 3bytes e.g@3, is it ok to edit the .def file to make it take 4 (as we did) e.g changing the @3 to @4 or shouldn't i change the header file to suite the .dll needs

It appears that you are confused by the link ordinals in the .def files. If you take a look at the original .def file, there may be e.g a line like

LT360LIB_OpenLinkUSB         @2   ; LT360LIB_OpenLinkUSB

The '@2' is the ordinal which also can be used for linking, i.e. linking completely without the symbolic function name. So, don't modify/remove those ordinals, just append the function naming decoration to the function names, e.g.

LT360LIB_OpenLinkUSB[B]@0[/B]         @2   ; LT360LIB_OpenLinkUSB

and so on.


Now, as a check-list, using LT360LIB_OpenLinkUSB() as an example, things should look like:

In the header file:

extern "C" __stdcall LONGINT LT360LIB_OpenLinkUSB(void);

In the .def file

LT360LIB_OpenLinkUSB@0          @[I]<link ordinal>[/I]

In the generated .lib file: (use dumpbin /EXPORTS)

[I]<link ordinal>[/I]            _LT360LIB_OpenLinkUSB@0

And in the code

LONGINT val = LT360LIB_OpenLinkUSB();
commented: exactly the answer needed +2

i got you my friend
.def

LIBRARY     LT360LIB.DLL

EXPORTS
    LT360LIB_CloseLink@4               @3   
    LT360LIB_Cmd@8                     @7   
    LT360LIB_CmdIndexValue@16          @9   
    LT360LIB_CmdString@4               @10  
    LT360LIB_CmdValue@12               @8   
    LT360LIB_GetDllVerDate@8           @1   
    LT360LIB_GetUsbFirmwareVerDate@12  @6   
    LT360LIB_LinkedCnt@0               @2   
    LT360LIB_OpenLinkCOM@8             @5   
    LT360LIB_OpenLinkUSB@0             @4   
    LT360LIB_ReadBinary@20             @12  
    LT360LIB_WriteBinary@20            @11

and the dump is as you said it s

E:\>dumpbin /exports lt360lib.lib
Microsoft (R) COFF Binary File Dumper Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.


Dump of file lt360lib.lib

File Type: LIBRARY

     Exports

       ordinal    name

             3    _LT360LIB_CloseLink@4
             7    _LT360LIB_Cmd@8
             9    _LT360LIB_CmdIndexValue@10
            10    _LT360LIB_CmdString@4
             8    _LT360LIB_CmdValue@12
             1    _LT360LIB_GetDllVerDate@2
             6    _LT360LIB_GetUsbFirmwareVerDate@6
             2    _LT360LIB_LinkedCnt@0
             5    _LT360LIB_OpenLinkCOM@8
             4    _LT360LIB_OpenLinkUSB@0
            12    _LT360LIB_ReadBinary@20
            11    _LT360LIB_WriteBinary@20

  Summary

          C9 .debug$S
          14 .idata$2
          14 .idata$3
           4 .idata$4
           4 .idata$5
           E .idata$6

now the code compiles and executes with no problem.
but one final question in the manual they gave an example of using the function LT360LIB_Cmdvalue which was as follows

LT360LIB_Cmdvalue(handle,lt_goto_ccw,'nnn.n')

, where nnn.n is and angle e.g 101.1.
when it try to execute the function e.g

z=LT360LIB_CmdValue(0, lt_Goto_CCW, '5.5');

i get the following error

F:\c++\lt360.cpp(21) : error C2664: 'LT360LIB_CmdValue' : cannot convert parameter 3 from 'const int' to 'char *'
        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.

as a reminder the header file definition is

extern "C" LONGBOOL _stdcall LT360LIB_CmdValue(LONGINT Handle, LONGINT CmdID, char *ParamValue);


//---------------------------------------------------------------------------
//  Function: 	LT360LIB_CmdIndexValue
//  Abstract:   Sends a Command to the LT360
//              Also dislays error message dialog if command fails
//  Parameters: Handle: LT360 Index returned from Link
//              CmdID : Command Identifier
//              ParamIndex : Parameter String for Index, may be nil
//              ParamValue : Parameter String for Value, may be nil
//                           Get calls return strings in ParamValue
//  Returns:    Returns TRUE if executed successfully

but if i place the angle in double quotation e.g

z=LT360LIB_CmdValue(0, lt_Goto_CCW, "5.5");

it gives no errors,why is that?did i solve the problem by using double quotes or did i just removed this problem and caused a big error yet to be seen? thanks

LT360LIB_Cmdvalue(handle,lt_goto_ccw,'nnn.n')

That's how a string is specified in Pascal. In C/C++ you have to stick with double quotes when you specify strings. Happy coding ...

Thanks my dear friend i hope ill be able to use your help in the future , and i hope this thread will be a good reference for any one with a similar problem :icon_smile:
regards

hey mitrmkar just a quick question ( sorry forgot to mention it before)
i get this warning when i add the header file of the lt360
( i removed the solved tag so the thread can be spotted and checked)

:\program files\microsoft visual studio\vc98\include\lt360lib.h(185) : warning C4518: 'LONGINT ' : storage-class or type specifier(s) unexpected here; ignored
e:\program files\microsoft visual studio\vc98\include\lt360lib.h(185) : warning C4230: anachronism used : modifiers/qualifiers interspersed, qualifier ignored

project.obj - 0 error(s), 2 warning(s)

as you can see no errors but warnings only ,but when i recompile the warnings go away and until now i had no problems.Is it ok to continue or are there some changes that must be done?

thanks

hey mitrmkar just a quick question ( sorry forgot to mention it before)
i get this warning when i add the header file of the lt360
( i removed the solved tag so the thread can be spotted and checked)

:\program files\microsoft visual studio\vc98\include\lt360lib.h(185) : warning C4518: 'LONGINT ' : storage-class or type specifier(s) unexpected here; ignored
e:\program files\microsoft visual studio\vc98\include\lt360lib.h(185) : warning C4230: anachronism used : modifiers/qualifiers interspersed, qualifier ignored

project.obj - 0 error(s), 2 warning(s)

as you can see no errors but warnings only ,but when i recompile the warnings go away and until now i had no problems.Is it ok to continue or are there some changes that must be done?

thanks

I assume you have a misplaced __stdcall somewhere in the header file, e.g.

extern "C" __stdcall LONGINT LT360LIB_OpenLinkUSB(void);

which has to be

extern "C" LONGINT __stdcall LT360LIB_OpenLinkUSB(void);

yup you are correct ,
Thanks problem solved

Good, such nitpicky compilers they make ;)

yeah and warning messages aren't straight to the point but maybe they made them more user friendly in the latest versions since mine is old

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.