Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Current System information
GDI+: converting text strings to images and saving in a graphics file
How to enumerate terminal servers within the specified Windows domain
Running a regular FoxPro form while main VFP window is minimized
Using GetNearestColor
Using IsChild() for testing ThisForm.ShowWindow property
Winsock: retrieving information from a host database for a given host name
Adding supplementary data to AVI files
An alternative way of setting Form.Closable to False
Copying files as a transacted operation (Vista)
How to retrieve version information for the specified file
How to generate UUID values
Reading STARTUPINFO structure for the current VFP session
Winsock: initializing the service in the VFP application
Building a tree of subdirectories for a given path using FindFile functions
Drawing a window caption using the DrawCaption routine
Enumerating MIDI output devices
GDI+: Storing DLL icon resources in image files
Retrieving geometrical parameters of the system desktop window
Saying "Hello World!" with VFP and WinAPI
How to test file attributes (key method for FileExists and DirectoryExists routines)
Setting and retrieving the double-click time for the mouse
Winsock: how to retrieve a service information corresponding to a service name
Creating two-byte hashes for a list of URLs
Obtaining heap handles and enumerating memory blocks for the current VFP session (WinNT only)

User rating: 10/10 (1 votes)
Rate this code sample:
  • ~
More code examples    Listed functions    Add comment     W32 Constants      Translate this page Printer friendly version of this code sample
 
DO decl
 
*| typedef struct _PROCESS_HEAP_ENTRY {
*|   PVOID lpData;                      1:4
*|   DWORD cbData;                      5:4
*|   BYTE cbOverhead;                   9:1
*|   BYTE iRegionIndex;                10:1
*|   WORD wFlags;                      11:2
*|   union {
*|       struct {
*|           HANDLE hMem;              13:4
*|           DWORD dwReserved[ 3 ];    17:4
*|       } Block;
*|       struct {
*|           DWORD dwCommittedSize;    13:4
*|           DWORD dwUnCommittedSize;  17:4
*|           LPVOID lpFirstBlock;      21:4
*|           LPVOID lpLastBlock;       25:4
*|       } Region;
*|   };                       total: 28 bytes
*| } PROCESS_HEAP_ENTRY, *LPPROCESS_HEAP_ENTRY
 
#DEFINE STRU_LENGTH                    28
 
*| Flags -- properties of the heap element
#DEFINE PROCESS_HEAP_REGION             1
#DEFINE PROCESS_HEAP_UNCOMMITTED_RANGE  2
#DEFINE PROCESS_HEAP_ENTRY_BUSY         4
#DEFINE PROCESS_HEAP_ENTRY_MOVEABLE    16
#DEFINE PROCESS_HEAP_ENTRY_DDESHARE    32
 
    LOCAL ii, lnHeapCount, lcBuffer, hHeap, lcHeapEntry, lnResult,;
        lpData, cbData, cbOverhead, lnRegIndex, lnFlags,;
        lnSzCmt, lnSzUncmt, lnFBlock, lnLBlock
 
    lnHeapCount = 256
    lcBuffer = Repli (Chr(0), lnHeapCount*4)
    lnHeapCount = GetProcessHeaps (lnHeapCount, @lcBuffer)
 
    * resulting cursor
    CREATE CURSOR csResult (heapno N(5), dataptr N(12),;
        datasize N(12), oversize N(4), regindex N(4), flags N(12),;
        szcomm N(12), szuncomm N(12), fblock N(12), lblock N(12))
 
    FOR ii = 1 TO lnHeapCount
        hHeap = buf2dword(SUBSTR (lcBuffer, (ii-1)*4+1, 4))
 
        * The HeapLock function is primarily useful for preventing 
        * the allocation and release of heap memory by other threads 
        * while the calling thread uses the HeapWalk function.
        IF HeapLock (hHeap) = 0
            ? "Failure to lock handle:", hHeap
            LOOP
        ENDIF
 
        * stuff the buffer with zeroes
        lcHeapEntry = Repli (Chr(0), STRU_LENGTH)
 
        DO WHILE HeapWalk(hHeap, @lcHeapEntry) <> 0
            lpData     = buf2dword (SUBSTR(lcHeapEntry, 1,4))
            cbData     = buf2dword (SUBSTR(lcHeapEntry, 5,4))
            cbOverhead = Asc(SUBSTR(lcHeapEntry, 9,1))
            lnRegIndex = Asc(SUBSTR(lcHeapEntry, 10,1))
            lnFlags    = buf2word (SUBSTR(lcHeapEntry, 11,2))
 
            IF lnFlags = PROCESS_HEAP_REGION
                lnSzCmt   = buf2dword (SUBSTR(lcHeapEntry, 13,4))
                lnSzUncmt = buf2dword (SUBSTR(lcHeapEntry, 17,4))
                lnFBlock  = buf2dword (SUBSTR(lcHeapEntry, 21,4))
                lnLBlock  = buf2dword (SUBSTR(lcHeapEntry, 25,4))
            ELSE
                STORE 0 TO lnSzCmt, lnSzUncmt, lnFBlock, lnLBlock
            ENDIF
 
            INSERT INTO csResult VALUES (ii, lpData, cbData, cbOverhead,;
                lnRegIndex, lnFlags, lnSzCmt, lnSzUncmt,;
                lnFBlock, lnLBlock)
        ENDDO
 
        * Each call to HeapLock must be matched by 
        * a corresponding call to the HeapUnlock function
        = HeapUnlock (hHeap)
    ENDFOR
 
    SELECT csResult
    GO TOP
    BROWSE NORMAL NOWAIT
 
FUNCTION  buf2dword (lcBuffer)
RETURN Asc(SUBSTR(lcBuffer, 1,1)) + ;
    Asc(SUBSTR(lcBuffer, 2,1)) * 256 +;
    Asc(SUBSTR(lcBuffer, 3,1)) * 65536 +;
    Asc(SUBSTR(lcBuffer, 4,1)) * 16777216
 
FUNCTION  buf2word (lcBuffer)
RETURN Asc(SUBSTR(lcBuffer, 1,1)) + ;
       Asc(SUBSTR(lcBuffer, 2,1)) * 256
 
PROCEDURE  decl
    DECLARE INTEGER GetProcessHeaps IN kernel32;
        INTEGER NumberOfHeaps, STRING @ProcessHeaps
 
    DECLARE INTEGER HeapWalk IN kernel32;
        INTEGER hHeap, STRING @lpEntry
 
    DECLARE INTEGER HeapLock IN kernel32 INTEGER hHeap
    DECLARE INTEGER HeapUnlock IN kernel32 INTEGER hHeap
 
 

User rating: 10/10 (1 votes)
Rate this code sample:
  • ~
3547 bytes  
Created: 2001-10-26 19:04:09  
Modified: 2001-10-26 19:15:06  
Visits in 7 days: 74  
Listed functions:
GetProcessHeaps
HeapLock
HeapUnlock
HeapWalk
Printer friendly API declarations
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 (50.17.109.248)
1.5 hrs.Function: 'getsockopt'
7.21 hrs.Example: 'Scanning the hierarchy of child windows down from the main VFP window'
 Example: 'Retrieving local computer and user names'
 Function: 'SQLGetInfo'
18.84 hrs.Function: 'CreateCompatibleBitmap'
 Function: 'AppendMenu'
20.36 hrs.Function: 'UrlHash'
 Example: 'Simple MAPI: how to resolve a name to unique address list entry'
21.84 hrs.Function: 'RealGetWindowClass'
Function group: 'Window'
22.65 hrs.Function: 'PostMessage'
Function group: 'Message and Message Queue'
Google
Advertise here!