I can't make this work. The problem is that the data read from ReadFile is not null-terminated. That's why I use string.assign with a length, because it handles this case.

I tried using string.insert(dwRead, 1, '\0') to put a null character in, but STL didn't like me modifying the string that way (hard crash).

I don't know how to make this work without a copy (though I suspect there is a way). I'm open to suggestions.