07-31-2011 10:37 AM
Solved! Go to Solution.
07-31-2011 04:42 PM
07-31-2011 07:30 PM
Try replacing the header file with the text below (for unknown reasons, the forum won't let me upload it). The function calls use simple types, so there's a good chance that the DLL Import Wizard will be able to handle it using this header file. For some reason the DLL Import Wizard, at least in LV 2009, imported bool as char * instead of int, so I replaced the bools with ints as well. See if it works.
// Header file for use with stp.dll int InitStp(); int RunMotor1(int steps, int interval, int direction, int outputs); int StopMotor1(int outputs); int RunMotor2(int steps, int interval, int direction, int outputs); int StopMotor2(int outputs); int SetStepMode(int M1Mode, int M2Mode); int GetCurrentStatus(int *M1Active, int *M2Active, int *M1Steps, int *M2Steps, int *Inputs);
08-01-2011 01:09 AM
WOW.... Straight out and it works... Thanks alot for the help nathand, I really appreciate it.
:):):):):):):)
08-16-2011 02:39 AM - edited 08-16-2011 02:43 AM
Actually bool is a C++ feature. And the standard says nothing about what size to use for that data type, so it is implementation (compiler) specific. Most compilers seem to use an 8 bit integer however. Visual C++ 4.2 used a header to define bool as int, but later version have a built in type that is implemented as 1 byte type.
This is different from BOOL, which is a Microsoft Windows API datatype and is indeed defined to be always a 32 bit value. As long as you pass a bool by value it won't really matter to much, since the compiler will pass any parameter smaller than 32 bit anyhow in a 32 bit stack address. However you have to watch out about possible sign extension then, if the caller and callee don't use the same parameter size. 0xFF seen as a signed 8 bit integer (-1) is something entirely different than the same value interpreted as 32 bit signed integer (255). When passing it by reference you need to be a bit more careful, but using a larger size in caller than what the callee expects is always safer, eventhough you need to watch out about sign extension.