|
Changing file attributes for a file is no problem (e.g. using the SetFileAttributes() function).
Is there an equivalent for doing this for a directory?
Thanks in advance, hfr
PS: if using SetFileAttributes() for a directory I get a HRESULT of 2 which means: file not found
|
|
|
|
|
This works for me:
if (! SetFileAttributes("c:\\ResOrg", FILE_ATTRIBUTE_READONLY))
{
DWORD dwError = GetLastError();
}
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Hi thanks for your reply!
Sorry, I was a bit inaccurately...
I am using RAPI version of SetFileAttributes() --> CeSetFileAttributes() because I need to do this on a remote device (on a Pocket PC running Windows CE)
It seems that there is a difference between SetFileAttributes() and CeSetFileAttributes().
CeSetFileAttributes() works fine for files but not for directories. The only thing I have found about this issue is that the .NET Compact Framework does not support changing attributes on directories... (files are supported).
Since the project is written in VC++ this should not matter...
CeSetFileAttributes() always returns false and CeGetLastError() returns 0x2 (file not found...)
Any idea why CeSetFileAttributes() does not work for directories?
thx
|
|
|
|
|
rubicon_hfr wrote:
Any idea why CeSetFileAttributes() does not work for directories?
No. I've no experience with CE or the .Net framework. What folder attribute are you wanting to alter? If I am reading the documentation correctly, it states that an application cannot change the attributes of a directory in the RAM file system. Does that apply to your situation?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I assume you mean ROM, not RAM?
Of course I do not try to alter attributes of a directory which is located in ROM. In this case I'll expect a "access denied" error...
I'd like to change directory's attributes which are located in RAM or on a storage card.
I can delete or rename the directories but I cannot change the "r" or "h" attribute...
|
|
|
|
|
rubicon_hfr wrote:
I assume you mean ROM, not RAM?
No, RAM was the intended word. See here.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Very interesting... thx!
This code (see comments) demonstrates what happens:
<br />
CeRapiInit();<br />
<br />
CString strFileName = "\\SD-MMCard\\Temp";<br />
<br />
wchar_t wcFileName[256];<br />
mbstowcs(wcFileName, strFileName, strFileName.GetLength()+1);<br />
<br />
DWORD dwAttributes = CeGetFileAttributes(wcFileName);
HRESULT hr = CeGetLastError();<br />
<br />
dwAttributes |= FILE_ATTRIBUTE_READONLY;<br />
<br />
CeSetFileAttributes(wcFileName, dwAttributes);<br />
hr = CeGetLastError();<br />
<br />
CeRapiUninit();<br />
RAM: "The system cannot find the file specified." (ok, since MSDN says it is not supported
Storage Cards: "Access is denied." (also not supported? )
|
|
|
|
|
FYI: Conclusion - setting file attributes for directories
I tried something and here are the results:
CeGetFileAttributes()
Worked for all devices.
CeSetFileAttributes()
Not worked on a PPC2002 device (Pocket PC)
Worked on a WM2003 device (Smartphone)
So it seems that this is only supported for devices using WM2003 or higner...
|
|
|
|
|
I want to find a working Dynamic time warping algorithm in c++ to compare voice.
|
|
|
|
|
......
char* p= new char[100];
...
//should I use
// delete p;
//or
// delete[] p;
|
|
|
|
|
delete[]
new -> delete
new[] -> delete[]
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
I'd like to stress PJ's point that you should *always* use delete [] with new []. Otherwise strange things will happen. Trust me.
--
Schni Schna Schnappi! Schnappi Schnappi Schnapp!
|
|
|
|
|
|
I allways used delete regardless if used new or new[]
...it worked fine (and I see no reason why it should not...)
<br />
byte buffer[4] = new byte[4];
DWORD dw4Bytes = new DWORD[1];
<br />
...<br />
<br />
delete buffer;
delete dw4Bytes;
|
|
|
|
|
rubicon_hfr wrote:
...it worked fine (and I see no reason why it should not...)
Because for one thing, your example is not exception-safe. If in the "..." code an exception is thrown, you'll end up with a memory leak.
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
|
|
|
|
|
Because for one thing, your example is not exception-safe. If in the "..." code an exception is thrown, you'll end up with a memory leak.
Since the topic has the subject "about delete" I only mention that there is no difference between delete and delete[].
You may assume that "..." stands for the following:
<br />
try<br />
{<br />
}<br />
catch (...)<br />
{<br />
}<br />
Of course you can use finally to free memory...
Or you just use a wrapper class which ctor does this for you (so you can't forget)...
Or use managed C++
|
|
|
|
|
at least to an extent were its working took me 30min - 1hr to write it, had 1 bug but fixed it with debugging in under 3 sec. flat!!! so exciting but I came across a wierd error, when i just used "D3DXVECTOR3(x, y, 0)" in one of the location parameters in the ID3DXSPRITE interface, Draw() to be exact, it wouldn't accept it, but then i tried "&D3DXVECTOR3(x, y, 0)" and it worked, what am i misunderstanding here, D3DXVECTOR3 is type struct by the way
IM PROUD TO BE A GMAIL;
|
|
|
|
|
tom_dx wrote:
but then i tried "&D3DXVECTOR3(x, y, 0)" and it worked, what am i misunderstanding here, D3DXVECTOR3 is type struct by the way
Simple, a struct is completely different to a pointer.
tom_dx wrote:
IM PROUD TO BE A GMAIL;
So was I, until my mail started to disappear.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
whoops have to break out my C++ reference
IM PROUD TO BE A GMAIL;
|
|
|
|
|
I need something like Microsoft MonthView Control v6.0 (from mscomct2.ocx) but with the ability to select non-contiguous dates, too.
Thank you,
DC
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
|
Thanks. It's hard to tell without a sample executable to play around with. Do you know if the dates can be navigated with the arrow keys on the keyboard?
- DC
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
|
I have working with CHtmlView derived SDI application.
Want to catch Event when user select print menu . do some processing like display a message box ..and then continuing printing ..How can I do it ..is it possible with OnCmdMsg() ..if yes How
|
|
|
|
|
Look for Virtual Function [CView::OnPreparePrinting]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|