
![]()
public class MyForm : Form
{
・・・
string file_name = "../../CSForm.cs";
byte[] byt = new byte[256];
int leng;
int pos = 1000;
|
public MyForm()
{
InitializeComponent();
if (!File.Exists(file_name)) //ファイルの有無をチェック
MessageBox.Show(file_name,"Input File Error");
FileStream reader = File.Open(file_name,FileMode.Open);
reader.Position = pos;
leng= reader.Read(byt,0,256);
Paint += new PaintEventHandler(MyHandler);
}
|
private void MyHandler(object sender, PaintEventArgs e)
{ string wstr = "";
int i,j,k;
byte[] wt = new byte[16];
for(i=0; i<leng; i+=16)
{ j = leng-i;
if (j > 16) j = 16;
for(k=0; k<j; k++) wt[k]= byt[i+k];
// オフセット
k = pos + i;
wstr += k.ToString("X4");
wstr += ": ";
// 16進
for(k=0; k<j; k++)
{ wstr+= wt[k].ToString("X2");
if (k % 4 == 3) wstr += " ";
}
// 文字
wstr+= " ";
for(k=0; k<j/2; k++)
wstr+= (char)(wt[k*2] + (wt[k*2+1]<<8));
wstr+= " ";
wstr+= "\r\n";
}
textBox1.Text = wstr;
}
|
this.textBox1.Font = new System.Drawing.Font("MS ゴシック", 12F, System.Drawing.FontStyle.Regular,
System.Drawing.GraphicsUnit.Point, ((byte)(128)));
|
![]()
[Next Chapter ↓] メニューを処理する
[Previous Chapter ↑] Binary Viewer のレイアウト