Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Retrieving information about all users currently logged on to the workstation (WinNT only)
Retrieving statistics for the TCP protocol running on the local computer
Comparing file times
Enumerating Performance Counters
An alternative way of setting Form.Closable to False
Changing system colors
Using the high-resolution performance counter
Converting path to original case
List of addresses in the AutoDial mapping database
Managing Cookies
Using the GetLogicalDriveStrings
How to create a service object
WAV file recorder
Retrieving window and menu help context identifiers
Using Video Capture: enumerating installed capture drivers
Setting the last-error code for the FoxPro
Using ActiveX control for adding a menu directly to a FoxPro MDI form
Hiding mouse cursor
Who is the first in viewing the Clipboard
Enumerating forms supported by a specified printer
Searching for the specified file using the SearchPath
Terminating VFP application using the FatalAppExit
Open and close a Simple MAPI Session
Creating a file, then moving it to another destination
Winsock: retrieving information about available transport protocols

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
 
*| typedef struct _WSAPROTOCOLCHAIN {
*|   int   ChainLen;
*|   DWORD ChainEntries[MAX_PROTOCOL_CHAIN];
*| } WSAPROTOCOLCHAIN, *LPWSAPROTOCOLCHAIN; total bytes = 32
 
*| typedef struct _WSAPROTOCOL_INFO {
*|   DWORD            dwServiceFlags1;             0:4
*|   DWORD            dwServiceFlags2;             4:4
*|   DWORD            dwServiceFlags3;             8:4
*|   DWORD            dwServiceFlags4;            12:4
*|   DWORD            dwProviderFlags;            16:4
*|   GUID             ProviderId;                 20:16
*|   DWORD            dwCatalogEntryId;           36:4
*|   WSAPROTOCOLCHAIN ProtocolChain;              40:32
*|   int              iVersion;                   72:4
*|   int              iAddressFamily;             76:4
*|   int              iMaxSockAddr;               80:4
*|   int              iMinSockAddr;               84:4
*|   int              iSocketType;                88:4
*|   int              iProtocol;                  92:4
*|   int              iProtocolMaxOffset;         96:4
*|   int              iNetworkByteOrder;         100:4
*|   int              iSecurityScheme;           104:4
*|   DWORD            dwMessageSize;             108:4
*|   DWORD            dwProviderReserved;        112:4
*|   TCHAR            szProt[WSAPROTOCOL_LEN+1]; 116:256
*| } WSAPROTOCOL_INFO, *LPWSAPROTOCOL_INFO; total bytes = 372 
 
#DEFINE WSAPROTOCOL_INFO_SIZE  372
#DEFINE WSAPROTOCOL_LEN        255
#DEFINE MAX_PROTOCOL_CHAIN       7
DO decl
 
LOCAL lcBuffer, lnBufsize, lcProtInfo, lnProtIndex, lnProtCount
 
IF InitWinsock()
    lnBufsize = 16384  && large enough to care not
    lcBuffer = Repli(Chr(0), lnBufsize)
    lnProtCount = WSAEnumProtocols (0, @lcBuffer, @lnBufsize)
 
    * resulting cursor
    CREATE CURSOR cs (;
        flags1   N(16),;
        flags2   N(16),;
        flags3   N(16),;
        flags4   N(16),;
        guid     C(16),;
        entryid  N(16),;
        chain    C(32),;
        version  N(16),;
        addrfam  N(16),;
        maxsock  N(16),;
        minsock  N(16),;
        socktype N(16),;
        protocol N(16),;
        maxoffs  N(16),;
        btorder  N(16),;
        secur    N(16),;
        msgsize  N(16),;
        reserved N(16),;
        protname C(250);
    )
 
    * scan the buffer filled by the WSAEnumProtocols function
    FOR lnProtIndex=0 TO lnProtCount-1
        * extract protocol info substring from the buffer
        lcProtInfo = SUBSTR(lcBuffer, lnProtIndex*WSAPROTOCOL_INFO_SIZE+1,;
            WSAPROTOCOL_INFO_SIZE)
 
        = DisplayProtInfo (lcProtInfo)
    ENDFOR
 
    = WSACleanup()
    GO TOP
    BROWSE NORMAL NOWAIT
