C#程序,运用kernel32.dll 的writefile在win10能运行,在win7和XP运行不了,折腾了2天发现:
win10 writefile的nNumberOfBytesToWrite参数写大点没问题,实际发送的长度还是buff字节实际长度。
win7上面byte[] lptxBuffer, int nNumberOfBytesToWrite,这2个要匹配。例如:lptxBuffer长度是20,nNumberOfBytesToWrite需要填19。
对比感觉win10对于参数容错兼容比win7更好点。win7参数填错,app是不运行的。