Visual Express C++ 8055, errors

Hi, I’m getting some errors trying to get the visual express to run the sample code.
First was that it couldn’t find afxres.h. I replaced it with windows.h
Then _ltoa should be replaced by _ltoa_s , which then lead to problems since the string was too short, should be size 6.
Then the functions must have a return type e.g.

FUNCTION __stdcall CloseDevice();
needs a return type, so I tried FUNCTION void__stdcall CloseDevice();

I managed to get it all to compile and connect but it didn’t work.

The closest I’ve got it to working is using the C++ builder trail on the old BC++ sample, but I don’t want to have to buy that compiler just for this. So I know the board is working.

Is there a really simple C++ code available that works on visual express c++ or maybe another decent(modern) free c++ builder. I’m not too fussed about a graphics user interface, just something that when run will turn the lights on, or something.

I made a test according to your experience.
I made all the same modifications as you, but I didn’t replace the _ltoa by _ltoa_s. There was “only” warning to do this.
I’m using Windows Vista - so I had to copy the latest version 3 DLL to the project folder.
Then compiled it with Microsoft Visual C++ 2008 Express Edition.
Seems to work.
Here is a link to the project files: box.net/shared/j6grkiv9jz

Thanks that project worked fine. I’m very impressed with the quality of support on these forums

Hi,
I had the same problems.
Is it possible to get a smal simple code which runs on MS Visual Express C ++ 2008.
I do not understand all things in the code that you linked here.
I found this code which does not run in MS Visual Express C ++ 2008. Is it possible to turn this to a MS VE C++ 2008 code?:
main.cpp:
#include <windows.h>
#include “k8055.cpp”
int main(){
init();
OpenDevice(0);
WriteAllDigital(255);//Schaltet Alle Digitalen Ports ein
CloseDevice();
return 0;
}
k8055.cpp:

typedef void(__stdcall *t_func)(long );
typedef void(__stdcall *t_func0)();
typedef long(__stdcall *t_func1)();
typedef void(__stdcall *t_func2)(long *, long *);
typedef void(__stdcall *t_func3)(long , long );
typedef long(__stdcall *t_func4)(long );
typedef bool(__stdcall *t_func5)(long );

//Allgemeine Arbeitsweisen
t_func4 OpenDevice;
t_func0 CloseDevice;

//Analog in Digital konvertiern
t_func4 ReadAnalogChannel;
t_func2 ReadAllAnalog;

//Digital in Analog konvertieren
t_func3 OutputAnalogChannel;
t_func3 OutputAllAnalog;
t_func ClearAnalogChannel;
t_func0 ClearAllAnalog;
t_func SetAnalogChannel;
t_func0 SetAllAnalog;

//Digitaler Ausgang
t_func WriteAllDigital;
t_func ClearDigitalChannel;
t_func0 ClearAllDigital;
t_func SetDigitalChannel;
t_func0 SetAllDigital;

//Digitaler Eingang
t_func5 ReadDigitalChannel;
t_func1 ReadAllDigital;

//Zählerfunktionen
t_func3 ReadCounter;
t_func ResetCounter;
t_func3 SetCounterDebounceTime;

HINSTANCE hModule;

int init()
{
hModule = LoadLibrary(“k8055d.dll”);
OpenDevice = (t_func4) GetProcAddress(hModule, “OpenDevice”);
CloseDevice = (t_func0) GetProcAddress(hModule, “CloseDevice”);
ReadAnalogChannel = (t_func4) GetProcAddress(hModule, “ReadAnalogChannel”);
ReadAllAnalog = (t_func2) GetProcAddress(hModule, “ReadAllAnalog”);
OutputAnalogChannel = (t_func3) GetProcAddress(hModule, “OutputAnalogChannel”);
OutputAllAnalog = (t_func3) GetProcAddress(hModule, “OutputAllAnalog”);
ClearAnalogChannel = (t_func) GetProcAddress(hModule, “ClearAnalogChannel”);
ClearAllAnalog = (t_func0) GetProcAddress(hModule, “ClearAllAnalog”);
SetAnalogChannel = (t_func) GetProcAddress(hModule, “SetAnalogChannel”);
SetAllAnalog = (t_func0) GetProcAddress(hModule, “SetAllAnalog”);
WriteAllDigital = (t_func) GetProcAddress(hModule, “WriteAllDigital”);
ClearDigitalChannel = (t_func) GetProcAddress(hModule, “ClearDigitalChannel”);
SetDigitalChannel = (t_func) GetProcAddress(hModule, “SetDigitalChannel”);
SetAllDigital = (t_func0) GetProcAddress(hModule, “SetAllDigital”);
ReadDigitalChannel = (t_func5) GetProcAddress(hModule, “ReadDigitalChannel”);
ReadAllDigital = (t_func1) GetProcAddress(hModule, “ReadAllDigital”);
ReadCounter = (t_func3) GetProcAddress(hModule, “ReadCounter”);
ResetCounter = (t_func) GetProcAddress(hModule, “ResetCounter”);
SetCounterDebounceTime = (t_func3) GetProcAddress(hModule, “SetCounterDebounceTime”);
}

I

Based on your code I made a Windows Forms applications in Visual C++ 2008 Express.
I modified the init() section according to the Microsoft’s example, how to explicitly load the DLL at run time.
msdn.microsoft.com/en-us/library/784bt7z7(VS.71.aspx
Here a link to download my project files: box.net/shared/je0p1i752p

Please tell me how I can use SetCurrentDevice() when I use two boards???

I am a student and I really need this info for my project…

Thank you Siss

I added some functions to the demo.
Now there are following functions you may use as an example:

h = OpenDevice(0); if (h == 0) { ... // open succeeded }

h = OpenDevice(1); if (h == 1) { ... // open succeeded }

h = SetCurrentDevice(0); if (h == 0) { ... // SetCurrentDevice succeeded }

h = SetCurrentDevice(1); if (h == 1) { ... // SetCurrentDevice succeeded }
Here a link to download the project files: box.net/shared/2mejt9njvd

Now I can use both my k8055 sepperately :smiley:

Thank you so much