(1) There are some links about changing registry using C but I don't trust those. Is there a specific C fucntion or a batch command I could incorporate in a C program that changes a registry entry?
(2) Well actually once I learn to use winapi properly this would come in handy.
But currently I'm focused on win32 console, why would I go into the jungle of win32 api when I don't even want to do gui.
Aside: batch commands are not relevant to a C or C++ program. You can get a C/C++ program to invoke a command interpretor to run a batch command, but I don't think that is what you mean (or need)
#1 There is no C/C++ (as in standard C/C++) call to update the registry, as the concept is WIN32 specific.
You need to use the WIN32 API's registry functions. In this case, RegOpenKeyEx, RegSetValueEx, RegQeuryValueEx, RegCloseKey.
Note that if a program changes the registry nothing will happen to the Explorer's view(s) until you notify it that you have made the change. This requires the use of SHChangeNotify. It might also require you to broadcast a WM_SETTINGCHANGE message to all top level windows, but as this is not the kind of code I've written often, I am hazy about the specifics.
#2 I am not away of a cross-platform C equivalent to FindFirstFile, etc. The Microsoft CRT does supply _findfirst, etc. which correspond to FindFirstFile, etc if you want to avoid including windows.h, but they are no less specific and no easier to use. And as you need windows.h for the registry functions...
A Linux solution to the same problem would make use of opendir/readdir/closedir.
For a cross-platform. C++ solution see Boost.Filesystem (the basic_directory_iterator)
Oh so this hides/unhides files by using a batch command, this is what I was thinking off.
Could you suggest a book that teaches batch commands?
Thank you.
chipp's solution is not doing what you asked for originally -- which was to show or hide system or hidden files. The batch file is changing the file attributes to remove their system, hidden, and readonly, so they become just normal files.
While removing the hidden attribute is (probably) benign, it is a bad idea to remove either the system or readonly attribute from random files.
As it stand, the code could have issues with newer versions of Windows if you tried to run it on a machine with a single drive (by swapping D:\ -> C:\)
Out of interest, what is your intended use for this hide/show mechanism?