A number of things could be going wrong, but most of them are due to the same probability: the current working directory is not what you think it is when you run the program in release mode.
Make sure to either:
1) set the current working directory before using CreateDirectory(), or
2) supply the full path of the new directory as argument
Also, check the return value to make sure nothing went wrong. If CreateDirectory() returns false, look at the return value of GetLastError().
I'm using createdirectory in a qt project. i have an explorer window for selecting a folder/path and then call the createdirectory funtion with the selected path. so it's always the full path and doesn't depend on the working directory