相关文章推荐
完美的脸盆  ·  Java ...·  3 周前    · 
阳刚的凉面  ·  C++ File文件处理 ...·  8 月前    · 
喝醉的镜子  ·  ThinkPHP ...·  9 月前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

Just figured that by looking at a Form application that I simply need to do the initialization by hand:

Application.CreateForm(TDataModule1, DataModule1);

UPDATE

As suggested in the comments, I ended up implementing:

DataModule1 := TDataModule1.Create(nil)
                Or use the Project Options dialog to set the data module as auto-create "form" which has the same effect.
– Ondrej Kelle
                Feb 18, 2013 at 22:25
                Personally I don't like relying on the .dpr file to do this. Add that code to the initialization section of the data module unit. That makes the unit self-contained. And I see no reason to use Application.CreateForm either. Just call the constuctor, DataModule1 := TDataModule1.Create(Application).
– David Heffernan
                Feb 18, 2013 at 22:25
                I don't get it, using Application in a Console application? Doesn't that practically defeat the purpose of a console application?
– Jerry Dodge
                Feb 19, 2013 at 6:02
                @David,@Jerry  We don't need to involve Application object for this. simple DataModule1 := TDataModule1.Create(nil) and when you're done with it DataModule1.Free.
– kobik
                Feb 19, 2013 at 11:55
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.