Link to home
Start Free TrialLog in
Avatar of Murdoc
Murdoc

asked on

Console application (creating dynamically components)

How can I create dynamically component, for example tidtcpserver(indy) when working with console application.
I tried with code below but it doesn't work....

thank you in advance


program Project2;

{$APPTYPE CONSOLE}

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Spin, XPMan, IdBaseComponent, IdComponent, IdTCPServer,
  IdThreadMgr, IdThreadMgrDefault, ComCtrls,toolwin,extctrls,registry;

var
siet:tidtcpserver;
begin
siet:=tidtcpserver.Create(self);
siet.DefaultPort:=5611;
siet.Active:=true;
end.
 

Avatar of kretzschmar
kretzschmar
Flag of Germany image

guessing your app will finish shortly

is this all the code?

Avatar of Murdoc
Murdoc

ASKER

It doesen't matter, i put short code to find out only how to create component dynamically.....
ASKER CERTIFIED SOLUTION
Avatar of geobul
geobul

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
AS geobul explained, I normally put these into a try..Except section :

siet := TidTcpServer.Create(nil);
 Try
  Try
   siet.Host := MyHost ..... {blah}
   { and other commands }
   Except
   Do something with error message
   end;
 Finally
  Siet.Free;
End;

This is not compilable code but I think you get the picture :)

Regards
Smurff
 
Avatar of Murdoc

ASKER

thanks for fast and good answer. I'd like to divide this points between geobul and smurf but i can not...:+{{
So i have to give this points to first good answer so don't be mad smurf.All i can do is increase points.

regards
Avatar of Murdoc

ASKER

P.S. this siet(tidtcpserver) suppose to be shiet...:+}}}
>so don't be mad smurf

haha dont worry about it. I dont really care about the points :)
Ive learnt so much from this forum over the years and I just like to give something back. geobul has helped me a quite a few times over the years and he deserves every point he gets.

Have a good weekend everyone,
Smurff
Thank you, Murdoc :-)
Avatar of Murdoc

ASKER

no problem