TURBO PASCAL

Новости

Программы   

Turbo Pascal 

Игры

Документация   

Странности

FAQ

Ссылки

Форум

Гостевая книга

Рассылка

Благодарности

Об авторе

58: Is a program running stand-alone or from within the IDE?

 A: Not all questions 
have an answer yet. I posed this question to
the the late UseNet newsgroup comp.lang.pascal, but we have not
found an answer that would be general for all MS-DOS versions. 
The
closest we have comes from dmurdoch@mast.queensu.ca 
Duncan Murdoch
(naturally :-). I have done some slight editing of Duncan's
solution.
  uses Dos;
  type Pchar = ^Char;
  function Asciiz2Str (p : Pchar) : string;
  var
    result : string;
    len : byte;
  begin
    len := 0;
    while (p^ <> #0) and (len < 255) do
    begin
      inc(len);
      result[len] := p^;
      inc(longint(p));
    end;
    result[0] := chr(len);
    Asciiz2Str := result;
  end;
  {}
  var parentSeg : ^word;
      p         : pchar;
  begin
    if swap(DosVersion) < $0400 then
      writeln ('Requires Dos 4.0+')
    else begin
      parentSeg := ptr (prefixSeg, $16);
      p := ptr (ParentSeg^-1, 8);
      writeln ('I was launched by ', Asciiz2Str(p));
    end;
  end.
Another suggestion has been that the contents of ParamStr(0) 
would
show the launching program. I tested this on several configurations
and TP versions and found no evidence that the contention would
hold.
 

 Contents

На первую страницу

Rambler's Top100 Rambler's Top100
PROext: Top 1000

(с)Все права защищены

По всем интересующим вопросам прошу писать на электронный адрес

Hosted by uCoz