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.
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,
var
siet:tidtcpserver;
begin
siet:=tidtcpserver.Create(
siet.DefaultPort:=5611;
siet.Active:=true;
end.
ASKER
It doesen't matter, i put short code to find out only how to create component dynamically.....
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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
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
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
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
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 :-)
ASKER
no problem
is this all the code?