Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delphi Service Example 1

Status
Not open for further replies.

ResonantEcho

Programmer
Aug 17, 2010
24
US
thread102-791024

In regard to the above thread. May I get you to provide the values for the following constants you use in your code example?

STR_REGKEY_SVC
STR_REGVAL_IMAGEPATH
STR_REGVAL_DESCRIPTION
STR_INFO_SVC_DESC
STR_REGKEY_EVENTMSG
STR_REGVAL_EVENTMESSAGEFILE
STR_REGVAL_TYPESSUPPORTED
STR_REGKEY_FULL
STR_REGVAL_INSTALLDIR
 

Code:
 STR_VERSION_MAIN                = '1.0';
 STR_NAME_COMPANY                = 'YourCompany';
 STR_NAME_APPLICATION_SHORT      = 'YourApplicationName';
 STR_NAME_APPLICATION            = STR_NAME_COMPANY+' '+STR_NAME_APPLICATION_SHORT;
 STR_NAME_SVC                    = 'Svc_YourService';

 // service main registry keys
 STR_REGKEY_SOFTWARE             = '\Software';
 STR_REGKEY_COMPANY              = '\'+STR_NAME_COMPANY;
 STR_REGKEY_APPLICATION          = '\'+STR_NAME_APPLICATION_SHORT;
 STR_REGKEY_FULL                 = STR_REGKEY_SOFTWARE+STR_REGKEY_COMPANY+STR_REGKEY_APPLICATION+'\'+STR_VERSION_MAIN;
 STR_REGKEY_EVENTMSG             = '\SYSTEM\CurrentControlSet\Services\EventLog\Application\'+STR_NAME_APPLICATION;
 STR_REGKEY_SVC                  = '\SYSTEM\CurrentControlSet\Services\'+STR_NAME_SVC;

 STR_REGVAL_INSTALLDIR           = 'InstallDir';
 STR_REGVAL_IMAGEPATH            = 'ImagePath';
 STR_REGVAL_DEPENDONSERVICE      = 'DependOnService';
 STR_REGVAL_DESCRIPTION          = 'Description';
 STR_REGVAL_EVENTMESSAGEFILE     = 'EventMessageFile';
 STR_REGVAL_TYPESSUPPORTED       = 'TypesSupported';

 STR_INFO_SVC_DESC               = STR_NAME_APPLICATION+' '+STR_VERSION_MAIN;
 STR_INFO_SVC_REGFAIL            = 'Registry is not initialized for service';
 STR_INFO_SVC_START              = 'Starting service...';
 STR_INFO_SVC_STARTED            = 'Service has been started';
 STR_INFO_SVC_STARTFAIL          = 'Service failed to start : "%s"';
 STR_INFO_SVC_STOP               = 'Stopping service...';
 STR_INFO_SVC_STOPPED            = 'Service has been stopped';
 STR_INFO_SVC_STOPPEDWITHERROR   = 'Service stopped due to main thread error, please check debug log';
 STR_INFO_SVC_STOPFAIL           = 'Service failed to stop : "%s"';

 STR_INFO_SVC_NOCONFIG           = 'Unable to load service configuration file';

I hope this is enough :)

-----------------------------------------------------
Helping people is my job...
 
Okay. Would you happen to have the source code for these units as well? :D I'm converting an old Delphi 7 service to use a thread and have seen these units referenced on Stack Overflow, etc. However, source never provided.

[ul]
[li]u_eventlog[/li]
[li]u_MyThread[/li]
[/ul]

ResonantEcho
 
BTW, is it necessary to use the "u_eventlog" unit? Why not use TEventLogger instead?


// ResonantEcho
 
BTW, is it necessary to use the "u_eventlog" unit? Why not use TEventLogger instead?

You do realize the original thread you referenced was 12 years ago when Delphi 7 was the most current Win32 option? Perhaps TEventLogger didn't exist then?

As for source: u_eventlog . Didn't find reference to the other.

 
Yes, code is a bit dated but still usable.
Nothing stops you from using TEventlogger :)

/Daddy

-----------------------------------------------------
Helping people is my job...
 
You do realize the original thread you referenced was 12 years ago when Delphi 7 was the most current Win32 option? Perhaps TEventLogger didn't exist then?

As for source: u_eventlog . Didn't find reference to the other.

Hi Glenn,

Believe it or not I'm having to use Delphi 7 and TEventLogger does exist. [bigsmile] It's what Xerox currently has available. Hoping they upgrade to Delphi 10 here soon considering I'm having to update up to 160 applications written in Delphi.

I did eventually find the "u_eventlog", but not the other.

Take care.


// ResonantEcho
 
Yes, code is a bit dated but still usable.
Nothing stops you from using TEventlogger :)

Going to give it a try. Thanks! ;)


// ResonantEcho
 
Nothing wrong with Delphi 7, it's probably the best option out there right now for Delphi given it's probably the most stable, least bloated platform that offers most all of the essentials you'd need. About the only thing that gets added is newer/different widgets/API calls - the API calls are pretty reproducible and the widgets only add value if they're valuable to you/the company. Of course, that's just one opinion out of many.

As far as the 160 applications, if they're all service-oriented, it might be useful to try to distill some things into some generic classes if you can. A lot of coding tends to involve a whole lot of disorganization and repeated inventing of wheels (for reasons both logical and unjustified) - I know I've been shocked at how abhorrent a lot of the code I've seen has been in my "professional" experiences simply for the lack of even a small amount of planning. Of course, the "logical" part is always pretty hard to solve, and I'd like to find a good solution to that just for my own stuff, much less code on the scope of a company.

How things are, I suppose...

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top