Delphi版textDump.lzh(ソースコード付き)
16進ダンプの結果をテキストとして表示します。
16進ダンプしたいファイルをドラッグ&ドロップ(アイコンへのドロップも可)
Delphiなら普通にバイナリファイルを扱えるので、当然VBScript版より、まともになってます(^^;。
ただし、ファイルへ出力しません。結果を表示するだけです。
|-`).。oO(結果を保存したいときはテキストエディタにコピーしてください。)
エラー処理は特にしていません。ソースコードを読んだ上でお使いください。
このソフトウェアの改変・再配布等は自由です。
言語 : Delphi6
OS : windows XP
unit textDumpFrm; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ShellAPI; type TForm1 = class(TForm) memo1: TMemo; procedure FormCreate(Sender: TObject); private { Private 宣言 } procedure DumpToText(fileName: string); procedure WMDropFiles(var msg: TWMDropFiles); message WM_DROPFILES; public { Public 宣言 } end; var Form1: TForm1; implementation {$R *.dfm} procedure Tform1.DumpToText(fileName: string); var fs:TFileStream; bufMemo:TStringList; buf:array[1..16] of byte; tmpLine:string; cnt:integer; i:integer; begin if FileExists(fileName) then { ファイルの存在を確認} begin //ファイルストリームを開く fs:=TFileStream.Create(fileName,fmOpenRead,fmShareDenyNone); bufMemo:=TStringList.Create; repeat //バッファに16バイトずつ読み込む cnt:=fs.Read(buf,16); tmpLine:=''; for i:=1 to cnt do begin //1バイトずつ十六進数な文字列に変換 tmpLine:= tmpLine+inttohex(buf[i],2)+' ' end; bufMemo.Append(tmpLine); until cnt <16; //表示する form1.Caption:=fileName; form1.memo1.Text:=bufMemo.Text; bufMemo.Free; //ファイルストリームを閉じる fs.free; end; end; procedure TForm1.FormCreate(Sender: TObject); begin //ファイルのドロップ可 DragAcceptFiles(Handle, True); //コマンドライン引数の処理 if paramcount >0 then begin DumpToText(paramstr(1)); end; end; //ドロップされたファイルを開く procedure TForm1.WMDropFiles(var msg: TWMDropFiles); var FileName: array[0..260] of Char; begin try //最初のひとつだけ読み込む DragQueryFile(msg.Drop, 0, FileName, SizeOf(FileName)); DumpToText(FileName); finally // ハンドルを解放 DragFinish(msg.Drop); end; end; end.
もどる |
(◎←) ((( ▽ ))) - - |
This page hosted by
Get your own Free Home Page