Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Retrieveing information about the active window (even if it is not owned by the calling process)
Retrieving information about the main VFP window
Using the GetTempFileName
Using vendor-neutral SQL constructs
Verifying a file using the Authenticode policy provider
A procedure for setting file times
Comparing dimensions of the VFP main window with _SCREEN properties
Copying strings through the global memory block
Enumerating MIDI output devices
Finding the path to the VFP executable running
GDI+: Storing DLL icon resources in image files
How to download this reference`s archive through WinInet functions using InternetOpenUrl
How to view system icons for the classes installed on the local machine
Obtaining physical parameters for a drive: sectors, clusters, cylinders...
Obtaining Shell32.dll version
Retrieving the name of the primary domain controller (PDC) and join status information (NT/2000/XP)
Enumerating ODBC Data Sources available on the local computer
GDI+: Color Transparency
Obtaining heap handles and enumerating memory blocks for the current VFP session (WinNT only)
Obtaining OS memory performance information
Pocket PC: Folder Viewer
Returning some basic information for the specified INF file
Current keyboard type
Obtaining names of local and global groups for current user (WinNT/XP/2K)
Adding and deleting User Accounts

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
Versions:
click to open
Before you begin:
The class below wraps NetUserAdd, NetUserDel, NetUserGetInfo and NetUserSetInfo API calls with methods that can add, delete and modify user accounts on a server.

Use another example, Obtaining information about all user accounts on a server, to review the user accounts.
 
  Members area. Log in to view this example.
 
  User name:
  Password:
 
 
  Forgot your password?
 
  Sign up for
the Membership
 
 


User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
7151 bytes  
Created: 2005-02-07 19:34:02  
Modified: 2011-12-10 09:20:22  
Visits in 7 days: 88  
Listed functions:
GlobalAlloc
GlobalFree
GlobalSize
NetApiBufferFree
NetApiBufferSize
NetUserAdd
NetUserDel
NetUserGetInfo
NetUserSetInfo
Printer friendly API declarations
My comment:
In VFP versions 3 to 6 you may have to declare RtlMoveMemory as MemToStr and StrToMem not once but every time you call this function with either interface. Newer VFP versions allow at least two API declarations exist simultaneously.

Use this program code to test the class. Replace "MyServer" with an empty string to access user accounts on the local computer.
#DEFINE ERROR_ACCESS_DENIED 5
#DEFINE ERROR_BAD_NETPATH 53
#DEFINE NERR_UserNotFound 2221
#DEFINE NERR_UserExists 2224

LOCAL oUser As UserAccount
oUser = CREATEOBJECT("UserAccount", "MyServer", "FoxApp")

DO CASE

CASE oUser.errorcode = 0
        = MESSAGEBOX("User account " + oUser.GetUsername() +;
                " exists on " + oUser.GetServername() + ". ",;
                64, VERSION())

CASE oUser.errorcode = ERROR_BAD_NETPATH
        = MESSAGEBOX("Server " + oUser.GetServername() +;
                " not found or can not be accessed. ",;
                48, VERSION())

CASE oUser.errorcode = ERROR_ACCESS_DENIED
        = MESSAGEBOX("Access denied to Network " +;
                "Management Functions on " +;
                oUser.GetServername() +;
                ". ", 48, VERSION())

CASE oUser.errorcode = NERR_UserNotFound
        nSelect = MESSAGEBOX("User account " +;
                oUser.GetUsername() +;
                " not found on " + oUser.GetServername() + ". " +;
                CHR(13)+CHR(13) +;
                "Do you want to add this account? ",;
                32+4+256, VERSION())

        IF nSelect = 6
                IF oUser.UserAdd()
                        = MESSAGEBOX("User account " +;
                                oUser.GetUsername() +;
                                " added on " +;
                                oUser.GetServername() + ". ",;
                                64, VERSION())
                ELSE
                        = MESSAGEBOX("Method UserAdd " +;
                                "failed with error code " +;
                                TRANSFORM(oUser.errorcode) + ". ",;
                                48, VERSION())
                ENDIF
        ENDIF
ENDCASE

IF oUser.UserExists()
        oUser.SetComment("Temporary account. Delete after the testing.")
*        oUser.UserDel
ENDIF

* * *
Read an article HOW TO: Add a User to the Local System by Using Directory Services and Visual C# .NET on Microsoft Help and Support web site.
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 (107.22.25.119)
35.38 min.Function: 'SetMapMode'
35.48 min.Function: 'FindText'
Function group: 'Common Dialog Box'
1.9 hrs.Function: 'GetInterfaceInfo'
Function group: 'IP Helper'
3.27 hrs.Example: 'How to Start a Process as Another User (NT/XP/2K)'
 Example: 'Using Change Notification Objects to monitor changes to the printer or print server'
5.58 hrs.Example: 'Converting path to original case'
 Example: 'Enumerating ODBC drivers available on the local computer'
8.07 hrs.Example: 'Initiating Inet connection using a modem'
 Example: 'Retrieving the name and type of all available RAS-capable devices'
8.53 hrs.Example: 'How to intercept window messages sent to VFP form'
Google
Advertise here!