Solved

Grab an ActiveX event

Posted on 2006-11-03
11
597 Views
Last Modified: 2008-01-09
I'm currently working with a fingerprint reader SDK that we're calling an ActiveX method. The problem is that we need to grab an event that is fired from the device in order to get the ID of the device we want to call with the method. I've read some about the Win32::OLE->WithEvent() but do not know how to tailor it to my situation, or if its even possible.

There is an event like below:

private: System::Void axGrFingerXCtrl2_SensorPlug(System::Object *  sender, _IGrFingerXCtrlEvents_SensorPlugEvent *  e) {
axGrFingerXCtrl2->CapStartCapture(e->idSensor);
}

We need to use Perl to get an ID of the fingerprint reader that is returned with the event call. Is there anyway to grab an even like this, and if so how?
0
Comment
Question by:scanhelp
  • 5
  • 5
11 Comments
 
LVL 25

Expert Comment

by:clockwatcher
ID: 17872028
Do you have a non dotnet sample to look at?  Or a link to the SDK documentation for the device you're using?
0
 
LVL 6

Expert Comment

by:tone28
ID: 17873043
Without knowing how you are creating the ActiveX objects in perl I would recommend reading this example.

http://www.perl.com/pub/a/2005/04/21/win32ole.html

Plus have you had a chance to look at the perldoc for OLE?

Tone
0
 

Author Comment

by:scanhelp
ID: 17877153
We're using the GrFinger SDK (http://www.griaule.com/page/en-us/grfinger_sdk). I've been scanning the Win32::OLE documentation to get an idea of how to model the way they handle events with the OLE->WithEvents() but have been unable to make it work. At this point im not sure if it is possible or whether I'm just not doing it right.
0
 
LVL 25

Expert Comment

by:clockwatcher
ID: 17877986
Can't test it because I don't have a fingerprint device, but I think this will work:

example.pl
-------------

package FingerEventHandlers;

sub SensorPlug {
  my ($self, $idSensor) = @_;
  print "$idSensor was plugged in\n";
}

sub SensorUnplug {
  my ($self, $idSensor) = @_;
  print "$idSensor was unplugged\n";
}

sub FingerDown {
  my ($self, $idSensor) = @_;
  print "Got a finger down from $idSensor\n";
}

sub FingerUp {
  my ($self, $idSensor) = @_;
  print "Got a finger up from $idSensor\n";
}

sub ImageAcquired {
  my ($self, $idSensor, $width, $height, $rawImage, $res) = @_;
  print "Got an image $width x $height\n";
}

1;

package main;

use strict;
use Win32::OLE qw(EVENTS);

my $finger = Win32::OLE->new("GrFingerX.GrFingerXCtrl");
Win32::OLE->WithEvents($finger, 'FingerEventHandlers', '_IGrFingerXCtrlEvents');
Win32::OLE->MessageLoop();
0
 

Author Comment

by:scanhelp
ID: 17884079
I'm not getting flags showing anything invalid in the handling. I am getting a compile error in the line:

Win32::OLE->WithEvents($finger, 'FingerEventHandlers', '_IGrFingerXCtrlEvents');

The error says "Win32::OLE error 0x80070057: 'The parameter is incorrect' at FingerEventHandlers". I was looking up what could be the cause of this and found an article interactiing with IE, which says that M$ sends back data in an invalid format. Do you believe that this could be the case in this application? The main point behind this entire program is to just save the scanned image file to the local disk, and part of doing that is handling these events as no image can be saved without handling these events. So I'm stuck at this point until I can figure this out. Any suggestions?
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 25

Expert Comment

by:clockwatcher
ID: 17886299
At compile time?  What do you get with?  

 perl -cw example.pl

The error you're describing doesn't sound possible to get at compile-time.  Can you post the exact error with line number?

Also try just this:

example2.pl
--------------
use strict;
use Win32::OLE qw(EVENTS);

sub ehandler {
  my ($obj, $event) = @_;
  print "$event\n";
}

my $finger = Win32::OLE->new("GrFingerX.GrFingerXCtrl");
Win32::OLE->WithEvents($finger, \&ehandler, '_IGrFingerXCtrlEvents');
Win32::OLE->MessageLoop();

And let me know what you get back.
0
 

Author Comment

by:scanhelp
ID: 17893220
example2.pl is giving the same error message as example.pl.

I am using Perl Express IDE, with ActivePerl Interpreter.

Here is the error message that I am receiving:
Win32::OLE(0.1703) error 0x80070057; "The parameter is incorrect" at example2.pl line 12
  eval(...) called at example2.pl line 12
0
 
LVL 25

Accepted Solution

by:
clockwatcher earned 250 total points
ID: 17895890
Try:

package FingerEventHandlers;

sub SensorPlug {
  my ($self, $idSensor) = @_;
  print "$idSensor plugged in\n";
  print $self->CapStartCapture($idSensor);
 
}

sub SensorUnplug {
  my ($self, $idSensor) = @_;
  print "$idSensor was unplugged\n";
}

sub FingerDown {
  my ($self, $idSensor) = @_;
  print "Got a finger down from $idSensor\n";
}

sub FingerUp {
  my ($self, $idSensor) = @_;
  print "Got a finger up from $idSensor\n";
}

sub ImageAcquired {
  my ($self, $idSensor, $width, $height, $rawImage, $res) = @_;
  print "Got an image $width x $height\n";
}

1;

package main;

use strict;
use Win32::OLE qw(EVENTS);

my $finger = Win32::OLE->new("GrFingerX.GrFingerXCtrl");

Win32::OLE->WithEvents($finger, 'FingerEventHandlers');
$finger->Initialize();
$finger->CapInitialize();

Win32::OLE->MessageLoop();
0
 

Author Comment

by:scanhelp
ID: 17901811
Okay that got it working, thank you.  I plan on giving you the allotted points, but could you answer a couple more thing for me.

I am trying to host this on a server, so the user can scan their finger and save it to the server.

What is the best way to deploy this so it runs on the client-side?  Will the user need to install the Perl runtime?
0
 
LVL 25

Expert Comment

by:clockwatcher
ID: 17903592
I recommend packaging it up into an executable with PerlApp from the ActiveState Perl Dev Kit (http://www.activestate.com/Products/Perl_Dev_Kit/?tn=1) and deploying the executable.  If that's not an option and you want to run this client-side in perl, then you'll need to include a perl install with your app.  You'll also (of course) need to install Griaule's ActiveX control on the client.  

Personally, I'd probably write up a C/C++ XS wrapper around their standard DLL (rather than screw with their ActiveX one) and package the whole thing up with PerlApp.  Depending on the extent you're going to be using the library, you may even be able to get away with Win32::API and Win32::API::Callback.
0
 

Author Comment

by:scanhelp
ID: 17916373
Clockwatcher you’ve been an astounding help on this pet project. I very much appreciate your time and consideration on this matter. Please accept these points and our thanks for the help. Your feedback has been invaluable.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now