Skip Menu | You are currently an anonymous guest. | Login | Return to Main | About rt.cpan.org
 

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.

X Report information
Id: 32424
Status: resolved
Worked: 44 hours (2640 min)
Left: 0 min
Priority: 0/0
Queue: Win32-API

Owner: COSIMO <cosimo [...] cpan.org>
Requestors: Jim_Kretlow [...] harte-hanks.com
Cc:
AdminCc:

Severity: (no value)
Broken in: (no value)
Fixed in: (no value)




X History Display mode: Brief headersFull headers
#   Fri Jan 18 11:24:30 2008 Jim_Kretlow[...]harte-hanks.com - Ticket created  
Subject: Perl 5.10 WIN32-API 0.47 fails to load external DLL
Date: Fri, 18 Jan 2008 10:22:41 -0600
To: bug-Win32-API[...]rt.cpan.org
From: Jim_Kretlow[...]harte-hanks.com
[text/plain 1.8k]

I have been using Perl and the WIN32-API to encode data into barcode
sequences that can be printed.
I have over 100 barcode applications written using different barcoding DLLs
from different barcode software venders.

ActiveState has two versions of Perl available: Version 5.10 and v5.8.8
The ActiveState PPM repository has two versions of the WIN32-API: 0.47 and
0.46
Programs working in Perl 5.8.7 using WIN32-API Version: 0.41 cause the
newer releases
to abort.

One example is:

The United States Postal Service (USPS) has released a
freeware encoder for their new OneCode barcode.
This encoder is a DLL.
The DLL and sample applications are attached

In the USPS IVP program the DLL is invoked this way

char TrackString[21]; /* Input parameter Track String + 1 null*/
char RouteString[12]; /* Input parameter Route String + 1 null*/
char BarString[66]; /* Output parameter Bar String + 1 null */
int RetCode; /* Return code from the usps4cb encoder */
__declspec (dllimport) int USPS4CB( char *TrackPtr, char *RoutePtr, char
*BarPtr);

The following Perl script works perfectly in Perl 5.8.7 using WIN32-API
0.41

use Win32::API; # Allow dynaminc loading of DLLs
$dll = new Win32::API("USPS4CB","USPS4CB",[P,P,P],I);
$transbar = "\0"x66; # Blank out return area
$bardata = "3070202120200000000127203643012";
$rc = 0; # Return code from dll
$track = substr($bardata,0,20) . "\0";
$route = substr($bardata,20,11) . "\0";
$rc = $dll->Call($track,$route,$transbar); # Call DLL
$transbar =~ s/\0.*$//; # remove hex 00 string terminator
print "$transbar \n";
#####
Output is ATTDAATFADDDTDDTFTFFADADFDTDDAFTATTAAATAAFTFADFDTTTFADAFDDATDDTFT



(See attached file: win_C&Java.ZIP)
Jim Kretlow
Systems Analyst
Marketing Services, Jacksonville
Harte-Hanks Direct Marketing
Phone: 904-519-1463
Fax: 904-363-6867

We make it happen.
[application/zip 308.5k]
#   Tue Jan 29 15:48:09 2008 COSIMO - Taken  
#   Tue Jan 29 17:51:34 2008 COSIMO - Correspondence added 120 min  
[text/plain 696b]
I tried to work out what the problems are, but currently I have
problems reproducing the bugs because my current development system
(Vista + MSVC9) compiles the library but refuses to load it.

I have gone back to every version of Win32::API (even 0.41) but I have
the same problem. I will try to install an XP VM and see if that solves
the problem.

In the meanwhile, I found additional information on the subject.

