SECRETS in shlwapi.dll

xiaoxiao2021-03-06  52

We may have encountered such problems when we program: in a Label or Panel display path, when the path is too long, I hope to shorten the path like some installer copy files, some of which are replaced by omnasion ,such as:

C: / program files / borland / delphi5 / source / RTL / WIN -> C: / Program Files / Borland /.../ Win

It is not difficult to program the implementation, but I have not been able to do it. Suddenly one day, I saw an article, so, all the problems solved, and it was an unexpected gain → ↓

That is a Visual Basic program, but I saw a function of a function: PathcompactPath:

Private Declare Function PathcompactPath Lib "shlwapi" Alias ​​"pathcompactpatha" (_ byval hdc as stay, byval lpszpath as string, ByVal DX As long) AS Long

After several modifications, the trial in Delphi passed, and it was able to do the effect of the compressed path, but I am more interested in that there is still a lot of good stuff that can be used in shlwapi.dll? Open MSDN, knock in "shlwapi" search, and there is a bunch of "attention," a bunch ") is a function started with" path ", and is pleased. So I viewed their feature one by one, find that there is a corresponding function of almost all functions we need to call, such as:

PathaddBackslash: PathremoveBackslash: Add or remove "/" behind the path; PathisDirectory, PathShtmlfile, Pathisprefix, Pathisroot, Pathisull ...

Wait, just try a few, you can use, then I think how to find all the function declarations, I know that many dynamic link libraries have corresponding headers on the MSDN, which may not exceed the exception. Sure enough, I am guess! SHLWAPI.H did exist. The next job is more annoying, spend some time, with "find, replace" Dafa as auxiliary, I have made the function declaration of the path operations into shlwapi.pas (SHLWAPI.h included a number of functions declarations) : String, path, registry, registry stream, palette, and a very useful function DllgetVIRSION, a complete statement can be downloaded here).

Let's talk about Pathcomact, the PathCompactPath function requires the device's HDC to do parameters. It may be troublesome to use, so there is another function PathCompactPathex, parameter and devices are not related to the character and display width. Some places. I need to scrumblish, I made a simple Ellipsispanel control, which can be used as an example.

The same function, you can also use the DrawText function, the parameter description is found in the Windows SDK Help of MSDN or Delphi, the function is stronger than the PathCompactPath, when the call is invoked, the path is omitted or omitted in the path tail (similar to The handling of the resource manager cannot display the full path name.) DFS DFSELLIPSISPANEL is doing it. Posted in "Agan's Home" August 29, 2000

转载请注明原文地址:https://www.9cbs.com/read-116453.html

New Post(0)