|
what is the best way to check to make sure a person does not have read only access to a folder?
also this folder may get alot of files in it over a period of time, is there a way to make sure i dont go over the limit of files in a folder? or to check if they have more than 100 files and if so delete files older than a month or so?
just looking for directions, dont need exact code.. thanks for the help!
-dz
|
|
|
|
|
Every directory supports a nul file name. I think this is leftovers from the DOS days, and its strong imitation of *nix. So you can attempt to open a file for write access to Drive:\Directory\nul and see if that works. If it does, your user has the "write" right to the directory. No file will ever be created, because nul is a big black hole.
As for checking for old files, if you're using MFC you can use the CFileFind class to iterate through all of the current files in any given directory. There is a function of CFileFind called GetLastWriteTime() that will tell you the last time it was modified. Take the CTime that function gives you, a CTime::GetCurrentTime() and combine it with a CTimeSpan to compare them. It's not very intuitive, so here's some sample code
<code>
const int cNumDays = 30;
CFileFind fFinder;
CTime tCurrent = CTime::GetCurrentTime();
CTime tFile;
CTime tCompare;
BOOL bWorking = fFinder.FindFile( "c:\\mydirectory\\*.*" );
while( bWorking )
{
bWorking = fFinder.FindNextFile();
if( !fFinder.IsDirectory() && !fFinder.IsDots() )
{
fFinder.GetLastWriteTime( tFile );
tCompare = tFile + CTimeSpan( cNumDays, 0, 0, 0 );
if( tCompare <= tCurrent )
{
TRACE( "%s\n", fFinder.GetFilePath() );
}
}
}
Ty
"The significant problems we face cannot be solved at the same level of thinking we were at when we created them." -Albert Einstein
|
|
|
|
|
thanks for the help!
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
Glad to help... and we were all newbies at one time
Ty
"The significant problems we face cannot be solved at the same level of thinking we were at when we created them." -Albert Einstein
|
|
|
|
|
Hi all,
Sorry in advance if you get this mail two times.
I have an VC++ application which uses *.dlls and *.libs.
When I run this application in debug mode i.e. pressing F5 it works.
But when I run it without debug mode either by double clicking or by pressing Ctrl+F5 nothing happens.
What is going wrong and what I am missing?
Any help in this regard will be appreciated.
thanks in advance
regards
/saekth
|
|
|
|
|
I'd make sure all the additional include libraries and additional directories are the same in the project settings for debug and release.
Nitron
_________________________________________--
message sent on 100% recycled electrons.
|
|
|
|
|
Hi Nitron,
Thanks for reply.
Usually when an application is built as a debug release it also works even if one runs it without debug i.e. by double clicking or ctrl+F5 (I might be wrong, in this case please correct me).
I have now even tried to build the release version of the application.Compiling and linking works fine but still I cann't run the application by double clicking or Ctrl+F5.
Any commnets
best regards
saekth
|
|
|
|
|
Do you have multiple projects in your workspace? If so, make sure your main project is the active project, otherwise F5 will try to run the library project (i've had that issue before). If everything looks fine, and just no response, I'd try the good 'ol reboot. Thats all I can think of
Nitron
_________________________________________--
message sent on 100% recycled electrons.
|
|
|
|
|
Any one has a binary multiplication c++ code? Thanks.
mIchAel Liu
__________________________________________________________
The secret of business is to know something that nobody else knows.
|
|
|
|
|
I need to find a free source code that implements
and manages a deeply customizable flex grid control.
I have to insert that code in an application that
I have to sell.
Does someone know if (o where) I can find it ??
Thanks a lot.
|
|
|
|
|
http://codeproject.com/miscctrl/gridctrl.asp[^]
I don't know if you can use it for sell or not.
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
For int value, in debug mode, i can add trace in code like
TRACE1("The value is %d", ival);
However, if the type is __int64, how can i trace it to output window ?
thanks
|
|
|
|
|
TRACE("%I64d", yourvariable );
Pavel
Sonork 100.15206
|
|
|
|
|
hello together,
i need information, how i can estimate permissions of the user at the computer. background: i have a program, which has to inform the user, that he has to have administator persmissions to run the selected function. i use vc++6.
hope you can help me.
ciao,
f.o.b
|
|
|
|
|
Use GetUserName and LookupAccountName to get current user and its SID.You can use this SID to find permission of that acount but I'm not sure how you can find out if it is admin or not.
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
thx for the information. i will check it out.
ciao
f.o.b
|
|
|
|
|
i have implemented your idea and i get a sid of
S-1-5-21-436379069-...
21 means 'SECURITY_NT_NON_UNIQUE'. i guess this is the reason why the fourth number has a seldom number.
i not sure but i think this is not the correct way for me.
ciao,
f.o.b
|
|
|
|
|
I found an article that I think will help you.Check this article in MSDN:
Q118626
HOWTO: Determine Whether a Thread Is Running in User Context of Local Administrator Account
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
thx for your effort.
Together with another article i get the solution.
thx a lot.
ciao
f.o.b
|
|
|
|
|
f.o.b wrote:
Together with another article i get the solution
Can I ask which article?
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
You will find it under:
http://www.codeproject.com/useritems/collectsid.asp
thx for your help.
Ciao,
f.o.b
|
|
|
|
|
hello,
i'm stuck in a problem with IShellView. here's my story :
i've implemented an IShellBrowser to make a file explorer holding to the windows one. problem : the THUMBNAILS display (only in windows 2000 and later).
when i switch to THUMBNAILS display, all is right, except when i change to another directory : the THUMBNAILS display isn't kept. nevertheless, i've been careful in saving the FOLDERSETTINGS of IShellView, and moreover, thanks to it, the "large icons" display, the "small icons", the "list" and the "details" ones are well and truly restored when i visit another directory. only the THUMBNAILS display is lost when the directory is changed.
why ? how to keep the THUMBNAILS display ? where is this parameter stocked if it isn't in FOLDERSETTINGS ?
|
|
|
|
|
i've made a test with SetWindowsHookEx to capture keyboard messages to MY OWN APPLICATION. it works, except the fact that the hook doesn't hook anything else when i use the keyboard in another application. when i switch back to my own application, the hook doesn't hook my keyboard inputs anymore.
why ? how to solve the problem ?
here is how i create the hook :
HHOOK hookdata;
hookdata = SetWindowsHookEx( WH_KEYBOARD, KeyboardProc, hInstance, 0 );
and here is my callback function :
LRESULT CALLBACK KeyboardProc ( int code, WPARAM w, LPARAM l )
{
MessageBox( g_hWnd, "KEYBOARD", "HOOKED", MB_OK );
return 0;
}
|
|
|
|
|
its because ur breaking the hook chain
Papa
Murex Co.
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
no that's not the problem, but it's ok now. i've found the solution :
hookdata = SetWindowsHookEx( WH_KEYBOARD, KeyboardProc, hInstance, GetCurrentThreadId() );
|
|
|
|