没有任何form像一运行产生一个cmd窗口! 使用winmain? 不过怎么建立一个没有form的工程?

解决方案 »

  1.   

    new/other/control panel application
      

  2.   

    program Project1;{$APPTYPE CONSOLE}
    uses
      Sysutils;
    const
      Max=100;
    var
      rn, un, cnt: Integer;
      guess: Boolean;
    begin
      Randomize;
      rn := Trunc(Random(Max) + 1);
      WriteLn('from 1 to '+inttostr(Max)+',guess!');
      WriteLn('Your guess is: ');
      cnt := 1;
      //un := 0;
      Guess := False;
      while Guess = False do
      begin
        ReadLn(un);
        if un > rn then
          WriteLn('Wrong, it is smaller ')
        else if un < rn then
          WriteLn('Wrong, it is larger')
        else //un=rn
          begin
            Guess:=True;
            Writeln('Correct!'+ IntToStr(cnt)+' times !')
          end;
        cnt := cnt + 1;
      end; //while
      ReadLn; //don't close the window, wait for [Enter]
    end.
      

  3.   

    file-->new-->other-->new选项卡中选择Console Application便可以编写控制台(dos)程序了