How to delete the file at reboot?
Deleting the file at reboot! Ahem! Ahem! Ahem. Don’t use this API to play prank on your friends. Actually windows have provided you API MoveFileEx, which can delay deleting the file till reboot. This API would be helpful in case when you the concerned file is in use and you have to delete, after it use is over.
MoveFileEx(_T(“FILE_TO_BE_DELETEDâ€), NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
How to find Handle to window (HWND) based on Window Caption?
 It fairly very easy then it seems too
, Windows have provided you two API to do so, and these api have saved my neck many times, now let get introduced to them, they are FindWindow and FindWindowEx. I have written a small function which would help you finding handle to window based on caption.
HWND GetWindowHandle(LPCTSTR strSearch, LPCTSTR strClass = NULL)
{
 TCHAR lpString[_MAX_PATH];
 CString strTitle;
 int iFind = -1;
 HWND hWnd = ::FindWindow(strClass,NULL);while(hWnd != NULL)
 {
 ::GetWindowText(hWnd,lpString,_MAX_PATH);
 TRACE1("%s\n",lpString);
 strTitle = lpString;
 strTitle.MakeUpper();
 iFind = strTitle.Find(strSearch);if(iFind != -1)
 return hWnd;hWnd = ::FindWindowEx(NULL,hWnd,strClass,NULL);
 }
 return hWnd;
}
Just call use this function to find the handle of Window based on caption name.
HWND hWnd = GetWindowHandle("REGISTRY",NULL);
PS: There two thing to note, to make this function work properly, first caption should be provided in capital letter, to make function search properly and secondly, caption should be unique, if not then you must have to provide the window class in second parameter, which may be NULL in most of cases. E.g. this function will return HWND of first NotePad windows, if more than one NotePad Window is open and you have passed caption as NOTEPAD.
How to display directories in a combo box?
Just come across somebody asking ComboBox filled with Directories and other stuff. There Mr Nibu Thomas replied that you can use DlgDirListComboBox for that. I just dig it up that api and created a small source code for you that will above tasks!
In Win32Api
TCHAR szDrive[MAX_PATH] = _T("C:\\YYY\\*.*");
DlgDirListComboBox(HANDLEOFDIALOG,szDrive,IDC_COMBO1, IDC_STATIC_1234, DDL_DIRECTORY|Â DDL_READONLY|Â DDL_DRIVES);
In MFC, Under Class drived from CDialog
TCHAR szDrive[MAX_PATH] = _T("C:\\YYY\\*.*");
DlgDirListComboBox(szDrive,IDC_COMBO1,IDC_STATIC_1234, DDL_DIRECTORY| DDL_READONLY | DDL_DRIVES);
see a small pic of same here :-
While registering my MFC DLL, regsvr32.exe returns error?
First of All, there are two type of MFC DLL , one is MFC DLL just like normal dll, which work same as Win32 DLL but utilize MFC capability into it and other is MFC extension DLL , which can export class from it with only one short coming, that’s it can be used with only MFC based application. And now little background of what regsvr32.exe do, it just call com DLL exposed function DllRegister* to register DLL with computer (i.e. it just placed required CLSID and DLL path into registry) .
Since MFC application doesn’t work like com DLL. so you don’t need to register that. You just have to place it with application or path defined in environment to make it work.