Recent

Author Topic: Import a functions from DLL  (Read 5313 times)

sin_dragan

  • Full Member
  • ***
  • Posts: 127
Import a functions from DLL
« 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

 
Windows 7 64 bit
Lazarus 1.4.1 (w/fixes) FPC 2.6.4 win32

Leledumbo

  • Hero Member
  • *****
  • Posts: 8746
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Import a functions from DLL
« Reply #1 on: September 19, 2013, 05:53:22 pm »
No idea for ActiveX, you may want to look at LazActiveX though. For class functions (not sure whether it's instance method or class method), you should flatten it to C due to no standard exists for C++ name mangling.

sin_dragan

  • Full Member
  • ***
  • Posts: 127
Re: Import a functions from DLL
« Reply #2 on: September 19, 2013, 08:21:57 pm »
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?
« Last Edit: September 19, 2013, 08:25:37 pm by sin_dragan »
Windows 7 64 bit
Lazarus 1.4.1 (w/fixes) FPC 2.6.4 win32

sin_dragan

  • Full Member
  • ***
  • Posts: 127
Re: Import a functions from DLL
« Reply #3 on: September 22, 2013, 01:57:36 pm »
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.
Windows 7 64 bit
Lazarus 1.4.1 (w/fixes) FPC 2.6.4 win32

 

TinyPortal © 2005-2018