How to lock device's orientation ?

I want to lock device’s orientation to one way (the same functionality to physically turn on lock rotation button beside the iPad’s device), I did with the following code.

CCDirector::sharedDirector()->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft);

But as long as I turn around the device, the screen rotates. The above code only effects the way the objects in the game, not prevents the device’s screen from rotating.

Any suggestions ?

FYI: I tested it on iPad.