ENDIF
* End of Main
 
PROCEDURE  DisplayProtInfo (lcProtInfo)
    LOCAL lcProt
 
    lcProt = SUBSTR(lcProtInfo, 117)  && protocol name offset
    lcProt = SUBSTR(lcProt, 1,AT(Chr(0),lcProt)-1)
 
    * append the protocol info to the resulting cursor
    INSERT INTO cs VALUES (;
        buf2dword(SUBSTR(lcProtInfo,   1,4)),;
        buf2dword(SUBSTR(lcProtInfo,   5,4)),;
        buf2dword(SUBSTR(lcProtInfo,   9,4)),;
        buf2dword(SUBSTR(lcProtInfo,  13,4)),;
        SUBSTR(lcProtInfo, 21,16),;
        buf2dword(SUBSTR(lcProtInfo,  37,4)),;
        SUBSTR(lcProtInfo, 41,32),;
        buf2dword(SUBSTR(lcProtInfo,  73,4)),;
        buf2dword(SUBSTR(lcProtInfo,  77,4)),;
        buf2dword(SUBSTR(lcProtInfo,  81,4)),;
        buf2dword(SUBSTR(lcProtInfo,  85,4)),;
        buf2dword(SUBSTR(lcProtInfo,  89,4)),;
        buf2dword(SUBSTR(lcProtInfo,  93,4)),;
        buf2dword(SUBSTR(lcProtInfo,  97,4)),;
        buf2dword(SUBSTR(lcProtInfo, 101,4)),;
        buf2dword(SUBSTR(lcProtInfo, 105,4)),;
        buf2dword(SUBSTR(lcProtInfo, 109,4)),;
        buf2dword(SUBSTR(lcProtInfo, 113,4)),;
        m.lcProt;
        )
RETURN
 
FUNCTION  InitWinsock()
* Initializing the Winsock service for the application
#DEFINE WSADATA_SIZE 398
#DEFINE WS_VERSION 0x0202
    LOCAL lcWSADATA, lnInitResult
    lcWSADATA = Repli(Chr(0), WSADATA_SIZE)
    lnInitResult = WSAStartup (WS_VERSION, @lcWSADATA)
RETURN  (lnInitResult = 0)
 
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
 
PROCEDURE  decl
    DECLARE INTEGER WSAStartup IN ws2_32 INTEGER wVerRq, STRING @lpWSAData
    DECLARE INTEGER WSACleanup IN ws2_32
    DECLARE INTEGER WSAEnumProtocols IN ws2_32;
        INTEGER lpiProtocols, STRING @lpProtBuf, INTEGER @lpdwBufLen
 
 

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
4284 bytes  
Created: 2001-12-20 07:13:05  
Modified: 2005-12-27 10:44:22  
Visits in 7 days: 62  
Listed functions:
WSACleanup
WSAEnumProtocols
WSAStartup
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.16.17.90)
5 sec.Example: 'Custom HttpRequest class (WinINet)'
Language: 'C++'
2.41 hrs.Function: 'GdipFillRectangle'
Function group: 'GDI+ Graphics'
 Function: 'CreateSolidBrush'
8.59 hrs.Example: 'How to set Creation Date/Time for a folder (WinNT)'
 Function: 'GdipCreateBitmapFromHBITMAP'
11.89 hrs.Function: 'NetScheduleJobEnum'
12.04 hrs.Example: 'How to display the Print property sheet'
 Example: 'Retrieving list of Global Atom names'
15.78 hrs.Example: 'Displaying dimmed window behind VFP top-level form'
23.24 hrs.Function: 'gethostbyname'
Function group: 'Windows Sockets 2 (Winsock)'
Google
Advertise here!