Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

wrestling with .NET application via perl

by trillich (Sexton)
on Sep 28, 2007 at 03:25 UTC ( [id://641460]=perlquestion: print w/replies, xml ) Need Help??

trillich has asked for the wisdom of the Perl Monks concerning the following question:

short version: using blackbaud API
  • perl script throws an error
  • VB script throws the same error
  • simple fix to the VB script gets it to work
  • how to replicate that fix in the perl script?
  • long version:

    we're stuck, trying to grapple with the interface to a .NET application (blackbaud). it has a well-documented API and some sample scripts (VB) that come with it, which are VB version 6; we only have VStudio 2003pro, so when we upgrade the scripts there's a glitch -- the same exact problems that our perl attempts have (namely "Startup Error: Failed to load control 'WebHost'") we managed to get a fix working from inside VB, but we don't know how to replicate that fix using perl... any ideas?

    the fix: here's the declaration added to the VB code:

    Private Declare Function OleInitialize Lib "ole32" (ByVal reserved As Integer) As Integer
    then we can call it before the rest of our app starts up:
    OleInitialize(0) 'only needed if no UI shown before init
    the minimal perl script we're using -- complete with error dialog -- is:
    use Win32::OLE;
    use strict;
    
    my $appid = 'AFNAPI7.FE_API';
    my $app = Win32::OLE->new($appid)
            or die "Canna create new object for $appid";
    $app->{SignOutOnTerminate} = 1;
    my $login = $app->Init(''); # error dialog here
    print "Login results: $login\n\n";
    the ideal situation would be to PULL the data from blackbaud on request using perl, instead of PUSHING it from within blackbaud using visual basic, which is, um, not quite as robust a language. but how to mimic that fix from within perl? using Win32 no doubt, but how? any pointers?
    • Comment on wrestling with .NET application via perl

    Replies are listed 'Best First'.
    Re: wrestling with .NET application via perl
    by Errto (Vicar) on Sep 28, 2007 at 03:31 UTC
      Use Win32::API. You can call any old Windows library function your heart desires using that, and OleInitialize should not be an exception for any reason I can think of.
    Re: wrestling with .NET application via perl
    by Corion (Patriarch) on Sep 28, 2007 at 06:36 UTC

      I would try the following (as gleaned from the Win32::OLE documentation):

      Win32::OLE->Initialize(Win32::OLE::COINIT_OLEINITIALIZE)

      If that doesn't work, the other way already recommended is using Win32::API and calling OleInitialize yourself. That will bring different problems if Win32::OLE thinks it's the only one making OLE calls.

        blessings upon you and your horse and the road you rode in on. :) works a treat! thanks a ton!

    Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Domain Nodelet?
    Node Status?
    node history
    Node Type: perlquestion [id://641460]
    Approved by Errto
    help
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this?Last hourOther CB clients
    Other Users?
    Others romping around the Monastery: (4)
    As of 2024-04-25 13:13 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found