|i have written this code in C++|
It's actually C, not C++. You do not use any C++ objects/features, and it's non-conformant C++, but valid C.
the return value is -1.
Check errno for more information on what's going wrong.
Obvious question: You're already using Windows specific features, why not just call the function directly, instead of going though system()?
How To Ask Questions The Smart Way