Program and details

xiaoxiao2021-04-08  406

Copyright Notice:

This article is completed by Lyris, started 9CBS, the author retains Chinese copyright. No commercial use is not permitted without permission. Welcome to the reprint, but please keep the article and copyright statement complete. For contact, please send an email: chenwentao@gmail.com

As early as a few years ago, I found this function in SHLWAPI.dll: Format the output file size: The file size is originally byte, such as 1234567 bytes. As can be seen in the Windows Explorer, if the file size is roughly like this, the byte is less than 1K, which is more than 1K, for example, 343.5kb, for example, for 1.4MB, in summary, The system is very intelligent to select a variety of dimensions, which is very convenient to view the size. Since the system already has this function, you don't have to write a function to write a function. Inside SHLWAPI.dll, there is this function Strformatbytesizea, Strformatkbsizea, check MSDN, converted into Delphi as

function StrFormatByteSize (dw: DWORD; szBuf: PChar; uiBufSize: UINT): PChar; stdcall; external 'shlwapi.dll' name 'StrFormatByteSizeA'; function StrFormatKBSize (qdw: LONGLONG; szBuf: PChar; uiBufSize: UINT): PChar; stdcall External 'shlwapi.dll' name 'strformatkbsizea';

Today, it is found that the file names such as "C: / Documents and Settings / LocalService / Application Data / Microsoft / Internet Explorer / Demo.txt" are always the same as "C". : / Documents and settings / l ... / demo.txt ", it is estimated that there is also a related function. Sure enough, open SHLWPI.dll, there are many operational paths, such as PathcompactPatha, as the name suggests, use MSDN one Check, it is like this. Soon writing Delphi's export function:

Function PathcompactPath (HDC: HDC; LPSZPATH: PCHAR; DX: INTEGER): Bool stdcall; external 'shlwapi.dll' Name 'PathcompactPatha';

I will get the effect you want. Summary: For applications, many things do not need to repeat the invention, basically in each domain details have a special research reference implementation. Thinking, fast finding information can make yourself further improve or stand on a higher angle look. Of course, the basic skill must be solid, and it can also be implemented for the exercise.

By the way, I will praise the Windows, see the spirit, huh, huh. This is not difficult to do so technical, but it has a great help to improve user experience. Don't think that software is algorithm, code, in fact, there are many places worth paying attention, such as user habits.

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

New Post(0)