Miscellaneous TD tools & components
When programming WinSock in TD, one major drawback you might discover is that detailed WinSock errors normally fetched using
the API function WSAGetLastError always returns 0 (zero).
This is caused by the fact that TD internally resets the last error code so your code will not be able to get it.
A solution is to use a wrapper dll, which offers the same API as WinSock, but internally calls WSAGetLastError when an error occurs.
The fetched error code is then passed back to TD so you can display the detailed error info.
A small wrapper is build and can be downloaded from the Sample Vault which does the above.
The source (Visual Studio 6 C++ project) is also part of the ZIP file.
Along with the TD sample, a INI file is present which holds all WinSock error codes and their short and long descriptions.
The sample application uses this INI to display the detailed error message.
Using the Callback dll, created by Christian Schubert, you are able to use Window API features
which require a callback function. In short, when using these features, Windows is able to call functions
within your TD application. Without the Callback DLL principle, TD does not offer a way to support callbacks.
An example where a callback function is used:
The Windows API function EnumThreadWindows is able to enumerate all nonchild windows associated with a thread.
This means you can obtain all opened top level windows within your application (all other windows present in the system take no part in the enumeration).
Reading the MSDN documentation on this function:
"The EnumThreadWindows function enumerates all nonchild windows associated with a thread by passing
the handle to each window, in turn, to 'an application-defined callback function'.
EnumThreadWindows continues until the last window is enumerated or the callback function returns FALSE."''
So, by calling this function and passing a "pointer" to an application defined function, all window handles are passed to that function in sequence.
As TD does not support pointers to functions, you are not able to utilize this function.
Callback DLL is the solution. It offers you a simple way to register a TD function (in a class, global function, window function)
which can be used as callback function.
TODO: create a callback sample on EnumThreadWindows.
You can download Callback from Christian Schuberts website
or from the Sample Vault:
All credits and thanks go to Armin Pokorny, who has developed this handy tool !!!
This tool adds for every function and message within your TD source a trace option.
When running the profiled application (and tracing is enabled), the entry and exit of the profiled functions/messages are saved to a trace file.
Using the trace viewer, you can inspect which functions are called and what time it took to complete the function/message.
These are some examples when such a tool may become handy:
- Time functions and messages at runtime. How long does a function take to complete
- Crashing application: run the app and let it crash. The tracefile will show the last executed function/message to pinpoint the issue
- See which functions are called or messages received and the sequence of them
- See how many times a recursive function is called and find any depth issues
This tool will add the needed extra code in your source.
Every function/message entry and exit points will be changed to have the entry and exits in the trace file.
The resulting source file can be used to build a profiled application.
When the profiled application saved a trace file, use this tool to view the trace file.
Needed runtime files:
TDProfiling.dll -> manages saving to the trace file.
It is a custom build dll, the project of that dll can be found in folder TDProfiling_dll.
This dll must be deployed along with the profiles TD application.
Steps to create a profiled source:
1) Start TDCodeGen.apt
2) Select your TD source and destination file
3) Press Start. It will create a profiled source. Repeat for every source file you want to trace.
(When using a merged source, you will get tracing for your application in one stroke)
4) Add manually to your profiled source the include file : TDApplicationProfiling.apl
5) Enable the tracing in App_Startup of your TD application and also close the tracing after ending the application
On SAM_AppStartup Set g_bTDProfile = TRUE Call TDTraceStart( 'C:\\TEMP\\MyTrace.trc' ) On SAM_AppExit Call TDTraceStop( ) Call TDProfileWriteFile( 'C:\\TEMP\\MyProfile.pro' ) Call TDProfileFlush( )
6) Build your profiled application to executable
7) Deploy the executable along with the TDProfiling.dll
8) Run your profiled application. It will create a trace file at the given location in step 5
9) Use the TDTraceViewer to open the trace file and inspect.
You can download the tool incl sources (c project and TD sources) from here:
UPDATE : Version 2 build 1 is now available. It is a stripped version, backported to TD15 file source.
This means you can use it with TD15 and higher without changing the source includes.
Registry Utilities Library (ANSI & UNICODE & x64)
With this library you can access the Windows registry using a class with functions to read, write or delete registry items.
The original library (v1.4) was only for ANSI TD versions and was not updated anymore in a central place.
The original library was created by Joe Meyer.
Now a new archive is created, starting as v2.0. It offers both ANSI and UNICODE versions.
ANSI must be used for TD1.5 up to TD4.2.
UNICODE must be used for TD51 and higher.
Also some new functions are added. For instance the feature to dump parts of the registry to a file or as a string.
Some defects have been solved on the older functions.
Latest version is v2.1
RegistryA.apl ------------- v2.1 16-11-2016 Dave Rabelink - Changed HKEY declarations from LONG to HANDLE - Merged changes from UNICODE version to this one - Able to specify the alternative view mode (32 or 64 bit) - Runs on TD x64 (eg TD 7.0) v2.0 25-07-2013 Dave Rabelink - Cleaned up source - Added EnumTypedValues - Added ReadBinaryAt - Fixed contatenation issues with getting key and values - Added KEY_WOW* constants - Added SetSlashConversion - Added dump to file or string v1.4 19-01-2000 Joe Meyer (reported by Martin Jussel) - Fixed CreateKey() v1.3 23-09-1999 Joe Meyer (reported by Charles McLouth, Centura) - Fixed handle leak in CloseKey when used with LazyWrite=false - Included FlushKey() - Included RegLoadKey(), RegSaveKey(), RegRestoreKey - Included shlwapi.dll declarations v1.2 14-10-1998 Joe Meyer (reported by Joerg Ellinghaus) - Fixed invalid buffer length bug in EnumValues(), EnumKeys() v1.1 09-07-1998 Joe Meyer - Fixed insufficient rights bug under NT4 RegistryW.apl ------------- v2.1 16-11-2016 Dave Rabelink - Added missing API functions which are present in ANSI version - Changed HKEY declarations from LONG to HANDLE (for x64) - Able to specify the alternative view mode (32 or 64 bit) - Runs on TD x64 (eg TD 7.0) v2.0 25-07-2013 Dave Rabelink - Converted to UNICODE API - Cleaned up source - Added EnumTypedValues - Added ReadBinaryAt - Fixed concatenation issues with getting key and values - Added KEY_WOW* constants - Added SetSlashConversion - Added dump to file or string
Here you can find all versions of this library:
By Alfredo Monasi
The purpose of this library is to give a simple tool to encrypt string in a simple way using standard of encryption today.
For TD 6.2 and higher.
- 1. Select Tools/.Net Explorer option
- 2. Select assembly Class and choose crypto.dll
- 3. Select Crypto.Security Class and choose the output path to generate the proxy Class.
- 4. After the functional classes are generated you will use the new functions with the new object Crypto_Security
- 5. Remember to use first the Security() function and when ends the Security_release() function
|sha1Encrypt||The first parameter is the String to encrypt in SHA1 algorithm, the second value is the encrypted string. Returns a boolean true if succeed or false if failed.|
|sha2Encrypt||The first parameter is the String to encrypt in SHA2 (512 bits) algorithm, the second value is the encrypted string. Returns a boolean true if succeed or false if failed.|
|SimpleEncrypt||The first parameter is the String to encrypt in Rijndael Algorithm with a pass key and initvector defined as constant in the library. the second value is the encrypted string. Returns a boolean true if succeed or false if failed.|
|ComplexEncrypt||The first parameter is the String to encrypt in TripleDES Algorithm, the second parameter is the passkey specified by the user, the third parameter is a boolean if true use a MD5 hashing of the key, the fourth value is the encrypted string. Returns a boolean true if succeed or false if failed.|
|ShowLastError||Return a string with the last error of the instanced class.|
Any bug report, doubt or problems please feel free to write me an email:
Email : Alfredo Monasi
Here you can find this library:
Click away TD IDE errors automatically during loading of backported sources
When you want to open sources created in a newer TD version using an older TD version you will have to manually change the outline version number in the source file.
This action is described in a TD WIKI article here:
You are then able to load the source.
But in many cases the outline structure of the source contains items which were introduced in the newer TD version(s) and can not be processed by the older TD version.
Those errors encountered during loading of the source are presented as an error message-box, like this:
You have to dismiss the message-box by clicking OK, until another error is encountered and you will have to click again and again and again...
There is no option to dismiss them all and ignore any errors which might be encountered.
Pressing CANCEL on the message-box will cancel the loading of the source file entirely.
For large sources having many issues this manual action is very tedious and time consuming and will probably induce RSI.
Furthermore, when you want to know which errors occurred, you will have to write them down for each case.
A little tool is created to help out. It will:
- Automatically click on OK when a message-box appears
- Logs all encountered error messages in a string field to be used for inspection later on.
Usage is simple:
- Start the tool before (or during) opening a TD source in another TD IDE instance
- Press the monitor button to start monitoring of error message-boxes
- Then open the source having errors in any TD version while the monitor runs
- Message-boxes will be automatically dismissed by clicking OK and reports the error text in the log field
You can find this tool here:
Quricol QR code generator library
Quricol is an open source freeware QR code generator library for C++, Microsoft .NET and Delphi based on qrencode – QR Code encoder by Kentaro Fukuchi.
The library contains methods to save the generated image to Bitmap or PNG file or generate images on-fly and save it to the stream.
The Quricol library can be used in TD applications using the supplied API for ANSI and UNICODE TD versions.
Also a 64 bit version is available for TD 7.x x64 versions.
More info on the library can be found here:
The TD implementation is shown in a sample application.
QR code is generated and displayed in a picture control.
The margin, pixel size and quality can be set.
Furthermore, the background and foreground colors can be changed.
The resulting QR code can be saved to a BMP or PNG file on disk.
You can download the sample from here:
It contains sources for ANSI, UNICODE and x64 TD versions.
The TD functions SalStrCompress and SalStrUncompress use a TD specific compression algorithm.
To be able to compress and uncompress in .NET and use the algorithm in C# projects this library is created. It does not need a TD runtime installation or any other 3rd party dependencies.
The solution contains 3 projects.
This is a standalone assembly (dll) which contains several methods to compress and uncompress.
It can be used as reference in any .NET projects and does not need any other external references.
These methods are available:
(see source for details)
- SalCompress -> compress byte array
- SalCompressFromFile -> compress file to byte array
- SalCompressToFile -> compress byte array to file
- SalUncompress -> uncompress byte array
- SalUncompressFromFile -> uncompress file to byte array
- SalUncompressToFile -> uncompress byte array to file
- SalIsCompressed -> Check if byte array is compressed
- SalGetCompressionInfo -> Get compression header info from byte array
- SalFileGetCompressionInfo -> Get compression header info from file
- SalFileCompress -> Compress input file to output file
- SalFileUncompress -> Uncompress input file to output file
Instead of referencing the assembly you can include the main source into your project to use the methods directly without the assembly.
This is a simple tool (executable) which uses the non-referenced way of using the compression API.
It can be used as a console application or as a GUI application. The executable can be used standalone, the SALCompression.dll is not needed.
When started from command (cmd) you can compress/uncompress files and get compression info.
SALCompressionCmd [/C] [/U] [/I] source destination /C Compress input file /U Uncompress input file /I Get compression info for input file source Specifies the input file destination Specifies the output file
Example to compress a file:
SALCompressionCmd.exe /C SourceFile.txt DestinationFile.bin
Example to uncompress a file:
SALCompressionCmd.exe /U SourceFile.bin DestinationFile.txt
Example to get compression info:
SALCompressionCmd.exe /I SourceFile.bin Compression header: Yes Has original data: No Original size: 1500054 Compressed size: 211176
When starting SALCompressionCmd.exe without parameters, the tool will show a GUI to select source and destination files. There files can be compressed/uncompressed or get compression info.
A small sample how to use the API. It needs the SALCompression.dll.
When run in command (cmd) it will output this:
Sample to compress a text string and uncompress it later Text to compress : 'This is some text to compress' The original bytes are: 54-68-69-73-20-69-73-20-73-6F-6D-65-20-74-65-78-74-20-74-6F-20-63-6F-6D-70-72-65-73-73 Compressing the bytes... Bytes are compressed now. The compressed bytes are: 3E-3C-00-02-F3-DC-1D-00-00-00-1C-00-00-00-90-54-68-69-73-69-73-10-73-6F-6D-65-74-65-78-12-74-74-6F-63-6F-6D-00-70-72-65-73-73 Uncompressing the bytes... Uncompressed text : 'This is some text to compress'
The archive contains all sources.
The binaries can be found in the Binaries folder.
SALCompression.NET can be downloaded here: