为何获取目录路径不全?

realhonse 2009-05-26 05:05:40
GetTempPath(255,@s3);
GetCurrentDirectory(255,@s4);
Edit3.Text:=s3;
Edit4.Text:=s4;
以上代码,获取目录为什么是这样的?:C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\
C:\Program Files\Borland\Delphi7\Projects\获得目录
一个为什么有~号呢,能获取长路径吗?
...全文
121 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
mjy521 2009-05-28
  • 打赏
  • 举报
回复
工具 - 文件夹选项 - 查看 - 在地址栏中显示完整路径
realhonse 2009-05-27
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 ccrun 的回复:]
Delphi(Pascal) codeprocedure TForm1.Button1Click(Sender: TObject);
var
s3: array[0..255] of char;
szShortPath: array[0..255] of char;
szLongPath: array[0..255] of char;
pDummy: PCHAR;
begin
GetCurrentDirectory(255, s3);

GetShortPathName(s3, szShortPath, 255);
Edit3.Text := szShortPath;

GetFullPathName(s3, 255, szLongPath, pDummy);
Edit4.Text := …
[/Quote]

以上代码我试试还是不行啊,难道我的电脑?
soweb 2009-05-27
  • 打赏
  • 举报
回复

function GetLongPathName(ShortPathName: PChar; LongPathName: PChar; cchBuffer: Integer): Integer; stdcall; external 'kernel32.dll' name 'GetLongPathNameA';

function ToLongPath(AFileName: string): string;
var
Buffer: array[0..260] of Char;
begin
Result := AFileName;
if (GetLongPathName(PChar(AFileName), Buffer, SizeOf(Buffer)) <> 0) then
Result := Buffer;
end;

亮剑_ 2009-05-27
  • 打赏
  • 举报
回复
3楼妖哥那个GetFullPathName可以的啊,就是这个API
ccrun.com 2009-05-26
  • 打赏
  • 举报
回复
procedure TForm1.Button1Click(Sender: TObject);
var
s3: array[0..255] of char;
szShortPath: array[0..255] of char;
szLongPath: array[0..255] of char;
pDummy: PCHAR;
begin
GetCurrentDirectory(255, s3);

GetShortPathName(s3, szShortPath, 255);
Edit3.Text := szShortPath;

GetFullPathName(s3, 255, szLongPath, pDummy);
Edit4.Text := szLongPath;
end;
凯文2016 2009-05-26
  • 打赏
  • 举报
回复
貌似跟系统有关系吧,DOS下经常有这种目录出现。
Harryfin 2009-05-26
  • 打赏
  • 举报
回复
如果只是为了访问的话没关系,可以照用的。显示的话是有点问题。

16,742

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 语言基础/算法/系统设计
社区管理员
  • 语言基础/算法/系统设计社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