CnPack Forum

#1 CnCommon单元LongNameToShortName函数有问题?
在Delphi 2010下面使用时会出现内存溢出,原始函数如下:
[code]function LongNameToShortName(const FileName: string): string;
var
Buf: PChar;
BufSize: Integer;
begin
BufSize := GetShortPathName(PChar(FileName), nil, 0) + 1;
GetMem(Buf, BufSize);
try
GetShortPathName(PChar(FileName), Buf, BufSize);
Result := Buf;
finally
FreeMem(Buf);
end;
end;[/code]

似乎这里用PChar有点不妥,我将其修改如下,似乎问题解决了,希望管理 ..

#1 >>Next Page

Forum:CnVCL 组件包
Thread:CnCommon单元LongName ...
Next Thread:请问多语言包中,是否 ...

Home
Login

Powered by Discuz!