|
In our app we have a resource manager which used a temporariy directory in the temp folder to store data while the application is runnning.
To preserve the integrity of our data we need to prevent the deletion of this folder while the application is running.
How could I lock the directory?
I'm thinking of win32 call like LockFile/LockFileEx, but I'm not sure what argument pass to these methods.
Any tips?
|
|
|
|
|
Super Lloyd wrote: How could I lock the directory?
Make it read-only using (I think) SetFileAttributes() , or change the folder's permissions via an ACL.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
interesting, will test that....
|
|
|
|
|
See SetFileSecurity does any help?
|
|
|
|
|
This is a strange error. First time i've seen it, anyone know a way around it?
[b]
compiler limit : too many exception handler states in function 'function'. simplify function
I read http://msdn2.microsoft.com/en-us/library/673fh3hz(vs.71).aspx on MSDN's site and basically anything above 1920 is a no no. Other than making a new function or something like that, anyone have another solution? Thanx in advance!
|
|
|
|
|
Can you show the code?
Steve
|
|
|
|
|
Is this VS 2003? If so: http://support.microsoft.com/kb/884888[^].
Try breaking the function into two or more smaller functions (welcome to refactoring!) and see if that helps.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
dellthinker wrote: Other than making a new function or something like that, anyone have another solution?
Simplify expressions by assigning common subexpressions to temporary variables.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Can you show snippet code?
|
|
|
|
|
Hi, I know Visual Studio has a way to detect when the developer is entering a comment by typing '///'.
I'm currently using Visual C++ 2005 Express Edition and it does not create the comment template I was hoping for.
such that typing "///" nets something along these lines:
/**
* comment:
*
* Params:
**/
Can anyone tell me what the key combination is or where to turn it on?
Is it even available in Visual C++ 2005 XE?
Thanks in advance.
|
|
|
|
|
hi,
Is there any way to change the cursor of the container application from the activex control.
Regards,
John,
|
|
|
|
|
NOTIFYICONDATA notifyData;<br />
notifyData.cbSize = sizeof(notifyData);<br />
notifyData.hWnd = hwnd;<br />
notifyData.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE | NIF_STATE;<br />
notifyData.uCallbackMessage = MSG_STATUSICON;<br />
notifyData.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON1));<br />
::strcpy((char*)notifyData.szTip, "hello"); <-- not working<br />
::strcpy((char*)notifyData.szInfo, "blablabla");<br />
<br />
char tp [128] ;<br />
::strcpy(tp,(char*)notifyData.szTip);
<br />
Shell_NotifyIcon(NIM_ADD, ¬ifyData);
instead of hello im getting gibberish on my icon ToolTip ..long string looks like chinese.
something wrong with this line?
::strcpy((char*)notifyData.szTip, "hello");
thank you
|
|
|
|
|
Lamefif wrote: notifyData.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE | NIF_STATE;
What if you remove NIF_STATE ?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
|
Lamefif wrote: something wrong with this line?
::strcpy((char*)notifyData.szTip, "hello");
If it's a unicode build then yes, there's something wrong with that line
I would recommend NOT using casts unless you need to. Write code without the casts. If the
compiler complains, then investigate why.
For a Unicode build, that line should be something like:
// Unicode only
::wcscpy(notifyData.szTip, L"hello");
or better yet
// generic
_tcscpy(notifyData.szTip, _T("hello"));
If this is indeed the problem, had you omitted the casts to char*, the compiler would have let
you know.
Mark
-- modified at 14:23 Monday 16th July, 2007
Mark Salsbery
Microsoft MVP - Visual C++
"Great job team! Head back to base for debriefing and cocktails."
|
|
|
|
|
thank you mark
|
|
|
|
|
You're welcome
Also check out DavidCrow's reply...you are using a flag that indicates members of the struct are
valid but you didn't show those members being initialized.
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
"Great job team! Head back to base for debriefing and cocktails."
|
|
|
|
|
How to make sure the LPCRITICAL_SECTION i have is a valid one ?. ie, suppose some other thread called a DeleteCriticalSection() on the same pointer then the pointer becomes invalid and the behaviour is undefined. So how to make sure this has not happend.
|
|
|
|
|
xcavin wrote: So how to make sure this has not happend
Use good coding practices!
Thread sync objects should be managed by one object/class/thread.
Of course, you're free to code any way you want, but if this is an issue there's something
wrong
Mark
Mark Salsbery
Microsoft MVP - Visual C++
"Great job team! Head back to base for debriefing and cocktails."
|
|
|
|
|
How to make sure the LPCRITICAL_SECTION i have is valid ?
|
|
|
|
|
It's valid from the time InitializeCriticalSection() is called until DeleteCriticalSection()
is called.
It's only a structure - there's no handle or function you can use to check its validity.
It's up to you to manage its scope.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
"Great job team! Head back to base for debriefing and cocktails."
|
|
|
|
|
Mark Salsbery wrote: It's only a structure - there's no handle or function you can use to check its validity.
It's up to you to manage its scope.
From the dump using CDB i can see if its uninitialized. So was wondering if this can be done it from my program itslef so that there is no need to create dump !
|
|
|
|
|
xcavin wrote: ...see if its uninitialized.
There really shouldn't be any reason for it not to be. This falls under the realm of good programming techniques.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
DavidCrow wrote: There really shouldn't be any reason for it not to be. This falls under the realm of good programming techniques.
Sorry to be impolite
Leave the programming techniques.
My question is simple, if debugger can find it, how can it be done within my program ?
|
|
|
|
|
How does the debugger find it?
If I put the line
CRITICAL_SECTION cs;
in my code, it's uninitialized. In a debug build at runtime, the entire struct is filled with
0xCC bytes. The only way I see to check for validity is initialize the struct to some values that
can never occur when the CS is initialized.
Maybe:
CRITICAL_SECTION cs;
memset(&cs, 0xFF, sizeof(CRITICAL_SECTION));
It's hard to "Leave the programming techniques" when this shouldn't be an issue if it's used
properly.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
"Great job team! Head back to base for debriefing and cocktails."
|
|
|
|