|
I want set a file,eg.test.txt,with read only and hide attribute,How can ido?
Thank you!
|
|
|
|
|
SetFileAttributes
The SetFileAttributes function sets a file's attributes.
BOOL SetFileAttributes(
LPCTSTR lpFileName, // file name
DWORD dwFileAttributes // attributes
);
Parameters
lpFileName
[in] Pointer to a string that specifies the name of the file whose attributes are to be set.
Windows NT/2000: In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to nearly 32,000 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. For more information, see File Name Conventions.
Windows 95/98: This string must not exceed MAX_PATH characters.
dwFileAttributes
[in] Specifies the file attributes to set for the file. This parameter can be one or more of the following values. However, all other values override FILE_ATTRIBUTE_NORMAL. Attribute Meaning
FILE_ATTRIBUTE_ARCHIVE The file is an archive file. Applications use this attribute to mark files for backup or removal.
FILE_ATTRIBUTE_HIDDEN The file is hidden. It is not included in an ordinary directory listing.
FILE_ATTRIBUTE_NORMAL The file has no other attributes set. This attribute is valid only if used alone.
FILE_ATTRIBUTE_NOT_CONTENT_INDEXED The file will not be indexed by the content indexing service.
FILE_ATTRIBUTE_OFFLINE The data of the file is not immediately available. This attribute indicates that the file data has been physically moved to offline storage. This attribute is used by Remote Storage, the hierarchical storage management software in Windows 2000. Applications should not arbitrarily change this attribute.
FILE_ATTRIBUTE_READONLY The file is read-only. Applications can read the file but cannot write to it or delete it.
FILE_ATTRIBUTE_SYSTEM The file is part of the operating system or is used exclusively by it.
FILE_ATTRIBUTE_TEMPORARY The file is being used for temporary storage. File systems attempt to keep all of the data in memory for quicker access rather than flushing the data back to mass storage. A temporary file should be deleted by the application as soon as it is no longer needed.
Return Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Remarks
The following table describes how to set the attributes that cannot be set using SetFileAttributes.
Attribute How to Set
FILE_ATTRIBUTE_COMPRESSED To set a file's compression state, use the DeviceIoControl function with the FSCTL_SET_COMPRESSION operation.
FILE_ATTRIBUTE_DEVICE Reserved; do not use.
FILE_ATTRIBUTE_DIRECTORY Files cannot be converted into directories. To create a directory, use the CreateDirectory or CreateDirectoryEx function.
FILE_ATTRIBUTE_ENCRYPTED To create an encrypted file, use the CreateFile function with the FILE_ATTRIBUTE_ENCRYPTED attribute. To convert an existing file into an encrypted file, use the EncryptFile function.
FILE_ATTRIBUTE_REPARSE_POINT To associate a reparse point with a file, use the DeviceIoControl function with the FSCTL_SET_REPARSE_POINT operation.
FILE_ATTRIBUTE_SPARSE_FILE To set a file's sparse attribute, use the DeviceIoControl function with the FSCTL_SET_SPARSE operation.
Requirements
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Requires Windows 95 or later.
Header: Declared in Winbase.h; include Windows.h.
Library: Use Kernel32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000.
Thinking in difference!
|
|
|
|
|
|
How do you handle a click or a double click of the title bar? I've tried adding WM_LBUTTONDOWN and WM_LBUTTONDBCLK but they were never called when the user clicked on the titlebar.
-Raffi
|
|
|
|
|
Try WM_NCLBUTTONDOWN and WM_NCLBUTTONDBLCLK .
---
Shog9
If I could sleep forever, I could forget about everything...
|
|
|
|
|
|
Yeah, good point.
---
Shog9
If I could sleep forever, I could forget about everything...
|
|
|
|
|
How do you add them. Neither is in the class wizard, and I've tried manually writing them in but they never get called.
I've tried puttingON_WM_NCLBUTTONDOWN() in the cpp, afx_msg void OnNcLButtonDown( UINT nHitTest, CPoint point); in the header, and I added the function to the cpp, but it never gets called. Why doesn't it work?
|
|
|
|
|
What sort of a window is this?
---
Shog9
If I could sleep forever, I could forget about everything...
|
|
|
|
|
Child window of an MDI.
-Raffi
|
|
|
|
|
Raffi wrote:
Child window of an MDI.
A direct child of the MDI client window, or a view? If it's a view, then it doesn't have a title bar of it's own, so you're not going to get the messages that way.
---
Shog9
If I could sleep forever, I could forget about everything...
|
|
|
|
|
Ahh, I had it in the view, got it working now, Thanks a lot
-Raffi
|
|
|
|
|
Hi,
I'm just a beginner with C++. I'm using the MS Visual Studio 6.
I would like to write a small .exe file that will copy backups of .ini files for a game, over the existing ones. This is to prevent other guys from changing my settings.
How the copying part in C++ is done, is not a problem. But I can't figure out how to start up the game.exe from within the small prog that I'm working on.
The small .exe file should also quit running after the game.exe is executed.
I'll guess it would be easy to just make a BAT file to handle it all, but then I wouldn't learn anything about C++ by doing so.
Anyone out there who got a clue or a small codesample to hand over?
Best regards, Peter
|
|
|
|
|
Look up CreateProcess in MSDN. That is the call to use to launch another program.
|
|
|
|
|
Try ShellExecute then end the program. exit in a console app
good luck,
Bill
|
|
|
|
|
Thank you, both of you guys!
I tryed to read the MSDN just after I read your suggestions, but as I'm quite new on C++ it turned out to be too technical for my right now. The compiler didn't swallow my attempts that I tryed 5 minutes ago.
I found out that it is easier to learn something complete knew by studying existing examples. Is there any codesample out there which I can play around with?
Best regards, Peter
|
|
|
|
|
|
Dear Nishant S,
To avoid wasting bandwith on this excellent discussion forum, I've emailed you some further questions.
Regards,
Peter
|
|
|
|
|
Anonymous wrote:
To avoid wasting bandwith on this excellent discussion forum, I've emailed you some further questions.
Please post your questions in the forum, because then other people will also be able to help you. I usually don't answer to direct emails and often don't even read them. I already have a problem keeping my mail organized. And the big advantage of asking questions in the forums is that the answers will remain there for other people to see in future if they run into the same problems.
Regards,
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
Okay, I'm trying to load the raw data of a resource of a custom type. I've named the type "JPG" and have created a resource with the ID "IDR_JPG1". The resource is located within the executable. The code that I've come up with is:
char* pData = 0;
HRSRC hRsrc;
HGLOBAL hGlobal;
DWORD dWord;
hRsrc = FindResource( NULL, ?, RT_RCDATA );
dWord = GetLastError(); // Produces 1813 (ERROR_RESOURCE_TYPE_NOT_FOUND)
hGlobal = LoadResource( NULL, hRsrc );
pData = (char*)LockResource( hGlobal );
I have no idea what I need to be putting in place of the question mark. The MSDN Library provides only unclear and essentially useless information. Also, I'm a little uneasy about locking up a resource and not releasing it. Do I need to release it? There is a FreeResource function but I'm told that it is depricated. I'd appreciate any info you could send my way.
|
|
|
|
|
Okay, to answer my own question . . .
hRsrc = FindResource( NULL, MAKEINTRESOURCE( IDR_JPG1 ), "JPG" );
Corrects the problem
|
|
|
|
|
Hello,
I am trying to force regedit to export a version 4 .REG file instead of version 5. This is an option in regedit, however I am using the command line
regedit /e filename destination to do my backup. I have searched msdn and other places looking for documentation on what arguments can be passed here to force a regedit 4 export, but have had no luck at all. Does anybody have any experience with this, or know where I can look for some documentation??
Thanks
Is it football season yet?
|
|
|
|
|
I've got an MDI MFC app.
(Irrelevant info in parentheses probably: I have a database class(built from ADO) )
An object 'db' is declared in view1. It opens a database which has to stay open while the program is running. Now I want to run one of the functions of db, in view2. View2 transmits a piece of information that is to be used in the argument list of the function. I need to use the same object, so I cant create a new one (cant open an already open database connection). What is the best mechanism to do this?
I was wondering about:
I only have two views and this tactic worked when I did a sendmessage from view2 to view1. But in the dropdown intellisense after doing pView-> I saw only the names of functions and didnt know if I could get to the db object as above.
Please let me know.
Thank you very much,
ns
The above snippet said that db was not a member of CView. I tried forcing it to be CTrain1View * (totally wrong I know) but was not acceptable to the compiler either.
Do I have to go via Doc variables and a sendMessage?
|
|
|
|
|
ns wrote:
An object 'db' is declared in view1. It opens a database which has to stay open while the program is running.
What stopped you from including 'db' in CYourDoc?
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
It didnt want to do simple recordset functions like get record count etc. It bombed if I made it a doc object because the constructor creates all the objects like command and recordset etc. Thats why I put it in the View....
Thanks,
ns
|
|
|
|