delphi - Coinitialize has not been called error message -


i in process of coding console application create firewall exception main app called client.exe uploads few documents our servers via ftp. borrowed rruz code delphi 7 windows vista/7 firewall exception network locations code looks this:

program changefw;  {$apptype console}  {$r *.res}  uses   system.sysutils,   comobj;  var   execname: string;  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;  begin   try     { todo -ouser -cconsole main : insert code here }     execname := getcurrentdir + '\' + 'client.exe';     addexceptiontofirewall('sip inventory',execname);   except     on e: exception       writeln(e.classname, ': ', e.message);   end; end. 

when execute application following error message: eoiesyserror: coinitialize has not been called, progid: “hnetcfg.fwpolicy2” idea doing wrong? please point me in right direction? thank much.

if want use com - objects have call coinitialize corresponding couninitialize.

in usual application done.
far program console program have call on own.

..... coinitialize(nil); try   try     { todo -ouser -cconsole main : insert code here }     execname := getcurrentdir + '\' + 'client.exe';     addexceptiontofirewall('sip inventory',execname);   except     on e: exception       writeln(e.classname, ': ', e.message);   end;   couninitialize; end; ..... 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -