Using Win32 functions in Visual FoxPro Image Gallery
Memory Management
..msdn
CopyMemory
FillMemory
GetProcessHeap
GetProcessHeaps
GlobalAlloc
GlobalFree
GlobalLock
GlobalMemoryStatus
GlobalReAlloc
GlobalSize
GlobalUnlock
HeapAlloc
HeapCompact
HeapFree
HeapLock
HeapReAlloc
HeapSize
HeapUnlock
HeapValidate
HeapWalk
LocalAlloc
LocalFree
LocalSize
VirtualAllocEx
VirtualFreeEx
ZeroMemory
Code examples:
Accessing LSA Policy object (Local Security Authority)
Adding and deleting Scheduled Tasks using NetScheduleJob API functions
Adding and deleting User Accounts
Adding printer to the list of supported printers for the specified server
Adding user-defined items to the Control Menu of VFP form (requires VFP9)
Attaching menu to a top-level form
Browsing Windows Known Folders (Special Folders)
Compressing and decompressing files with Windows API Runtime Library routines
Converting command-line string to a set of Unicode argument strings (WinNT only)
Creating the Open dialog box to specify the drive, directory, and name of a file to open
Creating the Save dialog box to specify the drive, directory, and name of a file to save
Custom HttpRequest class (WinHTTP)
Deleting files into the Recycle Bin
Displaying dimmed window behind VFP top-level form
Displaying standard progress dialog box when copying files
Displaying system dialog that selects a folder
Dynamic strings implemented through VFP Custom class
Enumerating data formats currently available on the clipboard
Enumerating files opened on the network
Extensible Storage Engine class library
How to assemble an array of strings and pass it to external function
How to display a user-defined icon in the MessageBox dialog
How to display advanced Task Dialog (Vista)
How to display the Print property sheet
How to display the Properties dialog box for a file (ShellExecuteEx)
How to enumerate sessions and processes on a specified terminal server
How to enumerate terminal servers within the specified Windows domain
How to enumerate, add and delete shares on the local computer (WinNT/XP)
How to extract frames from AVI files
How to ping a remote site using ICMP API calls
How to prevent users from accessing the Windows Desktop and from switching to other applications
How to remove a directory that is not empty
How to write and read Window Properties for the specified window
Loading a string resource from an executable file
MapiSendMail class for Visual FoxPro application
Mapping and disconnecting network drives
Obtaining names of local and global groups for current user (WinNT/XP/2K)
Passing data records between VFP applications via the Clipboard
Printing Image File, programmatically set print page orientation to landscape
Reading and setting explicit Application User Model ID for the current process (Win7)
Reading entries from Event logs
Retrieving configuration information for the specified server (Win2000/XP)
Retrieving the command line for the VFP session
Sending email messages with Simple MAPI
Shortcut Menu Class
Starting a dialog box for connecting to network resources and passing input parameters
Storing the environment strings in cursor
URL: splitting into its component parts
Using Change Notification Objects to monitor changes to the printer or print server
Using WM_COPYDATA for interprocess communication (VFP9)
Windows Shell Icons displayed and exported to ICO files (Vista)
Winsock: connecting to a news server (NNTP, port 119)
Writing entries to custom Event Log
URL: splitting into its component parts

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
Versions:
click to open
 
*| typedef struct {
*|     DWORD  dwStructSize;        0:4
*|     LPTSTR  lpszScheme;         4:4 *
*|     DWORD  dwSchemeLength;      8:4
*|     INTERNET_SCHEME  nScheme;  12:4
*|     LPTSTR  lpszHostName;      16:4 *
*|     DWORD  dwHostNameLength;   20:4
*|     INTERNET_PORT  nPort;      24:4
*|     LPTSTR  lpszUserName;      28:4 *
*|     DWORD  dwUserNameLength;   32:4
*|     LPTSTR  lpszPassword;      36:4 *
*|     DWORD  dwPasswordLength;   40:4
*|     LPTSTR  lpszUrlPath;       44:4 *
*|     DWORD  dwUrlPathLength;    48:4
*|     LPTSTR  lpszExtraInfo;     52:4 *
*|     DWORD  dwExtraInfoLength;  56:4  
*| } URL_COMPONENTS, *LPURL_COMPONENTS; 15x4 = 60 bytes
 
LOCAL oUrlSplit As UrlSplit
oUrlSplit = CREATEOBJECT("UrlSplit")
 
oUrlSplit.url = "http:" + "/" +"/www.google.com/" +;
        "search?q=using+FindText+API&hl=en&start=10&sa=N"
 
WITH oUrlSplit
    ? "URL:", .url
    ? "Scheme Name:", .SchemeNme
    ? "Host Name:", .HostNme
    ? "User Name:", .UserNme
    ? "Password:", .Pwd
    ? "URL Path:", .UrlPath
    ? "Extra info:", .ExtraInfo
    ? "Scheme value:", .SchemeValue
    ? "Port:", .PortNumber
ENDWITH
* end of main
 
DEFINE CLASS UrlSplit As Relation
#DEFINE ICU_DECODE  0x10000000
#DEFINE ICU_ESCAPE  0x80000000
#DEFINE MAINBUF_SIZE  60
#DEFINE STRBUF_SIZE 1024
#DEFINE ZERO_DWORD REPLICATE(CHR(0),4)
 
    url=""
    SchemeNme=""
    HostNme=""
    UserNme=""
    Pwd=""
    UrlPath=""
    ExtraInfo=""
    SchemeValue=0
    PortNumber=0
 
    oScheme=NULL
    oHostName=NULL
    oUserName=NULL
    oPwd=NULL
    oUrlPath=NULL
    oExtraInfo=NULL
 
PROCEDURE Init(cUrl As String)
    THIS.oScheme = CREATEOBJECT("PChar", "")
    THIS.oHostName = CREATEOBJECT("PChar", "")
    THIS.oUserName = CREATEOBJECT("PChar", "")
    THIS.oPwd = CREATEOBJECT("PChar", "")
    THIS.oUrlPath = CREATEOBJECT("PChar", "")
    THIS.oExtraInfo = CREATEOBJECT("PChar", "")
 
    THIS.declare
    THIS.url = m.cUrl
 
PROCEDURE url_ASSIGN(cUrl As String)
    THIS.ResetObject
    IF VARTYPE(cUrl)="C" AND NOT EMPTY(cUrl)
        THIS.url = ALLTRIM(m.cUrl)
        THIS.SplitUrl
    ELSE
        THIS.url = ""
    ENDIF
 
PROCEDURE ResetObject
    THIS.SchemeNme = ""
    THIS.HostNme = ""
    THIS.UserNme = ""
    THIS.Pwd = ""
    THIS.UrlPath = ""
    THIS.ExtraInfo = ""
    THIS.SchemeValue = 0
    THIS.PortNumber = 0
 
PROTECTED PROCEDURE SplitUrl
    THIS.ResetObject
 
    LOCAL cBuffer, cEmptyString
 
    cEmptyString = REPLICATE(CHR(0), STRBUF_SIZE)
 
    THIS.oScheme.SetValue(m.cEmptyString)
    THIS.oHostName.SetValue(m.cEmptyString)
    THIS.oUserName.SetValue(m.cEmptyString)
    THIS.oPwd.SetValue(m.cEmptyString)
    THIS.oUrlPath.SetValue(m.cEmptyString)
    THIS.oExtraInfo.SetValue(m.cEmptyString)
 
    cBuffer = num2dword(MAINBUF_SIZE) +;
        num2dword(THIS.oScheme.GetAddr()) +;
        num2dword(STRBUF_SIZE) +;
        ZERO_DWORD +;
        num2dword(THIS.oHostName.GetAddr()) +;
        num2dword(STRBUF_SIZE) +;
        ZERO_DWORD +;
        num2dword(THIS.oUserName.GetAddr()) +;
        num2dword(STRBUF_SIZE) +;
        num2dword(THIS.oPwd.GetAddr()) +;
        num2dword(STRBUF_SIZE) +;
        num2dword(THIS.oUrlPath.GetAddr()) +;
        num2dword(STRBUF_SIZE) +;
        num2dword(THIS.oExtraInfo.GetAddr()) +;
        num2dword(STRBUF_SIZE)
 
    = InternetCrackUrl(THIS.url, LEN(THIS.url), ICU_DECODE, @cBuffer)
 
    THIS.SchemeNme = THIS.ns(THIS.oScheme.GetValue())
    THIS.HostNme = THIS.ns(THIS.oHostName.GetValue())
    THIS.UserNme = THIS.ns(THIS.oUserName.GetValue())
    THIS.Pwd = THIS.ns(THIS.oPwd.GetValue())
    THIS.UrlPath = THIS.ns(THIS.oUrlPath.GetValue())
    THIS.ExtraInfo = THIS.ns(THIS.oExtraInfo.GetValue())
    THIS.SchemeValue = buf2dword(SUBSTR(cBuffer, 13,4))
    THIS.PortNumber = buf2dword(SUBSTR(cBuffer, 25,4))
 
PROTECTED FUNCTION ns(cSrc As String) As String
    LOCAL nPos
    nPos = AT(CHR(0), m.cSrc)
