Hi.

(I am using Windows XP)

I would like to know how you can use the function SetFileAttributes to hide a file or folder, I would also like to know about the declarations associated with this function. I would like to use this to develop a program that hides program files that should be kept out of sight in order to prevent them deleting any important files. Is it possible to run this function on the users computer?

Thank you.

> ... develop a program that hides program files that should be kept out of sight in order to prevent them deleting any important files.
what right do you have to try to prevent users from deleting files on *their* computers?
to protect users from accidental deletion or overwrite, set the read only attribute.
http://msdn2.microsoft.com/en-us/library/aa365522(VS.85).aspx

Hi.

(I am using Windows XP)

I would like to know how you can use the function SetFileAttributes to hide a file or folder, I would also like to know about the declarations associated with this function. I would like to use this to develop a program that hides program files that should be kept out of sight in order to prevent them deleting any important files. Is it possible to run this function on the users computer?

Thank you.

Definition:

BOOL SetFileAttributes(LPCTSTR lpFileName, DWORD dwFileAttributes);

dwFileAttributes can take these parametres:

FILE_ATTRIBUTE_ARCHIVE
FILE_ATTRIBUTE_COMPRESSED
FILE_ATTRIBUTE_DIRECTORY
FILE_ATTRIBUTE_ENCRYPTED//file is crypted)
FILE_ATTRIBUTE_HIDDEN
FILE_ATTRIBUTE_NORMAL
FILE_ATTRIBUTE_NOT_CONTENT_INDEXED
FILE_ATTRIBUTE_OFFLINE//don't change this attribute
FILE_ATTRIBUTE_READONLY
FILE_ATTRIBUTE_SYSTEM
FILE_ATTRIBUTE_TEMPORARY

Return value is not 0, 0 is an error.

Also see a function GetFileAttributes.

I get the error main must return int, what I am doing wrong?

Type your code.

Your main() is not returning an int, maybe nothing at all or something else, so ..

int main(int argc, char * argv[])
{
    // your code here

    // return some integer value, in this case zero ...
    return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.