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

  • SEARCH
  • Home
  • 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 7668825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:27:19+00:00 2026-05-31T15:27:19+00:00

I’m getting error when i call AddExceptionToFirewall in my Console Application Exception EOleSysError In

  • 0

I’m getting error when i call AddExceptionToFirewall in my Console Application

Exception EOleSysError In Module at CoInitialize has not been called

how to fix it why I’m getting this error even using ComObj ,ActiveX in uses clause?

Procedure AddExceptionToFirewall(Const Caption, Executable: String);
      const
       NET_FW_PROFILE2_DOMAIN  = 1;
       NET_FW_PROFILE2_PRIVATE = 2;
       NET_FW_PROFILE2_PUBLIC  = 4;
       NET_FW_IP_PROTOCOL_TCP = 6;
       NET_FW_ACTION_ALLOW    = 1;
      var
      fwPolicy2      : OleVariant;
      RulesObject    : OleVariant;
      Profile        : Integer;
      NewRule        : OleVariant;
      begin
      Profile             := NET_FW_PROFILE2_PRIVATE OR NET_FW_PROFILE2_PUBLIC;
      fwPolicy2           := CreateOleObject('HNetCfg.FwPolicy2');
      RulesObject         := fwPolicy2.Rules;
      NewRule             := CreateOleObject('HNetCfg.FWRule');
      NewRule.Name        := Caption;
      NewRule.Description := Caption;
      NewRule.Applicationname := Executable;
      NewRule.Protocol := NET_FW_IP_PROTOCOL_TCP;
      NewRule.Enabled := TRUE;
      NewRule.Profiles := Profile;
      NewRule.Action := NET_FW_ACTION_ALLOW;
      RulesObject.Add(NewRule);
     end;
  • 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-31T15:27:20+00:00Added an answer on May 31, 2026 at 3:27 pm

    You need to call OleInitialize (or OleInitializeEx) in your application before you try and Create a COM object.

    MSDN: OleInitialize function
    Initializes the COM library on the current apartment, identifies the
    concurrency model as single-thread apartment (STA), and enables
    additional functionality described in the Remarks section below.
    Applications must initialize the COM library before they can call COM
    library functions other than CoGetMalloc and memory allocation
    functions.

    I do this in my main unit:

    initialization
      OleInitialize(nil);
    
    finalization
      OleUninitialize;
    

    This function is in the ActiveX unit (via an External) but is not automatically called by that unit. It could be that other units will call this. It depends on when your function runs.

    Here is a Stackoverflow question asking about calling OleInitialize twice.

    Also be aware that this is thread specific. If are starting a different thread where this function is running you need to call OleInitialize on that thread.

    Here is another good page that goes into a lot of detail: Inside the COM Client

    A relevant quote from that page:

    In a standard Delphi EXE COM application, CoInitialize/Ex and
    CoUninitialize is automatically called from within the ComObj module.
    The CoInitialize/Ex process is chained through the InitProc
    initialization sequence that gets called from TApplication.Initialize.
    Thus, it is important to call Application.Initialize (usually in the
    DPR file) as the first statement in an EXE application.

    The effect of forgetting to call Application.Initialize is usually the
    nasty “CoInitialize has not been called” error at the first statement
    that tries to make a COM call, or more specifically, the first
    statement that exports/imports a COM interface pointer. On a different
    note, ComObj calls CoInitialize/Ex only for EXEs, not for DLLs. A
    DLL’s lifetime and threading requirements is a subset of its host
    application. Therefore, it is the responsibility of the host
    application to initialize the COM runtime before calling into a DLL
    application. Explicitly calling CoInitialize/Ex in a DLL can result in
    unpredictable behavior and nasty runtime failures.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
In my XML file chapters tag has more chapter tag.i need to display chapters

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.