 |
| Storing registration key in the resources of an executable file |
User rating: 0/10 (0 votes) | |
|
|
 |
 |
| Before you begin: |
 |
This sample shows how to save a registration key -- actually it can be any kind of data -- in the resources of VFP executable file after its compilation.

Choose an executable file to test this code with. Consider that its modification date and the file size may change due to the testing. Also note that Win32 process -- afaik -- cannot modify its executable file.
See also:
How to display a user-defined icon in the MessageBox dialog
|
 |
 |
| |
| |
Members area. Log in to view this example. |
|
| |
|
|
|
|
|
 |
User rating: 0/10 (0 votes) | |
| 6758 bytes Created: 2003-05-16 09:59:30 Modified: 2011-12-10 09:20:22 Visits in 7 days: 109 |
|
 |
 |
| Listed functions: |
 |
|
 |
 |
| My comment: |
 |
As the Win32 executable, the FoxPro application is able to access resources by their types and identifiers using API calls. There is a limitation: an executable can not modify its own resources. To add or modify resource data in an application a separate loader utility is required.
You know about "Other Files" section inside the Project Manager. I think, that would be handy to have a similar section named "Resources", where files like icons, bitmaps, sounds, strings and others could be added. And after the file compiled into an executable, they could be reached through the Resource API calls LoadResource, LoadString, LoadImage and so on.
* * *
At first, this code truncated each and every VFP executable it was applied to, making the executables unusable. Everything in the code seemed to be correct, all API functions were called properly. The problem appeared to be with the VFP executable format itself.
Good news came on Nov.23, 2005 with an article I spotted on Calvin Hsia`s WebLog Strongly typed methods and properties.
Calvin preserves two last sections of the executable before modifying its resources; and appends them back after the EndUpdateResource succeeds. Looks like it solves the truncation problem.
From his code one may deduce that last DWORD in each section contains the size of this section. So far I have no idea whether it is a documented feature.
* * *
Resource Hacker -- a freeware utility for viewing and modifying resources in 32bit Windows executables and resource files (*.res).
PEBrowse is a browser and disassembler for Win32 executables and Microsoft .NET assemblies.
|
 |
 |
| Word Index links for this example: |
 |
|
|
 |
 |
| Translate this page: |
 |
|