掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
ListViewのサイズカラムでソートするには? (ID:5734)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
Poさんへ。 数値をB, KB, MBにするのは、Formatでは無理では?Ifで、どの単位にするか切り分ける必要がありそうです。 APIを使えば1発変換ですね。 定義で、 {$EXTERNALSYM StrFormatByteSize64} function StrFormatByteSize64( qdw: int64; pszBuf: PCHAR; uiBufSize: UINT ):PCHAR; stdcall;export; {$EXTERNALSYM StrFormatByteSize64A} function StrFormatByteSize64A( qdw: int64; pszBuf: PAnsiChar; uiBufSize: UINT ):PAnsiChar; stdcall;export; {$EXTERNALSYM StrFormatByteSize64W} function StrFormatByteSize64W( qdw: int64; pszBuf: PWideChar; uiBufSize: UINT ):PWideChar; stdcall;export; として、実体を function StrFormatByteSize64; external 'shlwapi.dll' name 'StrFormatByteSize64A'; function StrFormatByteSize64A; external 'shlwapi.dll' name 'StrFormatByteSize64A'; function StrFormatByteSize64W; external 'shlwapi.dll' name 'StrFormatByteSize64W'; としておき、 var buf: array[0..512] of char; begin Memo1.Lines.Add(StrFormatByteSize64(532, @buf[0], 511)); Memo1.Lines.Add(StrFormatByteSize64(1340, @buf[0], 511)); Memo1.Lines.Add(StrFormatByteSize64(23506, @buf[0], 511)); Memo1.Lines.Add(StrFormatByteSize64(2400016, @buf[0], 511)); Memo1.Lines.Add(StrFormatByteSize64(2400000000, @buf[0], 511)); end; とすれば、 532 バイト 1.30 KB 22.9 KB 2.28 MB 2.23 GB と出来ます。 IE5.0以降で使用できるAPIですので、使えないときもあります。
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.