When building up your s
variable, you are appending "\0"
(double quotes), which gets interpreted as a 0-length string concatenation and thus a no-op, so s
is effectively NOT double null terminated correctly. In other words, this code:
s="x:\\games\\" + path + "\0" ;
Is effectively the same as this code, from the +
operator's perspective:
s="x:\\games\\" + path + "" ;
In order to actually append a null character, use '\0'
(single quotes) instead (yes, a single Char can be appended to a String):
s="x:\\games\\" + path + '\0' ;
Your d
variable is double null terminated correctly because the \0
is included in a larger string literal so it is not lost.