How to convert a screwdriver into a dinosaur? Easy, that's what casts are for! Or are they?
And what was it your parents taught you about checking return values?
Last, you cannot open the device with exclusive writing access, of course.
But even with all of that fixed, you'd need to run your program with administrator rights.
The solutions:
1. don't use casts when you don't know why you need them, call the right function (CreateFileA) or use wide strings (or rather, the _T macro and TCHAR).
2. Check return values.
3. Don't request exclusive write access.