Forum > Windows

Open Application with start values on windows

(1/2) > >>

eldonfsr:
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



speter:
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  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program_exe := paramstr(0);some_number := paramstr(1);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.

eldonfsr:
Ok i understand but where check parameters on GUI on main form?

Thausand:

--- Quote from: eldonfsr on May 22, 2022, 03:20:09 am ---Ok i understand but where check parameters on GUI on main form?

--- End quote ---
Depends. When you need parameters  :)

Can be in project .lpr or mainform create or when click button or when open file or ...

speter:

--- Quote from: eldonfsr on May 22, 2022, 03:20:09 am ---Ok i understand but where check parameters on GUI on main form?
--- End quote ---

I am not sure what you mean.

* To add parameters to a short-cut:
    right-click on the short-cut file (in windows explorer) and select "properties"; you can add the parameters after the EXE name (in Target).
* To add parameters inside Lazarus IDE (for testing etc):
    select "Run > Run Parameters" then add your parameters into "Command line parameters".
* To check what parameters there are, I'd suggest using the FormCreate() procedure. Something like the code below.
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.FormCreate(Sender: TObject);var  a : byte;begin  memo1.append('paramcount = '+paramcount.tostring);  for a := 0 to paramcount do    memo1.append('param '+a.tostring+' = '+paramstr(a));end;cheers
S.

Navigation

[0] Message Index

[#] Next page

Go to full version