?
Solved

File attribute

Posted on 2003-03-11
4
Medium Priority
?
1,435 Views
Last Modified: 2013-12-26
How to get and change a file attribute from Powerbuilder?
0
Comment
Question by:magotici
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 5

Expert Comment

by:buasuwan
ID: 8112126
You need an External Function to get file attributes.

first, declare an External Function.

Function long GetFileAttributes (string lpFileName) Library "kernel32" Alias for "GetFileAttributesA"

second, some constants.

Constant long FILE_ATTRIBUTE_ARCHIVE = 32
Constant long FILE_ATTRIBUTE_COMPRESSED = 2048
Constant long FILE_ATTRIBUTE_DIRECTORY = 16
Constant long FILE_ATTRIBUTE_HIDDEN = 2
Constant long FILE_ATTRIBUTE_NORMAL = 128
Constant long FILE_ATTRIBUTE_READONLY = 1
Constant long FILE_ATTRIBUTE_SYSTEM = 4
Constant long FILE_ATTRIBUTE_TEMPORARY = 256

and then codes,

long     ll_attributes
ll_attributes = GetFileAttributes("C:\AUTOEXEC.BAT")

ll_atttibutes contains attributes of above constants.

and,
this sample codes for checking that file has ARCHIVE attribute or not.

long     ll_bit

ll_bit = mod(ll_attributes, FILE_ATTRIBUTE_ARCHIVE * 2) / FILE_ATTRIBUTE_ARCHIVE

ll_bit = 1, an archive file
ll_bit = 0, not archive file.

and you can change parameter to test other attribute that you want.


0
 

Author Comment

by:magotici
ID: 8112353
Thank you.
And how to change an attribute?
Manuel
0
 
LVL 5

Accepted Solution

by:
buasuwan earned 200 total points
ID: 8112516
and setting file attributes,
you need more function.

Function boolean SetFileAttributes(string lpFileName, long dwFileAttributes) Library "kernel32" Alias for "SetFileAttributesA"

and script is,

boolean lb_result
lb_result = SetFileAttributes("C:\AUTOEXEC.BAT", FILE_ATTRIBUTE_READONLY)



0
 
LVL 5

Expert Comment

by:buasuwan
ID: 8112539
or

boolean lb_result
lb_result = SetFileAttributes("C:\AUTOEXEC.BAT", FILE_ATTRIBUTE_READONLY + FILE_ATTRIBUTE_ARCHIVE )
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question