Recent

Author Topic: [Windows 11] Use TProcess directly or not?  (Read 2346 times)

djongepier

  • Newbie
  • Posts: 6
[Windows 11] Use TProcess directly or not?
« on: February 14, 2024, 10:32:09 am »
Hi All,

I'm really new to Lazarus/Free Pascal, although I had my first encouter with Turbo Pascal some 20 years ago.
Last year I have learned to use Python and I found that I wanted to learn a more systems-programming kind of language that is not as taxing to learn as for instance Rust or C++.

I ended up on Lazarus/FreePascal and that seems to fit just fine for what I want to do.

My current quest is to find a way to control some processes on a Windows machine, Windows 11 to be precise. And what I found is some contradictions in advise on how to go about doing that.

Question: Do I use TProcess or a wrapper? Some are deprecated (compiler message)

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12119
  • FPC developer.
Re: [Windows 11] Use TProcess directly or not?
« Reply #1 on: February 14, 2024, 10:49:50 am »
Currently I lean to do both, write an own wrapper for a specific purpose.

E.g. to run a program with a timeout:
https://forum.lazarus.freepascal.org/index.php/topic,50525.msg368880.html#msg368880

The deprecated functions won't be removed soon, the deprecation is only there to signal that we don't accept quoting related bugreports for it.

djongepier

  • Newbie
  • Posts: 6
Re: [Windows 11] Use TProcess directly or not?
« Reply #2 on: February 14, 2024, 11:05:16 am »
Hi Marcov,

Thanks for the reply, I will then proceed on the path of building on the TProcess class.
For my needs the process (multiple ones) need to run at the same time, so plenty of research and testing to do.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12119
  • FPC developer.
Re: [Windows 11] Use TProcess directly or not?
« Reply #3 on: February 14, 2024, 11:07:50 am »
If you develop certain interesting examples (just like I did with output to memo or timeout or remote control program), please package them and put them online.

Maybe we can collect the examples in some gitlab repo or so.

djongepier

  • Newbie
  • Posts: 6
Re: [Windows 11] Use TProcess directly or not?
« Reply #4 on: February 14, 2024, 11:14:34 am »
If whatever I develop actually works, I will try to package it in a Unit.

Bear in mind the complete novice I am, it could take a while  :D

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Re: [Windows 11] Use TProcess directly or not?
« Reply #5 on: February 14, 2024, 02:08:12 pm »
On Windows its all about Handle, process ID and messages  O:-)
Please write a little what you mean by saying "control process" since there is just one generic method called "terminate" and one generic feature "show window" that could be of use without coding much.
If you want to IPC, there you have plenty of choices about how program A) could control program B), but both must then be written by your own to implement the IPC logic.

As you might noticed, I am more interested to find out more about the "control process" part  :D
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12119
  • FPC developer.
Re: [Windows 11] Use TProcess directly or not?
« Reply #6 on: February 14, 2024, 02:38:02 pm »
Just a demo of a lazarus program running a FPC console program.

So just standard input linking, not GUI application instrumentation

 

TinyPortal © 2005-2018