Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Storing registration key in the resources of an executable file
Storing registration key in the resources of an executable file

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
More code examples    Listed functions    Add comment     W32 Constants      Translate this page Printer friendly version of this code sample
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 name:
      Forgot your password?
      Sign up for
    the Membership

    User rating: 0/10 (0 votes)
    Rate this code sample:
    • ~
    6758 bytes  
    Created: 2003-05-16 09:59:30  
    Modified: 2011-12-10 09:20:22  
    Visits in 7 days: 86  
    Listed functions:
    Printer friendly API declarations
    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:
      Spanish    Portuguese    German    French    Italian offers instant, free translations of text or web pages.
    User Contributed Notes:
    There are no notes on this subject.

    Copyright 2001-2018 News2News, Inc. Before reproducing or distributing any data from this site please ask for an approval from its owner. Unless otherwise specified, this page is for your personal and non-commercial use. The information on this page is presented AS IS, meaning that you may use it at your own risk. Microsoft Visual FoxPro and Windows are trade marks of Microsoft Corp. All other trademarks are the property of their respective owners. 

    Privacy policy
    Credits: PHP (4.4.9), an HTML-embedded scripting language, MySQL (5.6.39), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
    Last Topics Visited (
    10 sec.Function: 'WSAConnect'
    Function group: 'Windows Sockets 2 (Winsock)'
    23 sec.Function: 'WSACleanup'
    Function group: 'Windows Sockets 2 (Winsock)'
    33 sec.Function: 'GdipCreateBitmapFromHICON'
    Function group: 'GDI+ Bitmap'
    44 sec.
    Function group: 'ODBC API'
    56 sec.Function: 'SetFileAttributes'
    Function group: 'File Management'
    1.1 min.Function: 'CreateProcessAsUser'
    Function group: 'Process and Thread'
    1.28 min.Function: 'CryptUnprotectData'
    Function group: 'Cryptography Reference'
    1.5 min.Project
    1.7 min.
    Function group: 'Unicode and Character Set'
    1.85 min.Function: 'ReleaseCapture'
    Function group: 'Mouse Input'
    Advertise here!