Tutorial Delphi 7 For Windows Xp Average ratng: 9,2/10 9664 reviews

Top Downloads

  • BootRacer 4.6.1.360

    BootRacer Tests How Fast is your PC! It..

  • WinSesame 10.3

    The most powerful encryption software to..

  • Money Manager Ex 0.9.9.0

    Money Manager Ex is a free, open-source,..

  • AgileTrack 0.7c 1.0

    Free download ping tools problems. AgileTrack is an agile/extreme programming (XP)..

  • Wise PC 1stAid 1.31

    An intelligent freeware to fix common PC..

Discuss: BORLAND DELPHI 7 PERSONAL 98/W2K/XP Sign in to comment. Be respectful, keep it civil and stay on topic. We delete comments that violate our policy, which we encourage you to read. The Tutorial assumes you have Delphi 7, but it should work the same in other Delphi versions. Create a service How do we create Windows Services in Delphi? Well, that's actually easy to do in Delphi. Select the menu items File, New, Other and select 'Service Application' and click OK.

New Downloads

  • EntityDAC 2.3

    EntityDAC is an ORM for Delphi with LINQ..

  • .Net DLL/WSDL Importer for Delphi 6.0.6.0

    The .Net DLL/WSDL Importer for Delphi is used..

  • PostgresDAC 3.2.1

    PostgresDAC: a PostgreSQL BDE replacement for..

  • SecureBlackbox VCL 14.0.290

    SecureBlackbox is a comprehensive component..

  • FastReport 5.2

    FastReport VCL - a new generation of reporting..

  • FastCube 2.2

    FastCube is a handy tool for efficient..

  • Visual Pascal 1.14

    Small tool for Delphi and Pascal programmers..

  • Core Temp reader for Delphi 1.1

    Core Temp is a free and easy to use program to..

  • SecureBridge Standard 6.0

    SecureBridge Standatd is a library of..

  • CAD Import VCL 8.1

    DXF DWG PLT HPGL SVG CGM import tools for..

Related Downloads

Delphi Database Tutorials, Delphi Examples And Animated Tutorials, Delphi Examples And Animated Tutorials 8 Open Sors, Coreldraw Tutorials, Ableton Tutorials, Acronis True Image Tutorials, Actionscript Tutorials For Flash, Algebra Tutorials Online, Alias Sketchbook Tutorials, Anime Drawing Tutorials

Recent Searches

1997 Audi A6 Parts Manual, Bluray Disc, Genius Color Page Hr3, Construction Equipment Guide Fort Washington Pa, Gif Edition, Download Traceelec, Hindi Font For Adobe Pagemaker, Winlock Reviews, Free Cheats Trainer For Pc Game Tombraider Legend, File Converter Media File To Midi, Sharepoint Time Reporting, Samsung Omnia Pro B7320 Conference Call, Topcon Tools V8, Ataris In This Diary Lyrics, Virus Clean Software

Latest Reviews

  • Mixcraft (ase)

    I am impressed with the software as it enables me to edit and save any recording for the presentation purpose.

  • Acronis True Image for Mac (Henry)

    Takes full backup of a Mac system which includes saved files and folder plus installed apps.

  • Lodgit Desk Hotel Software for Mac (Arnold)

    I run a small guest house in Nepal where this software is in use for last two years, we felt this is good enough for any..

  • XolidoSign (Zico)

    Allows me to insert signature on any document automatically before dispatching, other software requires manual instruction.

  • Wurlie (Tenesy)

    Make unlimited number of short urls with this script without knowing much about processes that take place in background.

  • Start Hotspot (heltvet)

    You may turn your android phone to a wifi hotspot but your data may be misused unless you have some sort of control over..

  • NCheck Bio Attendance Trial for Windows (Jeusme)

    The system is implemented in my office premises, it maintains the employees in and out time accurately, helps the accounts..

  • FirePlotter (Kacper)

    Monitors all in-coming and outgoing traffic to your PC, also shows the consumed bandwidth to calculate internet bill.

  • FolderMill (Fairyn)

    Black magic little mix download mp3. FolderMill is an automation software which looks for incoming files and send them to printer by filtering as per your..

  • DocuVieware (Sigfrid)

    Fully featured document viewer which can be added in your page to load and read almost any type files, the software can..


