|
Krisna Adityawan wrote:
How to find a file in a folder whatever the type is by last modified type.
ex: i want to find *.txt with last modified today
Are you wanting the newest .TXT file in a given folder? How about this pseudocode:
set lastmod to 0
for each .txt file in folder
if file's last mod date > lastmod
set lastmod = file's last mod date
save name of file
end
next
Krisna Adityawan wrote:
How to delete all file in a folder without delete the folder it self ?
SHFileOperation() should do it.
|
|
|
|
|
Hi all,
I am writing a program that requires deleting a file stored in the disk programmatically .I am wondering if we can do that?
Could somebody help me on this.
Regards.
|
|
|
|
|
|
Thanks a lot Jens,
I solved my problem.
|
|
|
|
|
You also have SHFileOperation() at your disposal.
|
|
|
|
|
Hi davi ,
Thanks a lot for guidance.
Regards.
|
|
|
|
|
You could also try CFile::Remove()
|
|
|
|
|
Or, the CRT function remove().
onwards and upwards...
|
|
|
|
|
Hi,
I need to parse ASP pages before they are rendered by a webserver and find the positions for the ASP scripts within the page. Looking for the "<%" and "%>" -tags is not a good solution since it could be something else than ASP(ei. could be in comments, could be HTML text etc.)
Anyone know a good way how to find out what really is ASP in a page?
Thanks
Fred
|
|
|
|
|
how do I know what privilage level the current user is on? like is he a member of administrative group or user group or some thing else?
|
|
|
|
|
NetLocalGroupGetMembers() & NetLocalGroupEnum() maybe what you wants.
Mazy
No sig. available now.
|
|
|
|
|
Thanks, but is there any article on this site about this issue????
|
|
|
|
|
Here is a quick and dirty method to check whether the user *could* write to specific key
in HKLM I used for a setup program that did different levels of setup depending on the
authority of the user:
char buf [MAX_PATH];
{
OSVERSIONINFO osVer;
osVer.dwOSVersionInfoSize = sizeof (osVer);
GetVersionEx (&osVer);
bIsNT = 1 && (osVer.dwPlatformId & VER_PLATFORM_WIN32_NT);
}
bIsAdministrator = FALSE;
if (bIsNT)
{
TRUSTEE Trustee;
ACCESS_MASK AccessMask;
::BuildTrusteeWithName (&Trustee, "CURRENT_USER");
PSECURITY_DESCRIPTOR pSecDesc= NULL;
PACL pAcl = NULL;
if (::GetNamedSecurityInfo (
"MACHINE\\SYSTEM\\CurrentControlSet\\Services",
SE_REGISTRY_KEY,
DACL_SECURITY_INFORMATION,
NULL,
NULL,
&pAcl,
NULL,
&pSecDesc) == ERROR_SUCCESS)
{
if (::GetEffectiveRightsFromAcl (pAcl, &Trustee, &AccessMask) == ERROR_SUCCESS)
{
if (AccessMask & STANDARD_RIGHTS_REQUIRED)
bIsAdministrator = TRUE;
}
::LocalFree (pSecDesc);
}
if (!GetSystemDirectory (buf, MAX_PATH))
bIsAdministrator = FALSE;
else
{
::lstrcat (buf, "\\drivers");
sPathSystem = buf;
}
if (bIsAdministrator && ::GetNamedSecurityInfo (
buf,
SE_FILE_OBJECT,
DACL_SECURITY_INFORMATION,
NULL,
NULL,
&pAcl,
NULL,
&pSecDesc) == ERROR_SUCCESS)
{
if (::GetEffectiveRightsFromAcl (pAcl, &Trustee, &AccessMask) == ERROR_SUCCESS)
{
if (AccessMask & STANDARD_RIGHTS_REQUIRED)
bIsAdministrator = TRUE;
}
::LocalFree (pSecDesc);
} else
bIsAdministrator = FALSE;
}
This may give you a headstart, or at least things to search for in the Platform SDK.
Iain.
|
|
|
|
|
Thanks. You have really solved the problem
|
|
|
|
|
What I have done is something like this.
Is it the right way to do this? Please commnet.
<br />
BOOL isCurrentUserAdministrator()<br />
{<br />
<br />
DWORD dwLevel = 1;<br />
LPUSER_INFO_1 pBuf = NULL;<br />
NET_API_STATUS nStatus;<br />
DWORD nSize = 20;<br />
<br />
LPWSTR lpUsername = new unsigned short[nSize];<br />
<br />
if(!::GetUserName( lpUsername, &nSize))
return false;<br />
<br />
<br />
nStatus = NetUserGetInfo(NULL, lpUsername, dwLevel, (LPBYTE *)&pBuf);
<br />
if(nStatus == NERR_Success)
{<br />
if( pBuf->usri1_priv == USER_PRIV_ADMIN)<br />
{<br />
NetApiBufferFree(pBuf);<br />
return true;<br />
}<br />
else<br />
{<br />
NetApiBufferFree(pBuf);<br />
return false;<br />
}<br />
}<br />
<br />
return false;<br />
}<br />
<br />
|
|
|
|
|
Looks good to me. You are specifically getting a user "level", which is what your question asked.
My solution answered "can a user do 'this'?", which is a subtly different one. Sometimes users
are members of groups which have specific access to something.
Which one you use depends on the detail of why you want to know, so that is an answer best left
to your application needs.
Iain.
|
|
|
|
|
Hi all,
How a process (exe file) will be able to know path where it is residing and from where it is loaded and running?
Is there any API available?????????
Thanks for help
|
|
|
|
|
GetModuleFileName() ?
Mazy
No sig. available now.
|
|
|
|
|
|
I used the class which is derived from CControl bar
in control bar.i used the formview as a view class,form view contains other controls ,but when i resize the dock it get flicker
can any one tell me the Soln for this
thanx
|
|
|
|
|
Does anyone has some idea about setting icon(120*40) to SDI Application left corner of the title???
thanks in advance
Adi
|
|
|
|
|
Do you want to have a 120*40 icon in the title bar?
Then you would have to draw the title bar itself (WM_NCPAINT, etc).
If just would like an icon in your title bar that is a downsized version of the 120*40 icon, just call LoadImage/SetIcon.
Jens
|
|
|
|
|
hi jens...... thanks for immediate reply.....
and our requirement is as u understood.....>
Do you want to have a 120*40 icon in the title bar?
> Then you would have to draw the title bar itself (WM_NCPAINT, etc).
but my doubt is.... where to handle the WM_NCPAINT event.... neither mainframe nor view class have this Windows Message...
where shud i handle it....... and can u send me little bit detailed information for drawing......
thanks in advance......
adi narayana
|
|
|
|
|
Hmm, try the follwing:
Go to the class wizard, choose the "class info" tab, set the "Message filter" to "Window".
Now you should be able to add a message handler for WM_NCPAINT.
One of my very favourite authors, Mr. Paul DiLascia, has written a wonderful article about this, I very recommend reading it. It explains everything:
http://www.microsoft.com/msj/0697/c0697.aspx.
Hope that helps,
Jens
|
|
|
|
|
I have some doubt as to how to retrieve the Headerfooter from MS-WORD document using VC++ application. I was not able to get the appropriate functions. So, can you please tell me the solution.
I tried using the GetHeader & GetFooter member functions.But these functions are available only in the MS-WORD8 version.They are not found in the MS-WORD 9 and 2000 version.
Also I tried implementing Getheader and Getfooter functions in the word9 version,but, it is gave the following error "GetHeader Function is not the memberclass of MS-WORD9".
Is there any function to put the header and footer in an already exisiting word document using VC++.
Anna Quadros
|
|
|
|