C/C++ How to change file attributes programmatically?

Does anybody know how to change file attributes such as time created/modified/accessed and hidden/system/read-only/archive? I know how to access them using
long hFile = _findfirst( DirSpec, &fileStat );
but I don't know how to change them. Any help is appreciated.
rasulomanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

B1-66ERCommented:
there WinAPI SetFileAttributes:

SetFileAttributes("C:\\lol", FILE_ATTRIBUTE_SYSTEM|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_READONLY) ;

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
B1-66ERCommented:
and API SetFileTime(..)

HANDLE File = CreateFile("C:\\lol", GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0) ;
 if  (File == INVALID_HANDLE_VALUE)
  MessageBox(0,"can open","",MB_OK) ;
      SYSTEMTIME st ;
      GetSystemTime(&st) ;
      FILETIME ft ;
      SystemTimeToFileTime(&st,&ft) ;
      if (!SetFileTime(File, &ft, &ft,&ft))
            MessageBox(0,"can set time","",MB_OK) ;
 CloseHandle(File) ;

will set created/modified/accessed time to current time.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.