Delphi Tutorials 7.1

Category:Programming / Delphi Utilities
Author: Tutorials.delcode.com Software Published: Mar 08, 2008
License: Shareware O/S: Windows XP, Windows NT, Windows Me, Windows 98, Windows 2003, Windows 2000
File Number: 48814
Uninstaller: yes

Delphi Tutorials with full source code. Animated tutorials. Collection of 10 basic Delphi tutorials. Each delphi tutorial comes with full source code and animated tutorial.
Delphi Tutorials Related Tags: Beginer - Code - Custom - Database - Dbexpress - Delphi - Delphi Tutorial - Delphi Tutorials - Examples - Forms
File Size: 1.6 MB Price: $0.00 Downloads: 1074
Download Now! Homepage Buy Now! Screenshot Report Link Error Bookmark this page
Requirements:
User Rating:
Editor Rating:

More Software from Tutorials.delcode.com Software:

Delphi Database Tutorial

Reviews:

Write a review:

Related Software

Delphi Database Tutorial 7.1

Delphi Database Tutorial with full source code and animated tutorials.
Price: $29.00 Size: 1.4 MB

Collection of Delphi Examples 7

Published: Jan 25, 2008
Collection of most wanted Delphi examples with full source code and animated tutorials as a standalone application. No third party components. Pure Delphi.Examples include: Database application example, Reports, mysql,sound, and many many more.
Price: $76.00 Size: 3.6 MB

Delphi examples and animated tutorials 8

Delphi examples and animated tutorials.
Price: $48.00 Size: 6.7 MB

Del123 Collection of Delphi examples 2.9

Published: Nov 19, 2012
Del123 Collection of Delphi examples and applications - Del123.
Price: $60.00 Size: 8.7 MB

Custom Reports in Delphi Example 2.0

Learn how to make custom print preview in Delphi .
Price: $26.00 Size: 729.0 KB

OpenGL Delphi examples and tutorials 2.0

Published: Mar 25, 2013
OpenGL Delphi examples and tutorials with full Delphi source code.
Price: $0.00 Size: 751.0 KB

Crash Course Delphi 4

Step-by-step Delphi programming tutorial for beginners, in HTML-format and with GIF-images.
Price: $24.00 Size: 113.0 KB

Delphi Code Library 2.1.0.160

Published: Aug 24, 2012
Delphi Code Library is a powerful multi-language source code Library with the following benefits:1.
Price: $79.99 Size: 12.0 MB

Cbexamples Collection of C++ Builder examples 2.0

Cbexamples Collection of C++ Builder examples and applications - Database, Rave, Firemonkey, Win32 examples and more. Full source code on purchase.
Price: $55.00 Size: 7.9 MB

Code Line Counter Pro - Delphi Version 4.2

Published: Mar 17, 2012
Code Line Counter Pro - Delphi Version may be helpful for Delphi programmers, SQA, project managers and other customers who need an overview of a project source code.
Price: $49.95 Size: 2.9 MB

Delphi Tutorials also mentioned on ShareMe

1. Delphi examples and animated tutorials - Programming/Delphi Utilities
.. Delphi examples and animated tutorials. Source code and animated tutorials. Working with ADO components, rave reports, OpenGL. More than 100 Delphi examples in 3 main categories. Ideal for both beginners and advanced professionals. Delphi code examples for everyone. ..
2. Delphi Database Tutorial - Programming/Delphi Utilities
.. Delphi Database Tutorial with full source code and animated tutorials. Set of ten Delphi database tutorials ranging from a simple to a more complex ones. Tutorials based on Access database file. ..
3. OpenGL Delphi examples and tutorials - Programming/Delphi Utilities
.. OpenGL Delphi examples and tutorials with full Delphi source code. Learn openGL through Delphi examples. Examples include both 2d and 3d OpenGL tutorials in Delphi. ..
4. Collection of Delphi Examples - Programming/Source Code
.. Collection of most wanted Delphi examples with full source code and animated tutorials as a standalone application. Best examples in one file.Everything you need to know to start making your own applications in no time. Examples include: Database application example, Custom reports, animating windows, dealing with sound, mysql server and more.. ..
5. Del123 Collection of Delphi examples - Programming/Delphi Utilities
.. Del123 Collection of Delphi examples and applications - Database, Rave, Firemonkey, Win32, OpenGL, Indy examples. Full Delphi source code and project files. From Delphi 7 to Delphi XE2 - Del123.com ..