Win32::API short types
[http://www.perlmonks.org/?node_id=548285]

Compiling C DLLs and using them from Perl
[http://eli.thegreenplace.net/2006/12/04/compiling-c-dlls-and-using-
them-from-perl/]

Win32::API Purgatory from Perlmonks
[http://www.perlmonks.org/?node_id=663116]

#   Tue Jan 29 17:51:36 2008 RT_System - Status changed from 'new' to 'open'  
#   Sat Feb 02 09:10:32 2008 COSIMO - Correspondence added 120 min  
[text/plain 992b]
On Mar. 29 Gen. 2008 17:51:34, COSIMO wrote:

> I will try to install an XP VM and see if that solves
> the problem.

I didn't install XP, but I tried to get Win32::API to load. And I made
it compiling my own perl 5.10 from sources with MSVC9. Probably, using
Strawberry or ActivePerl is not going to work if you then use MSVC9.
Ok, lesson learned for me.

Even with this shiny new perl 5.10, Win32::API now loads but Jim
example doesn't work neither with Win32::API 0.47, nor with Win32::API
0.41.

Other possible tracks to follow:

- Research the cause of the problem trying to interface the simplest
possible DLL.
- Install MSVC8 (2005) or MSVC++ 2003 and see if that helps.
- Try with XP instead of Vista and see if that helps.

I can only try with Express versions, since I don't own any MS compiler
license. And also, I don't want to screw up my laptop wiping out the
current system to install XP. This is my personal machine, which I
happen to use for development also... :(

#   Wed Feb 20 16:52:05 2008 COSIMO - Correspondence added 2400 min  
[text/plain 401b]
I think Win32::API 0.48, just published on CPAN, solves this problem.
I have been able to run your example and see the correct code produced.
However, you will have to change your sample code like the following:

$dll = new Win32::API(
"USPS4CB",
"USPS4CB",
['P','P','P'],
'I',
'_cdecl'
);

Please tell me if this work also for you.
I currently tested this with Vista and MSVC 2008 Express.

#   Wed Feb 20 16:52:08 2008 COSIMO - Status changed from 'open' to 'resolved'  
#   Wed Feb 20 17:26:21 2008 Jim_Kretlow[...]harte-hanks.com - Correspondence added  
Subject: Re: [rt.cpan.org #32424] Perl 5.10 WIN32-API 0.47 fails to load external DLL
Date: Wed, 20 Feb 2008 17:21:17 -0500
To: bug-Win32-API[...]rt.cpan.org
From: Jim_Kretlow[...]harte-hanks.com
[text/plain 2k]
Cosimo,
The new release has not become available yet (at least it does not display
in newest release) , but I will test it as soon as I find it.
Thanks

Jim Kretlow
Systems Analyst
Marketing Services, Jacksonville
Harte-Hanks Direct Marketing
Phone: 904-519-1463
Fax: 904-363-6867

We make it happen.




"Cosimo Streppone
via RT"
<bug-Win32-API[...]rt To
.cpan.org> Jim_Kretlow[...]harte-hanks.com
cc
02/20/2008 04:52
PM Subject
[rt.cpan.org #32424] Perl 5.10
WIN32-API 0.47 fails to load
Please respond to external DLL
bug-Win32-API[...]rt.
cpan.org









<URL: http://rt.cpan.org/Ticket/Display.html?id=32424 >

I think Win32::API 0.48, just published on CPAN, solves this problem.
I have been able to run your example and see the correct code produced.
However, you will have to change your sample code like the following:

$dll = new Win32::API(
"USPS4CB",
"USPS4CB",
['P','P','P'],
'I',
'_cdecl'
);

Please tell me if this work also for you.
I currently tested this with Vista and MSVC 2008 Express.




#   Wed Feb 20 17:26:22 2008 RT_System - Status changed from 'resolved' to 'open'  
#   Wed Oct 01 16:21:43 2008 COSIMO - Correspondence added  
[text/plain 289b]
On Mer. 20 Feb. 2008 17:26:21, Jim_Kretlow[...]harte-hanks.com wrote:
> Cosimo,
> The new release has not become available yet (at least it does not
display
> in newest release) , but I will test it as soon as I find it.
> Thanks
>
> Jim Kretlow
> Systems Analyst

Hi Jim,
any news on this?

#   Mon Oct 06 14:52:23 2008 Jim_Kretlow[...]harte-hanks.com - Correspondence added  
Subject: Re: [rt.cpan.org #32424] Perl 5.10 WIN32-API 0.47 fails to load external DLL
Date: Mon, 6 Oct 2008 14:51:55 -0400
To: bug-Win32-API[...]rt.cpan.org
From: Jim_Kretlow[...]harte-hanks.com
[text/plain 1.9k]
I installed Perl 5.10
Binary build 1004 [287188] provided by ActiveState
http://www.ActiveState.com
Built Sep 3 2008 13:16:37

And it worked fine.

Thank you very much!

Jim Kretlow
Systems Analyst
Marketing Services, Jacksonville
Harte-Hanks Direct Marketing
Phone: 904-519-1463
Fax: 904-363-6867

We make it happen.




"Cosimo Streppone
via RT"
<bug-Win32-API[...]rt To
.cpan.org> Jim_Kretlow[...]harte-hanks.com
cc
10/01/2008 04:21
PM Subject
[rt.cpan.org #32424] Perl 5.10
WIN32-API 0.47 fails to load
Please respond to external DLL
bug-Win32-API[...]rt.
cpan.org








<URL: http://rt.cpan.org/Ticket/Display.html?id=32424 >

On Mer. 20 Feb. 2008 17:26:21, Jim_Kretlow[...]harte-hanks.com wrote:
> Cosimo,
> The new release has not become available yet (at least it does not
display
> in newest release) , but I will test it as soon as I find it.
> Thanks
>
> Jim Kretlow
> Systems Analyst

Hi Jim,
any news on this?




#   Mon Oct 06 14:59:00 2008 COSIMO - Correspondence added  
[text/plain 33b]
This was fixed then.
Thanks Jim!

#   Mon Oct 06 14:59:02 2008 COSIMO - Status changed from 'open' to 'resolved'