Lazarus
Programming => Operating Systems => Windows CE => Topic started by: sin_dragan on September 19, 2013, 09:32:24 am
-
I need assistance in using C\C++ in WinCE. I don't have much expirience in this so please do take my apologies if I made some trivial error.
I've developing stock count application for Datalogic WinCE 5 and 6 device. I've downloaded device SDK with help file and it states that the DLL (DL_API.lib) export their function in 3 ways:
1. Regular exported functions,
2. Class functions,
3. ActiveX
I can import and use "regular" functions okay.
However, in regular functions I can only switch on only one Led on my device:
void DLLED_Set(BOOL value) (this controls green led, my device has two: Green and Red). This works ok.
So I have to use Class or ActiveX for RedLed:
This is help from Class functions:
DlDevice::SetRedLed
It enables/disables the red Led according to the parameter setting.
void SetRedLed(unsigned long bValue)
Parameters
unsigned long
if different from zero it turns on the green Led. If set to zero, it turns off the green Led.
Return Value
None
Requirements
Header:
declared in DL_Device.h, include DL_Device.h.
Library:
use DL_API.lib.
This is for ActiveX:
bGreenLedOn
This property allows switching on (set to “True”) or switching off (set to “False”) the green led. This property is not available at design time and is a write-only property at runtime.
Syntax
object.bGreenLedOn [= True|False]
Data Type
Boolean
Requirements
Header:
include DLCEDevice.h
IIDs, CLASSIDs:
include DLCEDevice_i.c
Type Library:
use DLCEDevice.tlb
Design Time Library:
use DLCEDevice.dll
I did export from DLL (atthached) but I can't import.
My question, can someone direct me how to import a function from a class in DLL or ActiveX property or fuction from DLL?
Sorry if this post seems long, but I think that the information will be of use to anyone who is using DLL functions for specific device.
Thank you,
Dragan
-
No idea for ActiveX, you may want to look at LazActiveX (http://wiki.freepascal.org/LazActiveX) though. For class functions (not sure whether it's instance method or class method), you should flatten it to C (http://ftp://ftp.freepascal.org/pub/fpc/docs-pdf/CinFreePascal.pdf) due to no standard exists for C++ name mangling.
-
I've tried today LazActiveX and imported previously registered DLL, there is a good tutorial on Wiki. I can read properties and some functions (for example nBatteryStatus and GetBatteryStatus) from activex, but I can't set Led options, strange. I noticed that all datatypes of the imported functions is declared as OleVariant, which is normal. But when I try to call function SetGreenLed(True) the function executes but nothing happends. I ve tried similar example with JavaScript from SDK and it works on device, so I know that the function is valid.
I'll try some more and then write back, I ve downloaded the PDF file, thank you.
EDIT: Maybe I'm calling the function with bad parameters, how should I set Boolean value (True) when parameter type is OleVariant?
-
Just wanted to post my results. It turns out that device hardware Leds are not reacting to ActiveX commands, but it's okay, I managed to get most of the functions.
I ve read on Wiki for LazActiveX(thx @Leledumbo) and I imported needed DLL's as packages and used methods and even events. Now I have access to scanning interface, as soon as user presses (and releases ) SCAN button, the applicaton is notified, so I can confirm that the imported ActiveX events are working on WinCE.
I had one problem, to use device functions I had to put ActiveX container on application, but I tried to hide it from user. So I place it below panel which had a alClient align. It wouldn't work, so the solution was to put on front panel and declare minimal width and height, after that I was able to use it.