Code
Snippets
These are snippets of code that might be of
use to other programmers. Primarily they're in C++ but there will
also be Delphi code available too - when time permits.
C++ code snippets
-
CD
drawer controller in C++ - this is rather useful if (as I
have) you wish to produce a business card CD.
-
Icon
registration and auto-open - this is two rather useful
chunks of code designed to asssociate your program with the icon
and file extension of your choice. Here my own file extensions
(swr and rus) are used.
-
Executing
html helpfiles - this code will allow you to call your html
helpfiles from within your program. It opens a separate browser
window, using whatever browser is present.
-
Checking
and disconnecting the modem - allows you to check whether an
internet connection is running or not and allows you to
disconnect the modem from the net.
-
Click-Starting
a file - this is how to run the program associated with a
file and make the program load that file.
-
Including
Start Menu item - this is how to put your program into the
start menu from within the program itself. Handy if your
installer doesn't do it.
-
Using
the registry - We all do it. This is how to initialise,
check for data and alter data in the registry.
Delphi code snippets
-
Generation
of virtual TShapes - The code behind this can be applied to
generating arrays of virtually any T-Class component.
-
Bizarrely-shaped
windows - Windows don't always have to be rectangular. You
can change their shapes!
-
Viewing
Windows Address Book - This code isn't perfect but it does
read most of the entries in Windows Address Book reasonably
well. Uses the registry to discover the location of the address
book.
-
IP-Stripper
- This allows the user to drop an email header onto a TMemo. It
then strips the I/P addresses out of it, discarding those lying
within reserved ranges (ranges not used on the open internet)
and replaces the text in the TMemo with I/P addresses that have
a valid format. It also drops onto a second memo, the DWords for
each I/P address.
Bonus
How to make use of the CD auto-run facility.
Start notepad.
type
[autorun]
open=MyApp.exe // the name of your
exe
icon=MyIcon.ico // the name of the icon you wish to
appear in Explorer
save as autorun.inf on your cd.
|