Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 331097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:44:34+00:00 2026-05-12T09:44:34+00:00

I am writing some code for driving Internet Explorer from a Perl 5 program

  • 0

I am writing some code for driving Internet Explorer from a Perl 5 program through Win32::OLE, and I am looking for ways to convert numeric status/error codes that are delivered back to the Perl program via events (such as NavigateError) into a somewhat more human-readable form.

Is there some kind of library function that converts i.e. 0x800C0005L or -2146697211 to "INET_E_RESOURCE_NOT_FOUND" or something even more readable?

I have tried Win32::FormatMessage(), but that seems to work only for non application-specific error conditions.

Update: Here is some example code for clarification. Some test
output is shown below.

#!/usr/bin/perl

use strict;
use warnings;
use 5.010;

use Time::HiRes qw(sleep time);
use Win32::OLE qw(EVENTS);
use Win32::OLE::Variant;

$|++;

sub ie_browse {
    my $url = shift;
    my $ie = Win32::OLE->new('InternetExplorer.Application') or die;
    Win32::OLE->WithEvents($ie, 
        sub {
            my ($obj, $event, @args) = @_;
            given ($event) {
                when ('NavigateComplete2') {
                    push @extra, 
                      'url='.($args[1]->As(VT_BSTR));
                    say "$event: @extra";
                }
                when ('NavigateError') {
                    push @extra, 
                      'url='.($args[1]->As(VT_BSTR)),
                      'statuscode='.($args[3]->As(VT_I4));
                    say "$event: @extra";
                }
            }
        }, 'DWebBrowserEvents2');
    Win32::OLE->SpinMessageLoop;
    $ie->{visible} = 1;
    Win32::OLE->SpinMessageLoop;
    $ie->Navigate2($url);
    Win32::OLE->SpinMessageLoop;
    while(1) {
        Win32::OLE->SpinMessageLoop;
        sleep(0.1);
    }
}

ie_browse $ARGV[0];

Here is some output for two fetch attempt. Fetching the Stack Overflow
page is successful, of course.

C:\Documents and Settings\nobody\Desktop>perl ie.pl http://stackoverflow.com/
NavigateComplete2: url=http://stackoverflow.com/
Terminating on signal SIGINT(2)

But example.invalid doesn’t exist.

C:\Documents and Settings\nobody\Desktop>perl ie.pl http://example.invalid/
NavigateError: url=http://example.invalid/ statuscode=-2146697211
NavigateComplete2: url=http://example.invalid/
Terminating on signal SIGINT(2)

I am interested in turning that numeric value (-2146697211) that has been
passed back into something useful. This is not an OLE error as such but an error condition
signaled by the Internet Explorer COM object.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T09:44:34+00:00Added an answer on May 12, 2026 at 9:44 am

    Update: In light of your comment, I believe you are looking for Microsoft’s documentation on the NavigateError event:

    INET_E_INVALID_URL (0x800C0002L or -2146697214)
    INET_E_NO_SESSION (0x800C0003L or -2146697213)
    INET_E_CANNOT_CONNECT (0x800C0004L or -2146697212)
    ...
    

    You could create a module by parsing this list:

    package Win32::WebBrowserControl::ErrorMnemonics;
    
    use strict;
    use warnings;
    
    my %lookup;
    
    sub import {
        my $class = shift;
        while ( my $x = <DATA> ) {
            my ($mnemonic, $code) = ( $x =~ m{
                ^(INET_E_[A-Z_]+)
                [ ]
                \(
                    0x[[:xdigit:]]+L
                    [ ] or [ ]
                    (-[[:digit:]]+)
                \)
            }x ) or next;
            $lookup{$code} = $mnemonic;
        }
    }
    
    sub lookup {
        my $self = shift;
        return $lookup{shift()};
    }
    
    1;
    __DATA__
    INET_E_INVALID_URL (0x800C0002L or -2146697214)
    INET_E_NO_SESSION (0x800C0003L or -2146697213)
    INET_E_CANNOT_CONNECT (0x800C0004L or -2146697212)
    INET_E_RESOURCE_NOT_FOUND (0x800C0005L or -2146697211)
    INET_E_OBJECT_NOT_FOUND (0x800C0006L or -2146697210)
    INET_E_DATA_NOT_AVAILABLE (0x800C0007L or -2146697209)
    INET_E_DOWNLOAD_FAILURE (0x800C0008L or -2146697208)
    INET_E_AUTHENTICATION_REQUIRED (0x800C0009L or -2146697207)
    INET_E_NO_VALID_MEDIA (0x800C000AL or -2146697206)
    INET_E_CONNECTION_TIMEOUT (0x800C000BL or -2146697205)
    INET_E_INVALID_REQUEST (0x800C000CL or -2146697204)
    INET_E_UNKNOWN_PROTOCOL (0x800C000DL or -2146697203)
    INET_E_SECURITY_PROBLEM (0x800C000EL or -2146697202)
    INET_E_CANNOT_LOAD_DATA (0x800C000FL or -2146697201)
    INET_E_CANNOT_INSTANTIATE_OBJECT (0x800C0010L or -2146697200)
    INET_E_REDIRECT_FAILED (0x800C0014L or -2146697196)
    INET_E_REDIRECT_TO_DIR (0x800C0015L or -2146697195)
    INET_E_CANNOT_LOCK_REQUEST (0x800C0016L or -2146697194)
    INET_E_USE_EXTEND_BINDING (0x800C0017L or -2146697193)
    INET_E_TERMINATED_BIND (0x800C0018L or -2146697192)
    INET_E_INVALID_CERTIFICATE (0x800C0019L or -2146697191)
    INET_E_CODE_DOWNLOAD_DECLINED (0x800C0100L or -2146696960)
    INET_E_RESULT_DISPATCHED (0x800C0200L or -2146696704)
    INET_E_CANNOT_REPLACE_SFP_FILE (0x800C0300L or -2146696448)
    INET_E_CODE_INSTALL_BLOCKED_BY_HASH_POLICY (0x800C0500L or -2146695936)
    INET_E_CODE_INSTALL_SUPPRESSED (0x800C0400L or -2146696192)
    

    For OLE related errors, see the Win32::OLE documentation:

    Win32::OLE->LastError()

    The LastError() class method returns
    the last recorded OLE error. This is a
    dual value like the $! variable: in a
    numeric context it returns the error
    number and in a string context it
    returns the error message. The error
    number is a signed HRESULT value.
    Please use the HRESULT(ERROR) function
    to convert an unsigned hexadecimal
    constant to a signed HRESULT.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 179k
  • Answers 179k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It's a little more complicated as this MSDN article shows. May 12, 2026 at 3:50 pm
  • Editorial Team
    Editorial Team added an answer You might want to have a look at Microsoft's Information… May 12, 2026 at 3:50 pm
  • Editorial Team
    Editorial Team added an answer You can move validation to client side adding EnableClientScript="true" attribute.… May 12, 2026 at 3:50 pm

Related Questions

I been waiting for sometime now to bring my Asp.net Preview 4 project up
I am writing some code to generate an opml file from a list of
Do there exist any ARM processors that implement the architecture version ARMv5TE (or ARMv5TEJ)
I am writing some code to determine whether a network domain is registered. For

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.