Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to change display settings: screen resolution, screen refresh rate
Adding and deleting Scheduled Tasks using NetScheduleJob API functions
Custom GDI+ class
Capturing keyboard activity of another application with the Raw Input API (VFP9)
Converting Unicode data from the Clipboard to a character string using a given code page
How to download a file from the FTP server using FtpGetFile
Detecting changes in connections to removable drives (VFP9)
Enumerating data formats currently available on the clipboard
How to play AVI file on the _screen
Winsock: sending email messages (SMTP, port 25)
Enumerating raw input devices attached to the system (keyboard, mouse, human interface device)
Custom FTP Class for Visual FoxPro application
Custom HttpRequest class (WinHTTP)
Deleting files into the Recycle Bin
Creating the Open dialog box to specify the drive, directory, and name of a file to open
How to activate Windows Calculator
Splash Screen for the VFP application
Custom HttpRequest class (WinINet)
Using Font and Text functions
Establishing connection using the SQLDriverConnect
Mapping and disconnecting network drives
How to display the Properties dialog box for a file (ShellExecuteEx)
Dragging files from Explorer window and dropping them on FoxPro control (requires VFP9)
How to convert a bitmap file to monochrome format (1 bpp)
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:
      Password:
     
     
      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: 94  
    Listed functions:
    BeginUpdateResource
    EndUpdateResource
    FindResource
    FreeLibrary
    GetLastError
    LoadLibraryEx
    LoadResource
    LockResource
    SizeofResource
    UpdateResource
    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  
    FreeTranslation.com offers instant, free translations of text or web pages.
    User Contributed Notes:
    There are no notes on this subject.


    Copyright © 2001-2013 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.1.55-log), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
    Last Topics Visited (107.22.127.92)
    6 sec.Example: 'Hiding mouse cursor'
    6.77 hrs.Example: 'How to save registry key including its subkeys and values to a file'
     Example: 'Determining if an Active Network Connection is Available'
    8.58 hrs.Example: 'Using the CreateFile'
    10.07 hrs.Example: 'How to fill a buffer with random bytes using Cryptography API Functions'
    10.66 hrs.Example: 'How to display the Properties dialog box for a file (ShellExecuteEx)'
    13.6 hrs.Example: 'GDI+: printing vertical text on VFP reports via generated images (VFP8)'
     Function: 'AlphaBlend'
    Function group: 'Bitmap'
     Example: 'Using MessageBeep'
    Language: 'C#'
    19.66 hrs.Example: 'Obtaining heap handles and enumerating memory blocks for the current VFP session (WinNT only)'
    Google
    Advertise here!