Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
DiskFreeSpace class
GDI+: reading and writing metadata in JPEG and TIFF files
GDI+: Using Scale and Shear transformations
Hiding mouse cursor
How to find when the application started
Reading and setting explicit Application User Model ID for the current process (Win7)
Retrieving System Error message strings
Saving available locale records into a cursor
Winsock: initializing the service in the VFP application
GDI+: converting text strings to images and saving in a graphics file
Obtaining the bounding rectangle for the specified device context
Retrieving current user for the process
Simulating DOEVENTS
Using the MessageBox Win32 function
Who owns the Windows Clipboard
GDI+: rotating images using matrix transformations
How to display the Print property sheet
Retrieving the IP-to-physical address mapping table
Using Custom FTP class (DEFINE CLASS ftp As Custom)
Using shared memory to exchange data between two FoxPro applications
Using the Semaphore object
Current System information
GDI+: Storing DLL icon resources in image files
How to save registry key including its subkeys and values to a file
Retrieving information about all users currently logged on to the workstation (WinNT only)

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
 
DO declare
 
*| typedef struct _WKSTA_USER_INFO_1 {
*|   LPWSTR    wkui1_username;
*|   LPWSTR    wkui1_logon_domain;
*|   LPWSTR    wkui1_oth_domains;
*|   LPWSTR    wkui1_logon_server;  16 bytes
*| }WKSTA_USER_INFO_1, *PWKSTA_USER_INFO_1, *LPWKSTA_USER_INFO_1;
 
#DEFINE USERINFO_1_SIZE  16
#DEFINE MAX_PREFERRED_LENGTH -1
 
LOCAL lnResult, lnBuffer, lnEntriesRead, lnTotalEntries, lnResumeHandle
STORE 0 TO lnBuffer, lnEntriesRead, lnTotalEntries, lnResumeHandle
 
lnResult = NetWkstaUserEnum(0, 1, @lnBuffer, MAX_PREFERRED_LENGTH,;
    @lnEntriesRead, @lnTotalEntries, @lnResumeHandle)
 
IF lnResult <> 0
* 53 = The network path was not found
    ? "Error code:", lnResult
ELSE
    LOCAL lnEntry, lnBufLen, lcBuffer, lpwstrUsername,;
        lpwstrLogon_domain, lpwstrOth_domains, lpwstrLogon_server,;
        lcUsername, lcLogon_domain, lcOth_domains, lcLogon_server
 
    lnBufLen = lnEntriesRead * USERINFO_1_SIZE
    lcBuffer = Repli(Chr(0), lnBufLen)
    = Heap2String(@lcBuffer, lnBuffer, lnBufLen)
 
    * resulting cursor
    CREATE CURSOR csResult (username C(30), logon_domain C(30),;
        oth_domains C(30), logon_server C(30))
 
    * scannig returned entries - UserInfo structures
    FOR lnEntry = 1 TO lnEntriesRead
        * copying the UserInfo structure to a VFP string
        lcUserInfo = SUBSTR(lcBuffer,;
            (lnEntry-1)*USERINFO_1_SIZE+1, USERINFO_1_SIZE)
 
        * retrieving pointers to Unicode strings
        lpwstrUsername     = buf2dword(SUBSTR(lcUserInfo,  1,4))
        lpwstrLogon_domain = buf2dword(SUBSTR(lcUserInfo,  5,4))
        lpwstrOth_domains  = buf2dword(SUBSTR(lcUserInfo,  9,4))
        lpwstrLogon_server = buf2dword(SUBSTR(lcUserInfo, 13,4))
 
        * copying data from pointers to VFP strings
        lcUsername     = GetStrFromMem(lpwstrUsername)
        lcLogon_domain = GetStrFromMem(lpwstrLogon_domain)
        lcOth_domains  = GetStrFromMem(lpwstrOth_domains)
        lcLogon_server = GetStrFromMem(lpwstrLogon_server)
 
        INSERT INTO csResult VALUES (;
            lcUsername, lcLogon_domain, lcOth_domains, lcLogon_server)
    ENDFOR
ENDIF
 
* this buffer is allocated by the system and must be freed
= NetApiBufferFree(lnBuffer)
 
IF USED("csResult")
    SELECT csResult
    GO TOP
    BROWSE NORMAL NOWAIT
ENDIF
 
FUNCTION GetStrFromMem(lnMemBlock)
* converting allocated in memory Unicode string to a VFP string
#DEFINE StrBufferLength 250
    LOCAL lcBuffer
    lcBuffer = SPACE(StrBufferLength)
    = Heap2String(@lcBuffer, lnMemBlock, StrBufferLength)
    lcBuffer = SUBSTR(lcBuffer, 1, AT(Chr(0)+Chr(0),lcBuffer)-1)
RETURN  STRTRAN(lcBuffer, Chr(0),"")
 
PROCEDURE declare
    DECLARE INTEGER NetWkstaUserEnum IN netapi32;
        INTEGER servername, INTEGER level, INTEGER @ bufptr,;
        INTEGER prefmaxlen, INTEGER @entriesread,;
        INTEGER @totalentries, INTEGER @resumehandle
 
    DECLARE INTEGER NetApiBufferFree IN netapi32 INTEGER Buffer
 
    DECLARE RtlMoveMemory IN kernel32 As Heap2String;
        STRING @ Destination, INTEGER Source, INTEGER nLength
 
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
 
 
 

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
3144 bytes  
Created: 2001-10-16 23:52:32  
Modified: 2005-09-14 20:47:26  
Visits in 7 days: 93  
Listed functions:
NetApiBufferFree
NetWkstaUserEnum
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)
4 sec.Function: 'DeleteEnhMetaFile'
Function group: 'Metafile'
2.19 hrs.Function: 'PathIsRelative'
Function group: 'Shell Lightweight Utility APIs -- Path Functions'
 Example: 'How to print FoxPro form'
4.08 hrs.Function: 'GetCommandLine'
4.09 hrs.Function: 'SetDoubleClickTime'
Function group: 'Mouse Input'
9.81 hrs.Example: 'How to print picture stored in enhanced-format metafile (*.emf)'
 Example: 'Retrieving information about MS-DOS device names using QueryDosDevice (WinNT only)'
10.73 hrs.Example: 'How to change display settings: screen resolution, screen refresh rate'
Language: 'C#'
16.05 hrs.Function: 'ReadFile'
Function group: 'File Management'
17.48 hrs.Function: 'GlobalSize'
Function group: 'Memory Management'
Google
Advertise here!