Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Reading security permissions for NTFS files and folders
A client for testing non-blocking Winsock server
Changing pitch and speed of a wave file
How to make a VFP form fading out when released (GDI+ version)
How to view icons stored in executable files (Icon Viewer)
Creating irregularly shaped FoxPro form using transparency color key
Drawing standard Windows icons
Extended MessageBox Class
Using InternetSetFilePointer when resuming interrupted download from the Internet
Yet another modal dialog: now HTML-based
Customizing the frame of top-level form: removing the standard frame (VFP9, Vista)
Exporting DLL icon resources as .ICO files
Displaying hypertext links with the SysLink control (VFP9, Comctl32.dll)
GDI+: copying to the Clipboard (a) image of active FoxPro window/form, (b) image file
Mapping and disconnecting network drives
Obtaining a handle to the desktop associated with the calling thread
Obtaining MAC address through Address Resolution Protocol (ARP) request
Setting the date and time that a file was created
Using Change Notification Objects to monitor changes to the printer or print server
Drawing Windows predefined bitmaps using the LoadBitmap functions
How to block the PrintScreen key
Playing WAV files on InteractiveChange
Retrieving the name of the primary domain controller (PDC) and join status information
Start an executable from VFP application by using the CreateProcess
Reading security permissions for NTFS files and folders

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:
This code sample includes a set of classes implementing several NTFS access control objects. Through these objects, like Access Control List (ACL) and Access Control Entry (ACE) and others, the OS defines access rights to files, folders (in particular) for different users and user groups.

The most familiar interface around NTFS access control objects is shown on the picture below.

An output from the code sample looks much simpler. It retrieves Security Identifiers (SID) for all accounts having allowed/denied access rights to the specified file.

The code also obtains Type, Flags and Mask values for each ACE. These values define access rights and properties like reading, writing, accessing attributes, taking ownership, inheritance and others.

  Members area. Log in to view this example.
  User name:
  Forgot your password?
  Sign up for
the Membership

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
6728 bytes  
Created: 2006-05-30 10:48:23  
Modified: 2006-05-30 11:14:12  
Visits in 7 days: 117  
Listed functions:
Printer friendly API declarations
My comment:
Read also:
Understanding Windows NTFS Permissions, by Derek Melber.

* * *
As you know, VFP strings are widely used instead of pointers in many API calls. Here is an example of GetFileSecurity API function being declared and called using such string as the third parameter passed by reference.

DECLARE INTEGER GetFileSecurity IN advapi32;
        STRING lpFileName, INTEGER RequestedInformation,;
        STRING @pSecurityDescriptor, INTEGER nLength,;
        INTEGER @lpnLengthNeeded

LOCAL cDescriptor, nBufsize
cDescriptor=REPLICATE(Chr(0), 256)

        @cDescriptor, LEN(cDescriptor), @nBufsize)

The code returns no error and the cDescriptor contains meaningful data on exit. But under certain circumstances, the cDescriptor fails while used in subsequent API calls like, for instance, GetSecurityDescriptorDacl.

I have found it far more reliable for this particular function to be declared with pSecurityDescriptor parameter set as Integer.

DECLARE INTEGER GetFileSecurity IN advapi32;
        STRING lpFileName, INTEGER RequestedInformation,;
        INTEGER pSecurityDescriptor, INTEGER nLength,;
        INTEGER @lpnLengthNeeded

Of course, it adds some extra code before and after the call. A memory block must be allocated and eventually released. A very simple LocalMem class handles this with no glitch.
Word Index links for this example:
Translate this page:
  Spanish    Portuguese    German    French    Italian offers instant, free translations of text or web pages.
User Contributed Notes:
Walter | 2007-12-13 13:08:00
Hi, How can i get permission information from a file or folder which belongs to the current user?
Walter | 2007-12-13 19:47:18
How I can know if my user has write permission on a folder?

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 (
26 sec.Function: 'SQLInstallerError'
Function group: 'ODBC API'
36 sec.Function: '_lopen'
Function group: 'File Management'
47 sec.Function: 'EnumPrintProcessorDatatypes'
Function group: 'Printing and Print Spooler'
59 sec.Function: 'listen'
Function group: 'Windows Sockets 2 (Winsock)'
1.13 min.Examples
1.32 min.Function: 'NetWkstaUserEnum'
Function group: 'Network Management'
1.52 min.Function: 'PathIsURL'
Function group: 'Shell Lightweight Utility APIs -- Path Functions'
1.67 min.Function: 'CeEnumDBVolumes'
Function group: 'Remote Application Programming (RAPI)'
1.87 min.Function: 'NetUserGetLocalGroups'
Function group: 'Network Management'
2.07 min.Function: 'GdipGetImageWidth'
Function group: 'GDI+ Image'
Advertise here!