This is what I’ve done.
CCDirector* pDirector = CCDirector::sharedDirector();
CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();
pDirector->setOpenGLView(pEGLView);
// Set the design resolution
pEGLView->setDesignResolutionSize(480, 640, kResolutionFixedWidth);
CCSize windowSize = pDirector->getWinSize();
CCLog("window width = %f, window height = %f", windowSize.width, windowSize.height);
You may vary the sizes 480 and 640 if you have different designs set, for e.g. (iphone, iPad etc). And write your code using width and height from windowSize.
Happy Coding.