Get today date in dd/mm/yyyy
Easy way to count the processing time
Open a console window
Error: the application has failed to start because its side by side configuration is incorrect.
Get System Window Resolution
List Directory
Memory leak tracking for new operator
Get pointers in MFC

Get today date in dd/mm/yyyy

#include <time.h>

time_t now = time( &now ) ;
struct tm* local_time = new tm( ) ;
local_time = localtime( &now ) ;
char buffer[20] = { '\0' } ;
strftime( buffer, BUFSIZ, "%d/%m/%Y", local_time ) ;
delete local_time;

more details on strftime Reference

Easy way to count the processing time

#include <time.h>

clock_t time = clock();
...
time = clock()-time;
printf("time in seconds: %ds\n",time/CLOCKS_PER_SEC);
printf("time in milliseconds: %dms\n",time);

more details on clock

Open a console window

AllocConsole(); //open the console window
freopen ("CONOUT$", "w", stdout); //set output available to this console
freopen("CONIN$","r",stdin); //set input avaiable to this console

more details on freopen Reference

Error: the application has failed to start because its side by side configuration is incorrect.

If you have met this error when you are running your distributed program in other machine,
One of the reasons is version mis-match. Someone may ask you to download the vcredist_x86.exe
from microsoft, but it maybe hard to find the right version.
Another method is to directly install the vcredist_x86.exe from your VC directory.
For VC 2005, probably the file is located at
C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\BootStrapper\Packages\vcredist_x86\vcredist_x86.exe
just copy this file to antoher machine and install it, it will then solve the version problem.

more details on Redistributing Visual C++ Files

Get System Window Resolution

int cx = GetSystemMetrics(SM_CXSCREEN);
int cy = GetSystemMetrics(SM_CYSCREEN);

more details on GetSystemMetrics Function

List Directory

Get the header file from Internet or download here
you may put it in VC directory or just put it in your project folder.
Here is a sample program made by VC2005 to list out what is inside a directory. [download]

more details on Wikipedia

Memory leak tracking for new operator

Add these code on the top of the file that you would like to track memory leak in.

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

After that, debugger will displays memory leak information in the output window after the program finished.

Get pointers in MFC

1) Get CApp in anywhere:
AfxGetApp();

2) Get CDoc in CView:
CYouSDIDoc *pDoc=GetDocument();

3) Get CMainFrame in CApp:
the variable m_pMainWnd in CWinApp
or in anywhere:
CMainFrame *pMain =(CMainFrame *)AfxGetMainWnd();

4) Get CMainFrame in CView:
CMainFrame *pMain=(CmaimFrame *)AfxGetApp()->m_pMainWnd;

5) Get CView:
CMainFrame *pMain=(CmaimFrame *)AfxGetApp()->m_pMainWnd;
CyouView *pView=(CyouView *)pMain->GetActiveView();

6) Get CDoc:
CDocument * pCurrentDoc =(CFrameWnd *)m_pMainWnd->GetActiveDocument();

7) Get CStatusBar and CToolBar:
CStatusBar * pStatusBarˇ×(CStatusBar *)AfxGetMainWnd()->GetDescendantWindow(AFX_IDW_STATUS_BAR);
CToolBar * pToolBar=(CtoolBar *)AfxGetMainWnd()->GetDescendantWindow(AFX_IDW_TOOLBAR);

8) Get Menu in Mainframe:
CMenu *pMenu=m_pMainWnd->GetMenu();