|
|
ProgramThe Extension Discoverer program displays the icon and file-type for the file extension entered by the user.
This program uses the following ActiveX controls:
This project contains one Form, frmExtDisc:
This form contains three textboxes - Ext, FType and FIcon. FType and FIcon have their Locked property set to True and the BackColor property set to 'ButtonFace'. There are three labels to the left of the TextBoxes and one Image control called IconPreview. The project also contains a module called 'REG_MODULE' to allow the program to read from the registry. This is necessary so that the program can lookup the icon filename and reference for the extension entered. 'REG_MODULE' (VBReg.bas) was written by Roger Wynn. frmExtDiscfrmExtDisc contains the following code:
The GetRegString function reads a string from the specified location in the registry via the 'REG_MODULE' module. FileTyp is used to find out the file type of the specified file. When the user presses a key whilst the focus is on Ext TextBox, the Ext_KeyDown procedure is called. The procedure tests to check whether the enter key was pressed. If so, a file is created in the user's temp folder called Extdisc.<ext>, where <ext> is replaced with the extension entered in the Ext TextBox. The FType TextBox is populated with the file type via the FileTyp function. The 'HKEY_CLASSES_ROOT\.<ext>' part of the registry is read to get some information about the file type. This information is used to read another part to get the filename of the icon. This string is put into the FIcon TextBox. An error message is displayed is the user enters illegal characters in the extension (\ / : * ? " & Chr(34) & " < > |) or if the extension is too long. Martin Allen 1999 - 2010. Last updated Monday 28 June 2010 10:35:08 PM +0100. |