明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 900|回复: 10

[资源] 论坛压缩包不能打开的修复程序

  [复制链接]
发表于 2021-12-19 19:36 | 显示全部楼层 |阅读模式
论坛可能避免为病毒感染,自动添加修改了首字节,运行下面的lisp程序可以自动删除首字节,
压缩包即可正常解开。这个程序就不打包上传了,不然无法解开压缩包。

  1. ;; 明经通道论坛 2021-12-19  yxp
  2. ;; 删除一个文件多余的head字节,0D0A
  3. (vl-load-com)

  4. (defun c:deletebyte (/ a LSP isUnnec)
  5.   (setq a (getfiled "选择需要删除首字节的文件"
  6.                     (if filesPathDefault filesPathDefault "")
  7.                     "*"
  8.                     0
  9.           )
  10.   )
  11.   (if a
  12.     (progn
  13.       (setq filesPathDefault a
  14.             LSP              (read_Bin a)
  15.             isUnnec          (and (= (car LSP) 13) (= (cadr LSP) 10))
  16.             exten            (vl-filename-extension a)
  17.             fnanme           (vl-string-trim exten a)
  18.             newFilesName     (strcat fnanme "_mod" exten)
  19.       )
  20.       (if isUnnec
  21.         (progn
  22.           (write_Bin (cddr LSP) newFilesName)
  23.           (princ "\n文件首字节已删除,保存在 ")
  24.           (princ newFilesName)
  25.         )
  26.         (princ "文件首字节不符合删除要求")
  27.       )
  28.     )
  29.   )
  30.   (princ)
  31. )


  32. (defun write_Bin (Blist file / ADO vbin)
  33.   (setq vbin (vlax-make-safearray 17 (cons 0 (1- (length Blist)))))
  34.   (vlax-safearray-fill vbin Blist)
  35.   (vlax-make-variant vbin)
  36.   (setq ADO (vlax-create-object "ADODB.Stream"))
  37.   (vlax-put-property ADO 'type 1)
  38.   (vlax-invoke-method ADO 'open 'nil 'nil 'nil 'nil 'nil)
  39.   (vlax-invoke-method ADO 'Write vbin)
  40.   (vlax-invoke-method ADO 'saveToFile file 2)
  41.   (vlax-invoke-method ADO 'close)
  42.   (vlax-release-object ADO)
  43. )


  44. (defun read_Bin (file / vbin ADO)
  45.   (setq ADO (vlax-create-object "ADODB.Stream"))
  46.   (vlax-put-property ADO 'type 1)
  47.   (vlax-invoke-method ADO 'open 'nil 'nil 'nil 'nil 'nil)
  48.   (vlax-invoke-method ADO 'LoadFromFile file)
  49.   (setq vbin (vlax-invoke-method ADO 'read 'nil))
  50.   (vlax-invoke-method ADO 'close)
  51.   (vlax-release-object ADO)
  52.   (vlax-safearray->list (vlax-variant-value vbin))
  53. )

  54. (princ "载入成功,命令:deletebyte")
  55. (princ)

评分

参与人数 3明经币 +3 收起 理由
wanghangshun + 1 赞一个!
bssurvey + 1 赞一个!
tigcat + 1 感谢Y版分享程序

查看全部评分

"觉得好,就打赏"
还没有人打赏,支持一下
发表于 2021-12-19 19:50 | 显示全部楼层
很不错的lsp程序

点评

yxp
0D0A 就是换行回车 \r\n 的编码,不明白为啥要加这个。  发表于 2021-12-19 21:29
发表于 2021-12-19 20:23 | 显示全部楼层
666不错的lsp
发表于 2021-12-20 07:35 | 显示全部楼层
很不錯的lsp程序
发表于 2021-12-20 12:52 | 显示全部楼层
感谢y版的修复工具
发表于 2021-12-20 22:26 | 显示全部楼层

很不錯的lsp程序
发表于 2021-12-21 09:18 | 显示全部楼层
本帖最后由 429014673 于 2021-12-21 09:57 编辑

chrome浏览器用Internet Download Manager下载,不用搞修复这回事,一点问题都没有
发表于 2021-12-21 10:21 | 显示全部楼层
这个也是一个大神写的,海大神的,也分享给大家!
(vl-Load-COM)
(defun try-file-ReadBinary (FileName / node size str stream xmldom)
        (setq xmldom (vlax-create-object "Microsoft.XMLDOM"))
        (setq node (vlax-invoke-method xmldom 'CreateElement "binary"))
        (vlax-put-Property node 'DataType "bin.hex")
        (setq stream (vlax-create-object "ADODB.Stream"))
        (vlax-put-Property stream 'type 1)
        (Vlax-Invoke stream 'open)
        (vlax-invoke-method
                stream
                'LoadFromFile
                FileName
        )
        (setq size(vlax-get-Property stream 'size))
        (vlax-put-Property node 'NodeTypedValue (Vlax-Invoke-Method stream 'Read size))
        (Vlax-Invoke-Method stream 'close)
        (setq str (vlax-get-Property node 'text))
        (vlax-release-object xmldom)
        str
)
(defun try-file-WriteBinary (file str / node stream xmldom)
        (setq xmldom (vlax-create-object "Microsoft.XMLDOM"))
        (setq node (vlax-invoke-method xmldom 'CreateElement "binary"))
        (vlax-put-Property node 'DataType "bin.hex")
        (vlax-put-Property node 'Text str)
        (setq stream (vlax-create-object "ADODB.Stream"))
        (vlax-put-Property stream 'type 1)
        (Vlax-Invoke stream 'open)
        (vlax-invoke-method stream 'write
                (vlax-get-Property node 'NodeTypedValue)
        )
        (vlax-invoke-method stream 'saveToFile file 2)
        (Vlax-Invoke-Method stream 'close)
        (vlax-release-object xmldom)
        (vlax-release-object stream)
)
(defun c:mjtd (/ file h16 h16-2 newfile)
        (setq file(getfiled "选择一个文件" "" "*" 0))
        (or file (exit))
        (setq
                h16(try-file-ReadBinary file)
                h16-2(substr h16 5)
        )
        (setq newfile (strcat(vl-filename-directory file)"\\"(vl-filename-base file)"_new"(vl-filename-extension file)))
        (try-file-WriteBinary newfile h16-2)
        (princ(strcat"\n处理完成,生成新文件"newfile))(princ)
)
发表于 2021-12-21 10:28 | 显示全部楼层
大神的ssget总结让人受益匪浅
发表于 2021-12-21 14:12 | 显示全部楼层
不错不错,收藏使用了
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-2 10:07 , Processed in 3.535140 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表