| RTL reference|Glossary|Tips/Tricks|FREE App/VCL|Best'O'Net|Books|Link To |
| Windows Shell Extensions Info Tip | |||||||||||||||||||||||
| Page 3: Delphi project: Infotip; Registering Infotip Extensions | |||||||||||||||||||||||
Delphi project: Infotip To begin, we need to create an automation object called DPRInfoTip. First, click File | New... to open the Object Repository, then click on the ActiveX tab and select the ActiveX Library. This will generate an empty ActiveX library and export the necessary function required to be a valid automation object.
Next, click File | New... again and select the ActiveX tab and select the Automation Object. When the Automation Object Wizard opens, enter DPRInfoTip as the CoClass name (see Figure 2 below for an example of how the dialog should look). Leave the remaining options with their default values and click OK, this will generate the basic Type Library and implement a skeleton for the IDPRInfoTip interface, which gets automatically generated.
Once the files have been created the next thing we need to do is to add support for the additional interfaces that must be supported:
TDPRInfoTip = class(TAutoObject, IDPRInfoTip, IQueryInfo, IPersistFile, IPersist);
Note: We need to implement IPersist also because IPersistFile inherits from IPersist.
The accompanying source code can be used for all InfoTip Extensions, the only code that must be altered is the GenerateTip method. This is the method that determines the text to display in the InfoTip.
In the Initialization method, we call SHGetMalloc, which causes Windows to allocate some memory and return a pointer to it in the pMalloc private variable. In the destructor, we set pMalloc equal to Nil. This releases our hold on the memory so the Windows shell can release the memory when necessary.
IPersistFile::Load For all remaining IPersistFile methods, simply return E_NOTIMPL.
IQueryInfo::GetInfoTip The GenerateTip method opens the .DPR file and reads contents into a string. The text to be returned first is assigned the filename of the selected file, then the type is assigned the first word in the project file; which is either Program or Library. Finally the project name is extracted from the remainder of the first line and the size of the file in bytes is determined by the size of the stream. The GenerateTip method can be customized to fit the needs of the InfoTip Extension being developed.
Registering Infotip Extensions 1. Register the COM DLL using regsvr32.exe (Start..Run dialog box)
regsvr32 "C:\...\DPRInfoTip.dll"
2. Add a reference to the associated extension (.dpr) to the HKEY_CLASSES_ROOT registry key.
The default value for this new key must be the CLSID of the COM object that implements the Shell Extension. This can be obtained from the Type Library file that was generated by Delphi (the filename ends in "_TLB.pas"). For our example extension the CLSID is named CLASS_DPRInfoTip and contains the value "{B20433A8-D083-11D4-993A-00D00912C440}".
The easiest way to make the registry changes is to make a copy of the .REG file provided with the source code for this project. Change the CLSID and file extension to the associated values.
One important note, it is necessary to "approve" shell extensions under Windows NT and 2000. This means that you must be logged into the machine with Administrator rights in order to register the extension.
That's all folks First page > Shell extensions allow developers to add functionality to the existing Windows shell > Page 1, 2, 3
|
|||||||||||||||||||||||
All graphics (if any) in this feature created by Zarko Gajic.
| More Delphi |
|
· Learn another routine every day - RTL Quick Reference. · Download free source code applications and components. · Talk about Delphi Programming, real time. · Link to the Delphi Programming site from your Web pages. · Tutorials, articles, tech. tips by date: 2001|2000|1999|1998 or by TOPIC. |
|
· NEXT ARTICLE:
New...Access Database from Delphi - DB/13. Chapter thirteen of the free Delphi Database Course for beginners. How to create an MS Access database without the MS Access. How to add an index to an existing table, how to join two tables and set up referential integrity. No MS Access, only Pure Delphi code. |
| Stay informed with all new and interesting things about Delphi (for free). |
|
|
| Got some code to share? Got a question? Need some help? |
