Posts

Showing posts from June, 2014

Windows Service Application in Delphi

Image
What is Windows Service? Windows service is an application that runs on background. It is usually used to check system updates continuously, to work on system resources. Service applications take requests from client applications, process those requests, and return information to the client applications. They typically run in the background, without much user input. Why do we need it? Suppose we have system that needs to respond 24/7 days or if we have software that needs to update frequently, then we can create service which will check the new updates and download it. Then update to new software. In such situations we can use Window Services. What are the limits? We cannot use any visual components in service applications. You can add just any nonvisual component to the new service. But you’re restricted to nonvisual components; you'll get an exception Controls Cannot Be Added To A Service message if you try to drop a visual component How to create Windows Serv...

Procedural Type & Method Pointer in Delphi

Procedural Type : Procedural type is one of user defined data type that allows you to consider procedures and functions as values that can be assigned to variables or passed to other procedures and functions. It is mostly used when we call DLL methods in Dynamic call, to declare custom Events for components. The following example demonstrates usage of a procedural type. Suppose you define a function called Calc that takes two integer parameters and returns an integer: function Calc(X,Y: Integer): Integer; You can assign the Calc function to a variable F if we declare F as function type. var     F: function(X,Y: Integer): Integer; .....    F := Calc; How to declare? : If you take any procedure or function heading and remove the identifier after the word procedure or function, then what is left is the right part of a procedural type declaration. You can use such type names directly in variable declarations (as in the previous exa...

ParamStr - Run Delphi Application with Command line paramaters

Image
ParamStr(ParamIndex : integer) The  ParamStr  function returns one of the parameters from the  command   line  used to invoke the current program. The ParamIndex parameter determines which parameter is returned: 0  : The execution drive/path/program name. Returns same as Application.ExeName. 1  : Return the 1st parameter 2 : Return the 2nd parameter ... If there is no parameter value for the given index,an empty string is returned. // Before running this code, use the Run/parameters menu option // to set the following  command   line  parameters : -parm1 -parm2 ParamCount() The ParamCount function gives the number of  command   line  parameters used to invoke the current executable. While application is running, the parameters are available to us. so we can retrieve them within a specific section of the application (usually from the OnActivate event handler of the main form). We ca...

Why I use Delphi?

Why I use Delphi? As I am a Delphi developer from last 5 years. I worked on several Delphi projects in several companies in India. In my last company we recruited a fresher to work with our team in Delphi. His first question was What is Delphi and Why I use it?. Even his friends suggested to leave Delphi as there is no future opportunity. And one day he said he wants to leave Delphi. I asked him what is the reason you want to leave. He answered because its outdated language. I got shocked if Delphi is outdated then what about C / C++. But C / C++ are still most power full language. And Delphi uses Object Pascal that is object oriented version of Pascal language which support all the OOPS behavior and new features.  And C, Pascal are most powerful languages still today. So I explained him some reason why I use and love Delphi. So following are some reasons why we use Delphi... Speed   Delphi is not an interpreted language. It compiles Delphi code and generates machi...