Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem Call DLL - Have Source Code
Message
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Problem Call DLL - Have Source Code
Miscellaneous
Thread ID:
00159950
Message ID:
00159950
Views:
75
I am having problems calling a DLL function from a 3rd parties DLL. Below is my code I am using. The DLL Declares fine, but when I call the function, it returns a code indicating a bad comm port id. The really bad part is that it works fine in VB. The vendor has sent me their C++ code (I don't know C++) so I've included the Function call code from it at this bottom of this message. Any help would be greatly appreicated, the vendor has told me they will correct any problem so that it works with Visual Foxpro, but they don't know where to start in finding the problem.

Thanks in advance.

Kirk Kelly
cqi_provider@email.msn.com

*-----------MY CODE I'M USING TO TEST

** Procedure PWAND
** Purpose: Test using the 32Bit DLL dload32.dll
Parameter tnWandID,tnPort,tnTimeOut
* Remove Old Status File
delete file status.txt
* Locals
Local lnResults,lnWandID,lnPort,lnTimeOut
** Check to See if we passed parameters
if pcount()<3
lnWandID=1
lnPort=2
lnTimeOut=90
else
lnWandID=tnWandID
lnPort=tnPort
lnTimeOut=tnTimeOut
endif

* Declare the DLL

** This is how their documentation says to declare it.
DECLARE Long InitializeWand in dload32.dll ;
Long@Wandid,;
String@SymPath,;
String@AplPath,;
Long@comport,;
Long@initTime,;
Long@Tdebug,;
Long@IODeug

** The declares is displayed in when I do DISP DLLS

* Then I tried this after I received their souce code.
* it loaded fine also, but returned the same error.

*!* DECLARE Long InitializeWand in dload32.dll ;
*!* LONG@Wandid,;
*!* String@SymPath,;
*!* String@AplPath,;
*!* INTEGER@comport,;
*!* INTEGER@initTime,;
*!* INTEGER@Tdebug,;
*!* INTEGER@IODeug



** Attempt Calling DLL Function (InitializeWand)
lnStatus=InitializeWand(1,"3OF9KP.DWP","",2,60,0,0)


**----------------- THE C++ CODE FROM THE VENDOR
/*************************************************************

InitializeWand

This function is the shell that opens and closes ports and will
call the routine to initialize a TimeWand with the symbology
specified and sets the ID to the ID string parameter. It may
also load an application and do several other things.

**************************************************************/
int CDload1wApp::InitializeWand( long IDParm, LPSTR symPath,
LPSTR aplPath, int portNumber,
int initTime,
int pathDebug,
int IOdebug)
{
int err;

m_debugIO = IOdebug;
m_debug = pathDebug;

err = FALSE ;
m_WandId = IDParm;
err = SerOpen( portNumber );
if (err < 0){
SerClose( portNumber );
return err;
}
if (m_debug){
dbgPrint(9999,"Proc: InitializeWand");
dbgPrintL(IDParm,"Params: ID = ");
dbgPrint(9999,symPath);
dbgPrint(9999,aplPath);
dbgPrint(portNumber,"portNumber = ");
dbgPrint(initTime,"InitTime = ");
}

err = InitWand( symPath, aplPath, initTime);
SerClose( portNumber );
return err;
}


/*******************************************************************************

SerOpen

Opens and initializes the serial port using the Windows API functions OpenComm,
BuildCommDCB, and SetCommState.

Also sets the global variables hCommPort, iCommPortNo, szCurrentRecvStr, and
iTotalRecd.

Returns badParamErr, portOpenAlready, otherPortOpen, openButBadBaud,
error from OpenComm(), iSerOpenErr, or noErr.

********************************************************************************/
int CDload1wApp::SerOpen ( int iParmCommPortNo)
{
PTTYINFO pTTY; // From CComPortIO Class.
int iSerOpenErr ;

if ((m_statusFile = fopen ( "status.txt", "a+b" )) == NULL){
return statusFileErr;
}
fclose(m_statusFile);
if ((m_debug) || (m_debugIO)){
m_dbgFile = fopen (m_dbgFileName, "w"); // DEBUG restart file
fclose(m_dbgFile);
}
if (m_debug){
dbgPrint(9999,"Proc: SerOpen");
dbgPrint(9999,"Version 1.40");
}

// Make sure that DLoad1W is not already being run from another task.
// NOTE: This will not work under Windows 95 because new memory is allocated
// for each application that accesses this DLL (Windows 95 rules).
if ( m_bAlreadyRunning )
return alreadyRunning ;

if (( iParmCommPortNo < 1 || iParmCommPortNo > 9 )){ // Valid Port ?
WriteStatus( "SerOpen - invalid port", iParmCommPortNo, badParamErr );
return badParamErr ;
}
if ( m_iCommPortNo == iParmCommPortNo){ // Open ?
WriteStatus( "SerOpen - port already open", iParmCommPortNo, portOpenAlready );
return portOpenAlready ;
}
if (m_iCommPortNo > 0 && m_iCommPortNo != iParmCommPortNo){ // other port open?
WriteStatus( "SerOpen - other port open", iParmCommPortNo, otherPortOpen );
return otherPortOpen ;
}

// Debug messages activated for COM port if set */
m_COM.DebugEnable(m_debugIO);

// COM port settings.
pTTY = m_COM.PresetOpenComPort();
BAUDRATE(pTTY) = CBR_1200;
BYTESIZE(pTTY) = 8;
PARITY(pTTY) = NOPARITY;
STOPBITS(pTTY) = TWOSTOPBITS;
// FLOWCTRL(pTTY) = FC_XONXOFF; // Do we need XON/XOFF ???

// Open the selected port for I/O
iSerOpenErr = m_COM.OpenComPort(iParmCommPortNo);

if(iSerOpenErr < 0){ // If there is an error, return it.
WriteStatus("SerOpen", iParmCommPortNo, iSerOpenErr);
return iSerOpenErr;
}

m_COM.TxFlushClear(); // Flush the transmit buffer.
m_COM.RxFlushClear(); // Flush the receive buffer.

// Set the "already running" flag to keep other apps from using DLoad1W.
// NOTE: This won't work under Windows 95.
m_bAlreadyRunning = TRUE ;
m_iCommPortNo = iParmCommPortNo ;
m_szCurrentRecvStr = (LPSTR)m_sReturnStr;
m_iTotalRecd = 0 ;
return noErr;
}
Next
Reply
Map
View

Click here to load this message in the networking platform