Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to view icons stored in executable files (Icon Viewer) - II
Using custom Simple MapiSendMail class
Winsock: changing the byte ordering
Changing file attributes
Clipping mouse cursor area
Creating an Open dialog box to specify the drive, directory, and name of a file to open (Shell32 version)
Displaying OS Memory Status
Enhanced GetFont dialog
How to view system icons for the classes installed on the local machine
Memory usage info for current VFP session (WinNT only)
Passing data records between VFP applications via the Clipboard
Reading and setting Environment variables
Reading the structure of VFP main menu
Running a regular FoxPro form while main VFP window is minimized
Saving available locale records into a cursor
Setting the volume label
The window and its ancestors
Time in milliseconds represented as string (e.g. 1 hour 24 min 36 sec)
Using Path functions from Shell Lightweight Utility APIs (shlapi.dll)
Using the SetErrorMode for determining if a floppy drive is ready
Winsock: retrieving the host information corresponding to a network address
Comparing file times
Configuring DEVMODE structure for a printer
Connecting a local device to a network resource
Changing file attributes

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
LPARAMETERS  lpFileName

#DEFINE FILE_ATTRIBUTE_READONLY       1  
#DEFINE FILE_ATTRIBUTE_HIDDEN         2  
#DEFINE FILE_ATTRIBUTE_SYSTEM         4  
#DEFINE FILE_ATTRIBUTE_DIRECTORY     16  
#DEFINE FILE_ATTRIBUTE_ARCHIVE       32  
#DEFINE FILE_ATTRIBUTE_NORMAL       128  
#DEFINE FILE_ATTRIBUTE_TEMPORARY    512  
#DEFINE FILE_ATTRIBUTE_COMPRESSED  2048  

DECLARE SHORT SetFileAttributes IN kernel32;
    STRING lpFileName, INTEGER dwFileAttributes

DECLARE INTEGER GetFileAttributes IN kernel32 STRING lpFileName 

* read current attributes for this file
dwFileAttributes = GetFileAttributes (lpFileName)

IF dwFileAttributes = -1
* the file does not exist
    RETURN
ENDIF

IF dwFileAttributes > 0
    * read-only attribute to be set
    dwFileAttributes = BitOr(dwFileAttributes, FILE_ATTRIBUTE_READONLY)

    * archive attribute to be removed
    IF BitAnd(dwFileAttributes, FILE_ATTRIBUTE_ARCHIVE) = FILE_ATTRIBUTE_ARCHIVE
        dwFileAttributes = dwFileAttributes - FILE_ATTRIBUTE_ARCHIVE
    ENDIF

    * setting selected attributes
    = SetFileAttributes (lpFileName, dwFileAttributes)
ENDIF


User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
1120 bytes  
Created: 2001-08-14 12:00:00  
Modified: 2007-08-02 14:45:37  
Visits in 7 days: 47  
Listed functions:
GetFileAttributes
SetFileAttributes
Printer friendly API declarations
My comment:
Pass a file name to this procedure. This code sets read-only and clears archive attributes for the selected file.

DOS command ATTRIB can be used for the same purpose:
ATTRIB -R c:\mydir\*.* /S
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-2014 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.68), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
Last Topics Visited (54.226.213.228)
4 sec.Function: 'GetTextFace'
6 sec.Example: 'How to retrieve number of objects in the Recycle Bin'
13.93 hrs.Function: 'CopyIcon'
13.94 hrs.Function: 'timeGetDevCaps'
Function group: 'Windows Multimedia'
 Function: 'CryptDestroyKey'
Function group: 'Cryptography Reference'
 Function: 'WNetGetProviderName'
Function group: 'Windows Networking'
 Example: 'Retrieving graphic capabilities of your display'
3 day(s)Example: 'Shortcut Menu Class'
 Function: 'Escape'
Function group: 'Printing and Print Spooler'
 Solution: 'ContextMenu ActiveX Control'
Google
Advertise here!