Recent

Author Topic: how to make application running always like windows service  (Read 3011 times)

Packs

  • Sr. Member
  • ****
  • Posts: 481
how to make application running always like windows service
« on: January 13, 2025, 11:05:06 am »
how to make application running always like windows service .

I have gui application it should always running .

Thaddy

  • Hero Member
  • *****
  • Posts: 16668
  • Kallstadt seems a good place to evict Trump to.
Re: how to make application running always like windows service
« Reply #1 on: January 13, 2025, 11:14:02 am »
A GUI application should never run as a service. Don't be silly.
What you should do is decouple the logic from the user interface, put the logic in the service and write a GUI client that interacts with the service  in user space.

Services are independent of a GUI, everybody knows that. (Well, obviously almost everybody)
« Last Edit: January 13, 2025, 11:52:12 am by Thaddy »
But I am sure they don't want the Trumps back...

PascalDragon

  • Hero Member
  • *****
  • Posts: 5909
  • Compiler Developer
Re: how to make application running always like windows service
« Reply #2 on: January 13, 2025, 09:06:33 pm »
how to make application running always like windows service .

I have gui application it should always running .

Current Windows versions don't allow services access to the UI for security reasons. Best you split your application into a GUI-less backend that you can put into a service and a UI application that will communicate with the service through IPC.

DragoRosso

  • Guest
Re: how to make application running always like windows service
« Reply #3 on: January 14, 2025, 12:19:23 am »
This link can help, how was made in the past and how is not possible anymore ...

https://learn.microsoft.com/en-us/windows/win32/services/interactive-services

Quote
Important

Services cannot directly interact with a user as of Windows Vista. Therefore, the techniques mentioned in the section titled Using an Interactive Service should not be used in new code.

EDIT: for joking, create a simple service, also empty, and at in the Start Event put this line

Code: [Select]
MessageBox(0, 'Hello', 'I am starting', MB_SERVICE_NOTIFICATION+MB_ICONINFORMATION+MB_OK);
After the service starting,  look at event viewer ... you will see the message in the log instead to a Desktop  :D
« Last Edit: January 14, 2025, 12:26:44 am by DragoRosso »

d2010

  • Full Member
  • ***
  • Posts: 121
Re: how to make application running always like windows service
« Reply #4 on: February 13, 2025, 02:11:02 am »
Services cannot directly interact with a user as of Windows Vista. Therefore, the techniques mentioned in the section titled Using an Interactive Service should not be used in new code.
EDIT: for joking, create a simple service, also empty, and at in the Start Event put this line
Code: [Select]
MessageBox(0, 'Hello', 'I am starting', MB_SERVICE_NOTIFICATION+MB_ICONINFORMATION+MB_OK);After the service starting,  look at event viewer ... you will see the message in the log instead to a Desktop  :D

How to check OutPutEvent display on screen isInsideWin7 ?, he=this function do not display
message at EventLog, expected not in screen ?
Code: [Select]
Function OutPutEvent(mssg:shortstring):integer;
Begin  mssg:=concat(mssg,#00);
         MessageBox(0,@mssg[01],'Devcinfo.exe', MB_SERVICE_NOTIFICATION+MB_ICONINFORMATION+MB_OK);
      Result:=5100;
End;
« Last Edit: February 13, 2025, 02:25:28 am by d2010 »

dsiders

  • Hero Member
  • *****
  • Posts: 1377
Re: how to make application running always like windows service
« Reply #5 on: February 13, 2025, 03:23:29 am »
Services cannot directly interact with a user as of Windows Vista. Therefore, the techniques mentioned in the section titled Using an Interactive Service should not be used in new code.
EDIT: for joking, create a simple service, also empty, and at in the Start Event put this line
Code: [Select]
MessageBox(0, 'Hello', 'I am starting', MB_SERVICE_NOTIFICATION+MB_ICONINFORMATION+MB_OK);After the service starting,  look at event viewer ... you will see the message in the log instead to a Desktop  :D

How to check OutPutEvent display on screen isInsideWin7 ?, he=this function do not display
message at EventLog, expected not in screen ?
Code: [Select]
Function OutPutEvent(mssg:shortstring):integer;
Begin  mssg:=concat(mssg,#00);
         MessageBox(0,@mssg[01],'Devcinfo.exe', MB_SERVICE_NOTIFICATION+MB_ICONINFORMATION+MB_OK);
      Result:=5100;
End;

You do seem to enjoy your .gifs. I'll give you a hint. Since there is no way to stop the animation here... no one knows what you're trying to demonstrate.
Preview the next Lazarus documentation release at: https://dsiders.gitlab.io/lazdocsnext

d2010

  • Full Member
  • ***
  • Posts: 121
Re: how to make application running always like windows service
« Reply #6 on: February 15, 2025, 06:45:37 am »
You do seem to enjoy your .gifs. I'll give you a hint. Since there is no way to stop the animation here... no one knows what you're trying to demonstrate.
 ;)
I need only the answer. How to send EvenLog isinside windows7 ?
I hope I do not spam this forum with my GIF.
Cheers.

rvk

  • Hero Member
  • *****
  • Posts: 6695
Re: how to make application running always like windows service
« Reply #7 on: February 15, 2025, 12:48:34 pm »
I need only the answer. How to send EvenLog isinside windows7 ?
You can't use the MessageBox in a normal program to write to the event log of Windows. That's just when it is in a service.

When you want to do this in a normal program you would need to use TEventLog.

Something like this:
Code: Pascal  [Select][+][-]
  1. uses eventlog;
  2. //......
  3.   with TEventLog.Create(nil) do
  4.   begin
  5.     Log(etCustom, 'Hey there');
  6.     Free;
  7.   end;

 

TinyPortal © 2005-2018