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;

  • 相关阅读:
    RESTful规范1
    Django -- 发送HTML格式的邮件
    11.10 vue
    Selenium 使用
    Beautiful Soup的用法
    Pthon常用模块之requests,urllib和re
    爬虫--工具安装Jupyter anaconda
    11-3
    Python -- tabulate 模块,
    Python -- queue队列模块
  • 原文地址:https://www.cnblogs.com/martian6125/p/9631488.html
Copyright © 2011-2022 走看看