Lazarus

Programming => Operating Systems => Windows => Topic started by: eldonfsr on May 22, 2022, 02:20:56 am

Title: Open Application with start values on windows
Post by: eldonfsr on May 22, 2022, 02:20:56 am
I need run application but must be receive a parameters to start some think like that

Admin  "config.txt"

Admin "network.txt"

the file contain some configuration like path and user information



Title: Re: Open Application with start values on windows
Post by: speter on May 22, 2022, 02:27:51 am
Have a look at "paramstr" (https://www.freepascal.org/docs-html/rtl/system/paramstr.html).

You could execute a console/command-line with something like:

prog 42 foobar.txt
^0   ^1  ^1

within the program you access the parameters with code like
Code: Pascal  [Select][+][-]
  1. program_exe := paramstr(0);
  2. some_number := paramstr(1);
  3. some_filename := paramstr(2);

In Windows, you can also create a short-cut, then specify parameters, to run the program in a GUI.

cheers
S.
Title: Re: Open Application with start values on windows
Post by: eldonfsr on May 22, 2022, 03:20:09 am
Ok i understand but where check parameters on GUI on main form?

Title: Re: Open Application with start values on windows
Post by: Thausand on May 22, 2022, 03:51:21 am
Ok i understand but where check parameters on GUI on main form?
Depends. When you need parameters  :)

Can be in project .lpr or mainform create or when click button or when open file or ...
Title: Re: Open Application with start values on windows
Post by: speter on May 23, 2022, 02:40:23 am
Ok i understand but where check parameters on GUI on main form?

I am not sure what you mean.
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. var
  3.   a : byte;
  4. begin
  5.   memo1.append('paramcount = '+paramcount.tostring);
  6.   for a := 0 to paramcount do
  7.     memo1.append('param '+a.tostring+' = '+paramstr(a));
  8. end;
cheers
S.

Title: Re: Open Application with start values on windows
Post by: eldonfsr on May 23, 2022, 11:20:28 pm
Thanks i never use parameters to start app i was some confuse but i got run the app with parameters....

thanks so much for you help...
TinyPortal © 2005-2018