Tutorial for making a Service Application using Delphi
by
Finn Tolderlund

http://www.tolderlund.eu/delphi/service/service.htm
Last updated 03-10-2012.
This tutorial is not finished, it is a work in progress.
Warning: Use of any files and information from this tutorial is at your own risk.
In this tutorial the following topics will be covered:
Create a service
Install and Uninstall the service application
Make the service do something
Debugging the service application
Using the TService.LogMessage method
Sample code for a service application
Links
FAQ
The Tutorial assumes you have Delphi 7, but it should work the same in other Delphi versions.
Create a service
How do we create Windows Services in Delphi?
Well, that's actually easy to do in Delphi. Select the menu items File, New, Other and select 'Service Application' and click OK.
Note that if you have the Standard edition of Delphi 'Service Application' may not be available. You need at least the Professional edition.
You now have the framework for a service application which includes a TService class.
The TService class is where we do our stuff and it has a number of properties which you can see in the Object Inspector.
Among the properties you will see a Name, DisplayName, ServiceStartName and Password property.
Name property:
Enter a good descriptive name for your service in the Name property.
Do not just leave the name as Service1, but choose a more descriptive name such as 'CompanynameSqlDatabaseSpecialSomething' (no blanks in the name).
Why is this Name property so important?
It's important to choose a good name, because when installing the service this name is automatically used to create a key in the registry under HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServices.
So be sure to use a name which will not be used by other services, otherwise you might end up with a nasty registry key name conflict with other services.
Also we will later use the Name property ourself to create a key in the registry under HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesEventlogApplication.
More about this key later.
DisplayName property:
Enter a user friendly and descriptive name such as 'Companyname SQL Database Special Something' (feel free to use spaces in the name).
The DisplayName is used for displaying when you use the Control Panel, Administration, Services applet.
ServiceStartName property:
You can specify an account name in this property and password in the Password property to specify which account the service should log on as.
That requires that you know at design time the account name and password, and who knows that?
Just leave ServiceStartName and Password empty. You can always enter an account name and password in the service properties after the service has been installed.
A service runs as a specific user and that means that a service has the same access permissions to different things such as folders as the account under which the service runs. Many services runs as 'Local System' unless you specify a specific username when installing the service. For many things 'Local System' is sufficient, however if the service needs to have access to things such as a folder on a network drive/share (which are normally user/password protected) you may need to specify an account which has been granted access to the network share.
I'll assume that you have created the service framework as shown above. We haven't written a single line of code ourself yet, that will come shortly.
Let's first install the service and see if it can run.
First save the project (File, Save All) in a folder on your local harddrive. Windows won't run a service application if it's located on a network drive.
For this tutorial save the unit as MyServiceUnit.pas and the project as MyService.dpr. Compile or Build the project.
Install and Uninstall the service application
Note that you need administrator rights to install and uninstall service applications, because it is necessary to write or delete registry entries in HKEY_LOCAL_MACHINE, and that requires permissions that normal or restricted users do not have.
To install the service application you open a command prompt and type:
MyService.exe /install
You will see a confirmation dialog when the service has been successfully installed or an error message if it failed. It can fail if you do not have sufficient rights.
If you do not want to see the confirmation dialog you can add the /silent switch like this:


To uninstall the service application you open a command prompt and type:
You will see a confirmation dialog when the service has been successfully uninstalled or an error message if it failed. It can fail if you do not have sufficient rights.
If you do not want to see the confirmation dialog you can add the /silent switch like this:
So type 'MyService.exe /install' in the command prompt now and klick OK to the confirmation dialog.
Open the Control Panel, go into Administration and into the Services applet. You will see a list of currently installed services. Locate your service name in the list, right click on it and select 'Start' menuitem in the popup menu. Notice that the Status for the service changes to Started. You can press the F5 key or select the Refresh command to update the list to make sure that the service keeps running.
You can also see your service in the Task Manager. Right click on an open area of your task bar at the bottom of your screen, then select 'Task Manager', select the Processes tab. Here you can see a list of currently running processes. See if you can find your services. It's listed as Myservice.exe. Close the Task Manager.
So now we have a service application running. Great eh? Well, it's running but it doesn't really do anything because we haven't put in any code to make it do anything useful. Let's do that now. In the Services applet right click on the service name and select the Stop command.
It's necessary to stop the service because we can't compile and update the exe-file when it's running.
We could also uninstall the service, but it's not necessary to uninstall the service while we change it, as long as we don't change the Name and DisplayName properties. If you need to change these properties you should uninstall the service first.
For now just stop the service. When we have put in some code we only have to start the service again to run it.
When you look at your service in the Services applet do you notice that the Description column is empty?
Unfortunately Delphi do not have a property in the TService class to set the description.
We have to set the description ourself after the Service Application has been installed.
Fortunately this is easy enough to do using the TRegistry class in the TService AfterInstall event.
The description is stored in the registry in the datavalue Description under the key
[HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesYourServiceName]
Try take a look there with the regedit application.
You set the Description datavalue like this:
Remember to add Registry to the uses clause.
Compile the service application.
Uninstall the service application and install it again and see that you now have a description in the Services applet.
Note that you do not need to delete the description when you uninstall the service application.
This is because everything under the key [HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesYourServiceName] is automatically deleted, including the description.
Make the service do something
There are basically two places where you can put your service code:
In the OnExecute method or the OnStart event.
OnExecute method:
Put your code in the TService.OnExecute method. Here you can also create a thread with your code if you want.
Quote from the help under OnExecute:
'Occurs when the thread associated with the service starts up.'
'If you are not spawning a new thread to handle individual service requests in an OnStart event handler, this is where you implement the service. When the OnExecute event handler finishes, the service thread terminates. Most OnExecute event handlers contain a loop that calls the service thread’s ProcessRequests method so that other service requests are not locked out.'
OnStart event:
Create a thread (TThread) that contains your code and start the thread in the TService.OnStart event.
Quote from the help under OnStart:
'OnStartup occurs when the service first starts up, before the OnExecute event.'
'This event should be used to initialize the service. For example, if each service request is handled in a separate thread (a good idea if handling the request takes much time) the thread for a request is spawned in an OnStart event handler.'
Which method you use is a personal matter, both work fine.
Below is an example of both methods.
Using OnExecute method
We loop around in the while-do loop until the service should be terminated, either when the machine is shutting down or the service is stopped from the service applet.
In this example the procedure 'SomeProcedureInAnotherUnit' is called every 10 seconds.
Note that we do not use Sleep(10000) in order to wait 10 seconds.
If we did that our service would not be able to responds quickly to commands sent from the SCM (Service Control Manager).
Instead we sleep only for 1 second at a time and use a counter to count how many seconds how gone since the last call to SomeProcedureInAnotherUnit.
You can use the OnStart event if you want to perform some initialization here instead of doing it in the OnExecute event and that allows you to set the Started variable to False if you find that some needed settings is missing and don't want the service to start.
Using the OnExecute method this way has it's advantages and drawbacks.
Advantage:
The code is simple. You do not need to create a secondary thread.
Pausing and resuming the service is handled automatically without extra code.
Drawbacks:
The SomeProcedureInAnotherUnit must take only a very short time to finish, it should take no more than a few seconds at the most.Delphi
The OnExecute method works well if the code takes only short time to finish on each run.
If the code takes a long time to run, you should consider starting a secondary thread in the OnStart event instead.
Using OnStart event
First you need to define your secondary thread class where you put all your code to do what ever it is you want your service to do.
Create the thread as you usually make thread classes. One way is to select the menu item File, New, Other, 'Thread Object'.
If you do not have any experience with threads you need to get a working knowledge about threads before you continue with the service application.
Tutorials on thread programming in Delphi:
Original, now removed:
http://www.pergolesi.demon.co.uk/prog/threads/ToC.html
Can now be found here:
http://www.eonclash.com/Tutorials/Multithreading/MartinHarvey1.1/ToC.html
http://www.sklobovsky.com/community/index.html
http://sklobovsky.nstemp.com/community/threadmare/threadmare.htm
http://sklobovsky.nstemp.com/community/threadmare/perks.htm
http://sklobovsky.nstemp.com/community/threadmare/fixes.htm
How to handle exceptions in TThread objects - by Borland Developer Support Staff:
http://community.borland.com/article/0,1410,10452,00.html
Let's say you have made a TThread called TMyServiceThread.
This thread should be made so that it will automatically free itself when the thread's Execute method terminates.
(This is actually wrong, but right now just do it. I'll correct it further down in this tutorial.)
For now, just set the thread's FreeOnTerminate property to True.
Define a thread variable in your TService's private section like this:
Now you need to create and fill in the OnStart and OnStop events like this:
What happens here is that the secondary thread is created and started in the service's OnStart event.
Then the thread goes on running until the thread is notified that it should stop. This is done in the service's OnStop event by calling the thread's Terminate method.
Note that calling the Terminate method does not stop the thread. All it does is to set the thread's Terminated property to true and it is then up to the thread to check this property at short intervals to see if the thread should stop. The thread then stops simply by exiting the thread's Execute method.
An very simple example of a thread that does this can be seen here:
Using the OnStart method to start a secondary thread has it's advantages and drawbacks.
Advantage:
The code is a little more complicated and you need knowledge about threads.
You can make the Execute method simpler by removing the Count variable and all the code that uses the Count variable and simply call Sleep with a larger value. Just don't make the Sleep value too large.
The SomeProcedureInAnotherUnit can take longer time to finish on each run and we can sleep for longer intervals.
But note that we should still check the Terminated property at regularly intervals so that the thread and service can shut down within reasonable time when Windows is shutting down or when asked to shut down by the SCM.
Drawbacks:
Pausing and resuming the service is not handled automatically. You need to define the OnPause and OnContinue events and add code to notify your thread when to pause and continue.
Note that although you could simply call the thread's Pause and Resume method this could potentially be a very bad idea.
If the thread has opened files or an active database connection or active network connection these resources would be hanging as long as the thread is paused. Instead you should set a property in your thread to signal that the thread should stop working and only loop around and call Sleep until it gets told to either continue or shut down.
The easy way to handle service Pause and Continue in this setup is to disable these options by setting the service's AllowPause property to False.
The OnStart method works well if the code takes longer time to finish on each run.
Caveats:
There are several issues we need to be aware of.
First I have a confession to make.
I told you above that you should set the thread's FreeOnTerminate property to True in order to make it free itself when the service application is shutting down. This is dead wrong.
Actually, letting the thread terminate itself in a service application is a recipe for disaster.
You have to make sure that the thread is terminated from within the TService class before you exit the TService. This is necessary because if you let the TService exit and shut down before the thread is terminated then the thread is simply killed in the middle of whatever it was doing. This of course is bad.
So you have to set the thread's FreeOnTerminate property to False and wait in the TService until the thread has finished. You do this by using the thread's WaitFor method.
Another pitfall:
When the service is stopped manually the OnStop event is called (OnShutdown is not called).
When the system shuts down the OnShutdown event is called (OnStop is not called).
So in order to properly clean up you have to implement both OnStop and OnShutdown. It's probably best just to call a common procedure to do the cleaning up.
We can do it like this:
And like this:
  • Create a subkey with the same name as your service (for example, MYSERV.EXE). To this subkey, add a value of type REG_SZ, named Debugger. Use the full path to the debugger as the string value.
  • In the Services control panel applet, select your service, click Startup and check Allow Service to Interact with Desktop.

    According to this: http://groups.google.dk/group/borland.public.delphi.nativeapi.win32/msg/13df743b00f57603?dmode=source&hl=da Go to http://www.wilsonc.demon.co.uk/delphi.htm and download 'NT Low Level Utilities' and use TDebugServiceApplication in unitDebugService.pas. Apparently Colin Wilson uses it for debugging only.
    Using the TService.LogMessage method
    If something happens during the execution of your service which you want to log, you can use the LogMessage method to save a message which later can be viewed using Windows built in event viewer.
    You simply call the LogMessage method like this:
    Use the message type as you think appropriate.
    When you look in the event viewer the message may then look something like this:
    As you can see there is a lot of nonsense text in front of the message we specified in LogMessage.
    You could simply ignore all that and be done with it, right?
    No?
    Well, if we want to remove the garbage text and only have our message shown, we need to do some extra coding.
    My personal opinion: This is where Microsoft managed to screw up and make something really complicated which could have been very simple.
    As it is we have to live with it.
    Now, before we go on, make sure that you have a message compiler installed on your machine.
    And what exactly is a message compiler?
    It's like a resource compiler, except a message compiler is used to compile message resource files.
    You can get a message compiler if you install Visual Studio from Microsoft, for example Microsoft Visual Studio .NET 2003.
    Then in the 'C:Program FilesMicrosoft Visual Studio .NET 2003Common7ToolsBin' directory there is a mc.exe which is the message compiler.
    If you don't have Visual Studio you could take a look at the free Visual Studio 2005 Express Editions
    http://msdn.microsoft.com/vstudio/express/
    Note that I don't know if the message compiler is included in the free versions.
    Someone wrote to me: You'll find it in the free Microsoft Platform SDK for Windows Server 2003 as well:
    Microsoft Platform SDK for Windows Server 2003 R2BinMC.Exe
    (no need to install the SDK, just copy the .exe)
    Now we need to make a message resource file and compile it and include it in the service application project.
    Make a text file containing these lines:
    You must write the lines exactly as shown here, otherwise you will get an error when you compile it. The message compiler is very picky.
    You can of course change the lines if you know what you are doing, but since you are reading this I assume you don't :-)
    Save these lines in a text file in the same directory as the service application and give it a name such as 'MyServiceMessageResource.mc'.
    In a command prompt issue the command (also type the ' characters)
    VS71COMNTOOLS is an environment variable created when Visual Studio is installed. It points to the 'C:Program FilesMicrosoft Visual Studio .NET 2003Common7Tools' directory.
    If the message compiler gives an error you need to correct the message resource file and compile it again.
    The message compiler generates these files:
    One binary resource file per supported language (msg00001.bin, msg00002.bin, and so on),
    and a resource file (.rc) that contains the appropriate statements to include each .bin file as a resource.
    Now we have a file called 'MyServiceMessageResource.rc' which must be compiled using the resource compiler.
    You can use the resource compiler installed with Visual Studio or the resource compiler installed with Delphi.
    For the Visual Studio resource compiler issue the command
    For the Delphi resource compiler issue the command
    Now we have a MyServiceMessageResource.res file which we can include in the project with the line
    If you don't have message compiler handy or just want the easy way, here is a zip file with ready made resource files:
    resfiles.zip (1 KB).
    (The only file you need is the one named 'MyServiceMessageResource.res')
    I did say it was complicated, right?
    But we are not done yet.
    In the ServiceAfterInstall method add these lines:
    In the ServiceAfterUninstall method add these lines:
    Now when we use the LogMessage method the event viewer will only show our message, without all the other junk.
    As I said Microsoft has managed to make it very complicated.
    Sample code for a service application
    DO NOT ask me for any sample code or demos.
    I do not yet have any sample code.
    When I write a sample code, it will be posted here.
    Links to other articles:
    Old dead link: http://info.borland.com/techpubs/delphi/delphi5/dg/buildap.html
    You can now find the page on the Internet Archive Wayback Machine:
    http://web.archive.org/web/20070629132322/http://info.borland.com/techpubs/delphi/delphi5/dg/buildap.html
    Or see my local copy of the page here: buildap.htm
    FAQ:
    Q:
    I've written a service app, and after I install it, when I try to start it in the Services console, it immediately shuts down saying that it has no work to do.
    Do you happen to know what causes this or how I can deal with it? I've looked all over for a solution, but information on service applications in Delphi is difficult to come by.
    A:
    That could be caused by an unhandled exception in the startup code.
    Check if you have an exception somewhere in your code.
    You MUST handle all exceptions in a service application.
    Send me an e-mail if you have any comments, questions, suggestions for improvements, or if you find errors in this tutorial.
    My Delphi page: http://www.tolderlund.eu/delphi/