Access violation at address 0040303F in module 'OnEyeManager.exe'. Write of address 0038003C
最近将一个程序从D7转换到D2010,在部分WINXP系统的电脑运行错误,错误信息为:
Access violation at address 0040303F in module 'OnEyeManager.exe'. Write of address 0038003C.
而在另外一些WINXP系统的电脑上运行正常,开始以为是操作系统版本的原因,因为不能运行电脑的操作系统都是电脑公司装的,就把其中一台的系统格了重新安装,还是运行出错。
然后就整了个虚拟机,装上D2010,编译没报错,逐步调试,发现出错的地方是Copy函数,我疯狂了......
D2009-用ANSI,2009+用Unicode,字符串编码问题
function FormatDir(aDir: string): string; begin Result := aDir; if Length(Trim(aDir)) > 2 then begin if Copy(Trim(aDir), Length(Trim(aDir)), 1) <> '\' then Result := aDir + '\'; end; end;
if aDir[length(aDir)] <> '\' then aDir := aDir + '\'
function IncludeTrailingPathDelimiter(const S: string): string; begin Result := S; if not IsPathDelimiter(Result, Length(Result)) then Result := Result + PathDelim; end;