Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
An alternative way of setting Form.Closable to False
GDI+: rotating images using matrix transformations
GDI+: Storing DLL icon resources in image files
How to generate UUID values
How to get Special Folders paths
How to save registry key including its subkeys and values to a file
Returning some basic information for the specified INF file
Using GetNearestColor
Converting a decimal string to an integer
GDI+: Color Transparency
GDI+: converting image file to another graphics format
GetProcessVersion points at target OS
How to test file attributes (key method for FileExists and DirectoryExists routines)
Locking and unlocking file of a VFP table
Using Custom FTP class (DEFINE CLASS ftp As Custom)
Using the CopyFile
Winsock: how to retrieve a service information corresponding to a port
Retrieving graphic capabilities of your display
Retrieving information about MS-DOS device names using QueryDosDevice (WinNT only)
Using an Event Object. Part B: running an application responding to events
GetFileOwner - Get the owner of an NTFS file
Retrieving configuration information for the specified server (Win98/Me)
Retrieving information specific to the current Time Zone
Running a regular FoxPro form while main VFP window is minimized
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: 67  
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 (107.22.127.92)
3 sec.Example: 'Retrieving long values associated with the class of the VFP window'
14.07 min.Function: 'SHSimpleIDListFromPath'
14.12 min.Function: 'AddPrinter'
Function group: 'Printing and Print Spooler'
20.77 min.Example: 'Dragging files from Explorer window and dropping them on FoxPro control (requires VFP9)'
20.83 min.Example: 'Attaching menu to a top-level form'
6.84 hrs.Example: 'How to print a bitmap file'
6.85 hrs.Example: 'How to ping a remote site using IP Helper API calls'
7.33 hrs.Example: 'Custom GDI+ class'
10.88 hrs.Example: 'Storing registration key in the resources of an executable file'
 Example: 'Confining Windows calculator inside the VFP main window'
Google
Advertise here!