RETURN IIF(nPos=0, m.cStr, SUBSTR(m.cSrc, 1, m.nPos-1))
 
PROCEDURE declare
    DECLARE INTEGER InternetCrackUrl IN wininet;
        STRING lpszUrl, INTEGER dwUrlLength,;
        INTEGER dwFlags, STRING @lpUrlComponents
 
ENDDEFINE
 
DEFINE CLASS PChar As Relation
    PROTECTED hMem
 
PROCEDURE Init (lcString)
    THIS.declare
    THIS.hMem = 0
    THIS.setValue (lcString)
 
PROCEDURE declare
    DECLARE INTEGER GlobalSize IN kernel32 INTEGER hMem
    DECLARE INTEGER GlobalAlloc IN kernel32 INTEGER, INTEGER
    DECLARE INTEGER GlobalFree IN kernel32 INTEGER
 
    DECLARE RtlMoveMemory IN kernel32 As Heap2Str;
        STRING @, INTEGER, INTEGER
 
    DECLARE RtlMoveMemory IN kernel32 As Str2Heap;
        INTEGER, STRING @, INTEGER
 
PROCEDURE Destroy
    THIS.ReleaseString
 
FUNCTION GetAddr  && returns a pointer to the string
RETURN THIS.hMem
 
FUNCTION GetValue && returns string value
    LOCAL lnSize, lcBuffer
    lnSize = THIS.getAllocSize()
    lcBuffer = SPACE(lnSize)
 
    IF THIS.hMem <> 0
        = Heap2Str (@lcBuffer, THIS.hMem, lnSize)
    ENDIF
RETURN lcBuffer
 
FUNCTION GetAllocSize  && returns allocated memory size (string length)
RETURN Iif(THIS.hMem=0, 0, GlobalSize(THIS.hMem))
 
PROCEDURE SetValue (lcString) && assigns new string value
#DEFINE GMEM_FIXED   0 
    THIS.ReleaseString
 
    LOCAL lnSize
    lcString = lcString + Chr(0)
    lnSize = Len(lcString)
    THIS.hMem = GlobalAlloc(GMEM_FIXED, lnSize)
    IF THIS.hMem <> 0
        = Str2Heap(THIS.hMem, @lcString, lnSize)
    ENDIF
 
PROCEDURE ReleaseString  && releases allocated memory
    IF THIS.hMem <> 0
        = GlobalFree (THIS.hMem)
        THIS.hMem = 0
    ENDIF
ENDDEFINE  && pchar
 
FUNCTION buf2dword(lcBuffer)
RETURN Asc(SUBSTR(lcBuffer, 1,1)) + ;
    BitLShift(Asc(SUBSTR(lcBuffer, 2,1)),  8) +;
    BitLShift(Asc(SUBSTR(lcBuffer, 3,1)), 16) +;
    BitLShift(Asc(SUBSTR(lcBuffer, 4,1)), 24)
 
FUNCTION num2dword(lnValue)
#DEFINE m0  256
#DEFINE m1  65536
#DEFINE m2  16777216
    IF lnValue < 0
        lnValue = 0x100000000 + lnValue
    ENDIF
    LOCAL b0, b1, b2, b3
    b3 = Int(lnValue/m2)
    b2 = Int((lnValue - b3*m2)/m1)
    b1 = Int((lnValue - b3*m2 - b2*m1)/m0)
    b0 = Mod(lnValue, m0)
RETURN Chr(b0)+Chr(b1)+Chr(b2)+Chr(b3)
 
 

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
5881 bytes  
Created: 2001-11-02 18:15:42  
Modified: 2007-05-04 17:55:03  
Visits in 7 days: 93  
Listed functions:
GlobalAlloc
GlobalFree
GlobalSize
InternetCrackUrl
Printer friendly API declarations
My comment:
May.04, 2007 -- the code sample rewritten from scratch.
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 (54.234.231.49)
3.49 hrs.Function: 'VkKeyScan'
Function group: 'Keyboard Input'
 Example: 'Creating irregularly shaped FoxPro form using transparency color key'
6.32 hrs.Example: 'MapiSendMail class for Visual FoxPro application'
 Example: 'Pocket PC: creating backup for the System Registry'
8.62 hrs.Links
Page 6
10.16 hrs.Example: 'Using the SetErrorMode for determining if a floppy drive is ready'
 Function: 'GdipCreateFromHWND'
Function group: 'GDI+ Graphics'
15.9 hrs.Function: 'CertFreeCertificateContext'
 Function: 'GetAsyncKeyState'
Function group: 'Keyboard Input'
 Example: 'How to display the Print property sheet'
Google
Advertise here!