Posts

MS Word Automation in Delphi

Techniques to control MS-Word from a Delphi application are discussed in this blog. As a demonstration, I have added different codes which allows to use Word to create tables, to format strings, to create paragraphs and to insert different objects like images, shapes, word arts etc. Finding a PC that does not have MS-Word installed may prove a difficult task: The word processor from Microsoft is ubiquitous. It therefore makes sense to use it whenever it is necessary to create beautiful output from a program. Delphi makes it actually very easy: The language support for Variants as references to OLE automation servers and the support for COM interfaces make steering MS-Word (or indeed Excel or MS-Access) quite easy. Controlling MS-Word is done through its COM interface: Through Delphi’s OLE mechanism, an OLE reference is obtained to the MS-Word application, and then the various commands exposed by the MS-Word interface can be used to let MS-Word do virtually anything that is neede...

FASTMM and how to use in a Delphi Project.

Image
One of the most challenging parts of inheriting a legacy project is to fix the memory leaks that most often are hiding in the code. A while ago, while dealing with an application that managed to eat all the available memory within a few hours I found FastMM and it was sure a great find. What is FastMM? FastMM is a memory manager replacement designed to be used with Delphi. It is an Open Source project developed by Pierre Le Riche in South Africa. Starting with Delphi 2006 FastMM replaced the Borland memory manager. Unfortunately, Delphi only ships with a subset of FastMM. Most of the useful debugging reporting that can be done with FastMM has been stripped from the shipping version of Delphi, RAD Studio and BDS. But fear not! It is very simple to replace the stripped-down version of FastMM with the full version. All you have to do is follow the directions outlined below. I have also included a step to install the FastMM4 Options Interface program. That program is a very frie...

Memory Leak in Delphi and How to avoid it

Image
What is Memory Leak Every time when we no longer use an object in our code, we should delete it, by freeing the memory it was allocated. If we don't do this, our program can allocate more and more memory as it runs. This will also fail to remove unwanted blocks of memory is called a memory leak. And if we run the program long enough without solving memory leak issue then our program will use up the memory resources of our PC and the PC will slow down and eventually hang at last. What are the problems faced by memory leaks? - Memory leak slows down the system and doesn’t let the normal applications to run too. - Memory leak causes more problems for the overall speed and generate lots of error message like Stack overflow, etc. - Memory leak also doesn’t allow other applications on the system to run due to the memory overflow error. - It can be detected and application can be made such that while its termination it releases the memory as well. - It doesn’t run for a v...