Using Win32 functions in Visual FoxPro Image Gallery
Network Management
..msdn
NetApiBufferFree
NetApiBufferSize
NetConnectionEnum
NetFileClose
NetFileEnum
NetFileGetInfo
NetGetDCName
NetGroupEnum
NetLocalGroupEnum
NetMessageBufferSend
NetMessageNameAdd
NetMessageNameDel
NetMessageNameEnum
NetScheduleJobAdd
NetScheduleJobDel
NetScheduleJobEnum
NetServerEnum
NetServerGetInfo
NetSessionEnum
NetShareAdd
NetShareDel
NetShareEnum
NetShareSetInfo
NetUserAdd
NetUserChangePassword
NetUserDel
NetUserEnum
NetUserGetGroups
NetUserGetInfo
NetUserGetLocalGroups
NetUserSetInfo
NetWkstaGetInfo
NetWkstaTransportEnum
NetWkstaUserEnum
Code examples:
Adding and deleting Scheduled Tasks using NetScheduleJob API functions
Adding and deleting User Accounts
Enumerating global and local group accounts on a server (WinNT/XP/2K)
Enumerating network sessions established on a server
Finding out if the current user is the Guest account
How to enumerate, add and delete shares on the local computer (WinNT/XP)
Obtaining names of local and global groups for current user (WinNT/XP/2K)
Retrieving configuration information for the specified server (Win2000/XP)
Retrieving configuration information for the specified workstation (Win2000/XP)
Retrieving the name of the primary domain controller (PDC) and join status information
Using NetWkstaTransportEnum to obtain MAC Address of remote server
Using the NetMessageBufferSend to send messages on the network
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: 90  
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-2017 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.38), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
Last Topics Visited (54.147.40.153)
16 sec.Function: 'CeFindFirstDatabaseEx'
Function group: 'Remote Application Programming (RAPI)'
32 sec.Example: 'Obtaining names of local and global groups for current user (WinNT/XP/2K)'
46 sec.
Function group: 'Windows Sockets 2 (Winsock)'
1.05 min.All Functions
1.32 min.Function: 'GetEnvironmentVariable'
Function group: 'Process and Thread'
1.62 min.
Function group: 'Pipe'
1.9 min.Function: 'AVIFileOpen'
Function group: 'Windows Multimedia'
2.43 min.Project
2.7 min.Function: 'CeDeleteFile'
Function group: 'Remote Application Programming (RAPI)'
2.97 min.Function: 'waveOutOpen'
Function group: 'Windows Multimedia'
Google
Advertise here!