QQ聊天

MaxScript用二进制读取方式获取Max文件版本

 

代码
Fn GetMaxFileVersion theMaxFile =
(
local versionFloat,theBinStream,keyWord,notFind,textFromBin,binEnd
versionFloat
= 0
if isMaxFile theMaxFile do
(
theBinStream
= fopen theMaxFile "r"
keyWord
= "Version:"
notFind
= true
textFromBin
= ""
fseek theBinStream
0 #seek_end
binEnd
= ftell theBinStream
fseek theBinStream
0 #seek_set

while (ftell theBinStream < binEnd ) and notFind do
(
textFromBin
= ReadString theBinStream
if textFromBin == "V" do
(
for i = 1 to keyWord.Count - 1 do textFromBin += ReadString theBinStream as string
)
if keyWord == textFromBin do
(
versionString
= ""
for i = 1 to 5 do versionString += ReadString theBinStream as string
versionFloat
= versionString as float
notFind
= false
)
)
FClose theBinStream
)
versionFloat
)

GetMaxFileVersion(getOpenFileName())

 

posted @ 2010-08-23 15:51  SITT  阅读(1342)  评论(0编辑  收藏  举报
QQ聊天