LoginSignup
0
0

More than 5 years have passed since last update.

vbsの作法 その6

Posted at

概要

vbsの作法、調べてみた。
バイナリーファイルを表示してみた。

写真

image.png

サンプルコード

Dim App1
Dim Appflg
Dim Stream
Dim Bytes
Dim Chars
Dim c
Dim k
Dim buf

Set App1 = Createobject("OHIcompo6.srv")
WScript.ConnectObject App1, "App1_"

Sub App1_exit()
    Appflg = 2
End Sub

Sub App1_ok()
    Msgbox App1.text
End Sub

buf = ""
Set Stream = CreateObject("ADODB.Stream")
Stream.Open
Stream.Position = 0
Stream.Type = 1
Stream.LoadFromFile "hexread0.vbs"
Bytes = Stream.Read(-1)
Chars = ""
For k = 1 To LenB(Bytes)
    If k Mod 16 = 1 Then
        buf = buf & "     " & Chars & vbcrlf
        Chars = ""
    End If
    If k Mod 4 = 1 Then
        buf = buf & " "
    End If
    c = AscB(MidB(Bytes, k, 1))
    buf = buf & Mid(Hex(256 + c), 2)
    If (c < 32) or (c > &h7f) Then
        c = 32
    End If
    Chars = Chars & Chr(c)
Next
App1.text = buf
Set Stream = Nothing
Appflg = 1
Do
    WScript.Sleep(100)
    App1.ping
Loop until Appflg = 2
Set App1 = Nothing

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0