Welcome to the new platform of Programmers Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use it's exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
OK, I may have a job interview with a programing firm here in my city, and I have been tweaking and cleaning up my applications and sources. However, I lost the sources to my program that cleans out temporary file directories, so I am rebuilding it from scratch in C++.
Now, my first question is this. When I do "SHBrowseForFolder()", it returns a pointer to an allocated block of memory. My help files say I am responsible for freeing this memory. Since I use a variable to store the pointer, how can I free the memory? I tried using "free()" and "delete ", but both caused the application to crash. If I don't attempt to free the pointer, it works AOK, but I don't want my coding to look sloppy, which may cause memory leaks. How do I free the resources that "SHBrowseForFolder()" allocates?
Next, I need a function that can use "FindFirstFile()" and "FindNextFile()" to go through a directory and it's sub-directories and remove all files in them. Say I wanted to use the function "bool CleanFiles()" to delete every file and directory under C:WindowsTemp. How would I do this? I've only used the "Find*File()" functions once before, long ago, so I am not 100% sure on how to use them properly. Thanks for the help!