NetTalk Central

Author Topic: Desktop app or Service  (Read 2912 times)

rupertvz

  • Sr. Member
  • ****
  • Posts: 326
    • View Profile
    • Email
Desktop app or Service
« on: June 12, 2024, 08:10:54 AM »
Hi Guys,

Is there an easy way to determine at runtime whether a NT app is running as a desktop instance, or a Windows Service?

Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: Desktop app or Service
« Reply #1 on: June 12, 2024, 09:04:20 AM »
May be...

How to Know If the Exe is Running as a Service
The easiest way to know if your app is running as a service is to test System{'ss:AmService'}. This is set to true when the program is in service mode. For example;

If System{'ss:AmService'} = true
  ! in service mode
End

This approach only works if you are using Clarion 10.11975 or later.
The advantage of this approach is that the code is system-global, meaning it'll work in pre-compiled DLL's, classes with no access to global data and so on.

If you are using an older build of Clarion then we recommend either (a) upgrading, or following one of the steps described in Destroy Controls above.
-----------
Regards
Alberto

Jane

  • Sr. Member
  • ****
  • Posts: 372
  • Expert on nothing with opinions on everything.
    • View Profile
    • Email
Re: Desktop app or Service
« Reply #2 on: June 12, 2024, 11:06:13 AM »
If you're using SelfService, query the AmService property.

https://www.capesoft.com/docs/SelfService/selfservice.htm#ObjectProperties

rupertvz

  • Sr. Member
  • ****
  • Posts: 326
    • View Profile
    • Email
Re: Desktop app or Service
« Reply #3 on: June 14, 2024, 01:25:37 AM »
Thank you Jane, Alberto ;-)