zoukankan      html  css  js  c++  java
  • 使用ShLwApi中的PathCompactPathEx进行路径压缩显示

    比如将C:\My Installations\Delphi7Compent\Media\CDROM\Disk Images\Disk1\data2.cab显示为C:\My Installati...\data2.cab

    API函数为ShlWApi.dll中的PathCompactPathEx,同样的,在此DLL内还有更多关于Path路径的函数。

    delphi没有把这个DLL进行封装,但有人已经把它封装好了。下载地址:ftp://delphi-jedi.org/api/Shlwapi.zip

    function PathCompactPathExA(pszOut: PAnsiChar; pszSrc: PAnsiChar; cchMax: UINT; dwFlags: DWORD): BOOL; stdcall;
    ...{$EXTERNALSYM PathCompactPathExA}
    function PathCompactPathEx(pszOut: PChar; pszSrc: PChar; cchMax: UINT; dwFlags: DWORD): BOOL; stdcall;
    ...{$EXTERNALSYM PathCompactPathEx}
    function PathCompactPathEx; external shlwapi32 name 'PathCompactPathExA';

     
    function CompressPath(SrcPath:String;DestLength:Integer):String;
    var
      InBuffer, OutBuffer : array[
    0..MAX_PATH] of char;
    begin
      FillChar(InBuffer,  MAX_PATH 
    + 10);
      FillChar(OutBuffer, MAX_PATH 
    + 10);
      StrCopy(InBuffer,PChar(SrcPath));
      PathCompactPathEx(OutBuffer, InBuffer, DestLength, 
    0); //这里的DestLength就是设置长度
      Result:=OutBuffer;
    end;

  • 相关阅读:
    bzoj3224
    [洛谷日报第62期]Splay简易教程 (转载)
    bzoj1588
    codeforces467C
    codeforces616B
    codeforces379C
    codeforces545C
    codeforces285C
    codeforces659C
    快读代码level.2
  • 原文地址:https://www.cnblogs.com/martian6125/p/9631488.html
Copyright © 2011-2022 走看看