Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Retrieving configuration information for the specified workstation (Win2000/XP)
Retrieving current settings for an ODBC connection
Using custom Simple MapiSendMail class
Using the SetErrorMode for determining if a floppy drive is ready
Accessing the list of Windows Recent Documents
Converting strings between ANSI and OEM
GDI+: printing vertical text on VFP reports via generated images (VFP8)
Joining local computer to a domain (XP/2000)
Retrieving list of Global Atom names
Retrieving the state of your Internet connection
Using Multimedia Command Strings to play MIDI files
Managing Cookies
Reading metrics for the currently selected font
Retrieving the elapsed time since the system was started
Retrieving the names of all sections in an initialization file
Closing Windows
Enumerating MIDI output devices
Obtaining provider name for a specific type of network
Retrieveing information about the active window (even if it is not owned by the calling process)
Retrieving configuration information for the specified server (Win2000/XP)
Extended OS Version info
GDI+: custom control, base class
Open and close a Simple MAPI Session
The original LoadPicture() function in VFP returns valid handles to bitmaps, icons, cursors, and metafiles
Retrieving configuration information for the specified workstation (Win2000/XP)

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
Before you begin:
Check similar example Retrieving configuration information for the specified server (Win2000/XP).
#DEFINE NERR_Success 0
DO decl

PRIVATE hBuffer, cBuffer
LOCAL cServer, nLevel, nResult, nBufsize
*cServer = Null
*cServer = STRCONV("MYSERVER"+CHR(0), 5)  && sufficient access level
nLevel=102
hBuffer=0

nResult = NetWkstaGetInfo(cServer, nLevel, @hBuffer)
IF nResult <> NERR_Success
* 5=ERROR_ACCESS_DENIED
* 53=ERROR_BAD_NETPATH
    ? "Error code:", nResult
    RETURN
ENDIF

nBufsize=0
= NetApiBufferSize(hBuffer, @nBufsize)

cBuffer = REPLICATE(CHR(0), nBufsize)
= CopyMemory(@cBuffer, hBuffer, nBufsize)

*|typedef struct _WKSTA_INFO_102 {
*|  DWORD wki102_platform_id;      0:4
*|  LMSTR wki102_computername;     4:4
*|  LMSTR wki102_langroup;         8:4
*|  DWORD wki102_ver_major;       12:4
*|  DWORD wki102_ver_minor;       16:4
*|  LMSTR wki102_lanroot;         20:4
*|  DWORD wki102_logged_on_users; 24:4
*|} WKSTA_INFO_102,... total bytes 28

CREATE CURSOR cs (prm C(30), vlu C(100))

nPlatformId = buf2dword(SUBSTR(cBuffer, 1,4))
INSERT INTO cs VALUES ("Platform ID", LTRIM(STR(nPlatformId)))
= NetApiBufferFree(hBuffer)

cComputerName = GetStr(5)
INSERT INTO cs VALUES ("Computer name", m.cComputerName)

cLangroup = GetStr(9)
INSERT INTO cs VALUES ("LAN Group", m.cLangroup)

nVerMajor = buf2dword(SUBSTR(cBuffer, 13,4))
INSERT INTO cs VALUES ("OS major version", LTRIM(STR(m.nVerMajor)))

nVerMinor = buf2dword(SUBSTR(cBuffer, 17,4))
INSERT INTO cs VALUES ("OS minor version", LTRIM(STR(m.nVerMinor)))

cLangroot = GetStr(21)
INSERT INTO cs VALUES ("LANMAN directory", m.cLangroot)

nLogged = buf2dword(SUBSTR(cBuffer, 25,4))
INSERT INTO cs VALUES ("Logged users", LTRIM(STR(m.nLogged)))

*SELECT 0
*CREATE CURSOR cc (ch C(1), asc I)
*FOR ii=1 TO LEN(cBuffer)
*    ch = SUBSTR(cBuffer, ii,1)
*    INSERT INTO cc VALUES (m.ch, ASC(m.ch))
*ENDFOR

SELECT cs
GO TOP
BROWSE NORMAL NOWAIT
* end of main

FUNCTION GetStr(nOffs)
    LOCAL nPtr, cStr, ch
    nPtr = buf2dword(SUBSTR(cBuffer, nOffs,4)) - hBuffer + 1
    cStr = ""
    DO WHILE nPtr < LEN(cBuffer)
        ch = SUBSTR(cBuffer, nPtr, 2)
        IF ch = CHR(0)+CHR(0)
            EXIT
        ENDIF
        cStr = cStr + m.ch
        nPtr = nPtr + 2
    ENDDO
    cStr = STRTRAN(cStr, CHR(0), "")
RETURN cStr

PROCEDURE decl

    DECLARE INTEGER NetWkstaGetInfo IN netapi32;
        STRING servername, LONG lvl, INTEGER @bufptr

    DECLARE INTEGER NetApiBufferFree IN netapi32 INTEGER Buffer

    DECLARE INTEGER NetApiBufferSize IN netapi32;
        INTEGER Buffer, INTEGER @ByteCount

    DECLARE RtlMoveMemory IN kernel32 As CopyMemory;
        STRING @dst, INTEGER src, INTEGER bufsize

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)



User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
2774 bytes  
Created: 2004-06-01 19:06:21  
Modified: 2004-06-01 19:08:36  
Visits in 7 days: 34  
Listed functions:
NetApiBufferFree
NetApiBufferSize
NetWkstaGetInfo
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-2018 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.6.39), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
Last Topics Visited (54.92.197.82)
13 sec.Function: 'SCardListCards'
Function group: 'Authentication'
27 sec.Function: 'mciSendCommand'
Function group: 'Windows Multimedia'
39 sec.Function: 'SetupDiGetClassImageListEx'
Function group: 'Setup API functions'
50 sec.Function: 'IsWow64Process'
Function group: 'Process and Thread'
1.03 min.
1.32 min.Function: 'CeGetSpecialFolderPath'
Function group: 'Remote Application Programming (RAPI)'
1.75 min.Function: 'AVIFileInfo'
Function group: 'Windows Multimedia'
1.97 min.Function: 'mixerGetNumDevs'
Function group: 'Windows Multimedia'
2.15 min.All Functions
2.4 min.Function: 'waveOutUnprepareHeader'
Function group: 'Windows Multimedia'
Google
Advertise here!