将AStyle集成到VC++7.1.rar
 
' * --------------------------------------------------------------------
' * File Name   : 将AStyle集成到VC++.vbs   
' * Description : NULL 
' * Author      : 淡月清风   
' * Edited      : 2009年2月8日21:39:02       

Option Explicit   
  
On Error Resume Next  
  
Const DEF_AStyleDirectory   = "D:\Program Files\AStyle"  
Const DEF_RegPath  = "HKCU\Software\Microsoft\VisualStudio\7.1\External Tools\"
'Const DEF_RegPath  = "HKCU\Software\Microsoft\VisualStudio\9.0\External Tools\"  
Const DEF_MsgBoxTitle       = "提示 - 淡月清风"  
 
Dim objFso,objWshShell,ToolNumKeys  
Dim IsInstalled  
 
Dim AStyleParameters  
 
AStyleParameters = ""  
AStyleParameters = AStyleParameters & " --style=ansi"  
AStyleParameters = AStyleParameters & " --mode=c"  
AStyleParameters = AStyleParameters & " --force-indent=tab=4"   ' -T4  
AStyleParameters = AStyleParameters & " --brackets=break"       ' -b 
AStyleParameters = AStyleParameters & " --indent-cases"         ' -K  
AStyleParameters = AStyleParameters & " --indent-namespaces"    ' -N  
AStyleParameters = AStyleParameters & " --indent-preprocessor"  ' -w  
'AStyleParameters = AStyleParameters & " --break-blocks=all"    ' -F  
'AStyleParameters = AStyleParameters & " --pad=paren-in"        ' -D  
AStyleParameters = AStyleParameters & " --pad=oper"             ' -p  
AStyleParameters = AStyleParameters & " --fill-empty-lines"     ' -E  
AStyleParameters = AStyleParameters & " --verbose"              ' -v  
 
Set objFso=CreateObject("Scripting.FileSystemObject")  
 
If Not objFso.FolderExists(DEF_AStyleDirectory) Then  
  objFso.CreateFolder(DEF_AStyleDirectory)  
End If  
 
If Not objFso.FileExists(DEF_AStyleDirectory & "\AStyle.exe") Then  
  objFso.CopyFile "AStyle.exe",DEF_AStyleDirectory & "\AStyle.exe"  
End If  
 
Set objWshShell = WScript.CreateObject("WScript.Shell")  
ToolNumKeys = objWshShell.RegRead(DEF_RegPath & "ToolNumKeys")  
 
'判断当前是否已经安装了AStyle  
Dim OrgToolCmd  
OrgToolCmd = objWshShell.RegRead(DEF_RegPath & "ToolCmd" & ToolNumKeys-1)  
If OrgToolCmd = DEF_AStyleDirectory & "\AStyle.exe" Then  
  '覆盖  
  ToolNumKeys = ToolNumKeys - 1  
  IsInstalled = true  
Else  
  '新增  
  ToolNumKeys=ToolNumKeys  
  IsInstalled = false  
End If  
 
'1.ToolCmd  
Dim ToolCmd,ParamToolCmd  
ToolCmd="ToolCmd" & ToolNumKeys  
ParamToolCmd=DEF_AStyleDirectory & "\AStyle.exe"  
objWshShell.RegWrite DEF_RegPath & ToolCmd,ParamToolCmd,"REG_SZ"  
 
'2.ToolArg  
Dim ToolArg,ParamToolArg  
ToolArg="ToolArg" & ToolNumKeys  
ParamToolArg="$(ItemFileName)$(ItemExt)" & AStyleParameters  
objWshShell.RegWrite DEF_RegPath & ToolArg,ParamToolArg,"REG_SZ"  
 
'3.ToolDir  
Dim ToolDir,ParamToolDir  
ToolDir="ToolDir" & ToolNumKeys  
ParamToolDir="$(ItemDir)"  
objWshShell.RegWrite DEF_RegPath & ToolDir,ParamToolDir,"REG_SZ"  
 
'4.ToolOpt  
Dim ToolOpt,ParamToolOpt  
ToolOpt="ToolOpt" & ToolNumKeys  
ParamToolOpt=26  
objWshShell.RegWrite DEF_RegPath & ToolOpt,ParamToolOpt,"REG_DWORD"  
 
'5.ToolSourceKey  
Dim ToolSourceKey,ParamToolSourceKey  
ToolSourceKey="ToolSourceKey" & ToolNumKeys  
ParamToolSourceKey=""  
objWshShell.RegWrite DEF_RegPath & ToolSourceKey,ParamToolSourceKey,"REG_SZ"  
 
'6.ToolTitle  
Dim ToolTitle,ParamToolTitle  
ToolTitle="ToolTitle" & ToolNumKeys  
ParamToolTitle="AStyle 1.22代码格式化(&A)"  
objWshShell.RegWrite DEF_RegPath & ToolTitle,ParamToolTitle,"REG_SZ"  
 
'X.写入外部工具计数  
objWshShell.RegWrite DEF_RegPath & "ToolNumKeys",ToolNumKeys + 1,"REG_DWORD"  
 
Dim InfoText  
If Err.Number = 0 Then  
 If IsInstalled Then  
    InfoText="您已经重新安装了AStyle 1.22代码格式化工具!"  
 Else  
    InfoText="成功安装了AStyle 1.22代码格式化工具!"  
 End If  
 MsgBox InfoText,48,DEF_MsgBoxTitle  
Else  
 MsgBox "发生错误:" & Err.Number,48,DEF_MsgBoxTitle   
End If

本文链接地址: 将AStyle集成到VC++7.1
https://blog.qingfengju.com/index.asp?id=16

上一篇: 语法高亮编辑控件Scintilla在MFC中的简单使用之完整示例
下一篇: 甲型H1N1流感(猪流感)防护手册

分类:脚本编程 查看次数:9448 发布时间:2009/5/12 18:28:11