Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Quering a waveform-audio input device
Compressing and decompressing files with Windows API Runtime Library routines
How to display the Properties dialog box for a file (ShellExecuteEx)
How to retrieve list of system DSNs (Data Source Name) with parameters
Placing an arbitrary rectangular area of main VFP window on the Clipboard
The DetectAutoProxyUrl function identifies the auto-config script location
Displaying printer-properties Property Sheet for the specified printer
Opening the Page Setup dialog box to specify the attributes of a printed page
Pocket PC: custom RAPI class for operating with files and folders on mobile device
Subclassing CommandButton control to create BackColor property
Adding a background image to VFP report (VFP9, ReportListener)
Class for sound recording
Disconnecting USB Mass Storage Device programmatically
GetFocus returns a HWND value
How to enumerate terminal servers within the specified Windows domain
Start an executable from VFP application by using the CreateProcess
GDI+: sending image of FoxPro form to printer
How to display the port-configuration dialog box for a port on the specified server
How to obtain the number of rows affected by remote UPDATE, INSERT or DELETE statement
Pocket PC: custom RAPI class for operating with the System Registry
Retrieving current settings for an ODBC connection
Scanning the hierarchy of child windows down from the main VFP window
GDI+: retrieving list of available image encoders and image decoders
How to display a dialog box with which the user can add a data source (DSN)
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: 83  
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-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)
3.69 hrs.Example: 'Retrieving the priority class for the current process'
 Example: 'Retrieving the name of the network resource associated with a local device'
11.01 hrs.Example: 'Custom HttpRequest class (WinHTTP)'
 Example: 'Playing WAV sounds simultaneously'
14.1 hrs.Example: 'Storing the environment strings in cursor'
18.17 hrs.Example: 'Obtaining some properties for the Windows desktop using the GetWindowPlacement function'
18.18 hrs.Function: 'GetKeyNameText'
Function group: 'Keyboard Input'
18.32 hrs.Function: 'WNetGetConnection'
 Function: 'SetClipboardViewer'
19.12 hrs.Example: 'An alternative way of setting Form.Closable to False'
Google
Advertise here!