Click here to Skip to main content
15,886,026 members
Articles / Programming Languages / C++

Project Line Counter Add-In v2.10 for VS.NET and VC6

Rate me:
Please Sign up or sign in to vote.
4.92/5 (38 votes)
29 Jun 2003 447.9K   5.3K   142  
Get statistics about your source code with a click of a button
Dim Shell
Set Shell = CreateObject("WScript.Shell")
Dim FSO
Set FSO = CreateObject("Scripting.FileSystemObject")

Title = "PLC Installer"

Call Install

Sub Install
	If (MsgBox("This will install Project Line Counter.  Do you wish to continue?", 4, Title) <> 6) Then Exit Sub
	
	MsgBox "Please close all running instances of VC++ and VS.NET!", 48, Title

	' Get target directory
	ProgramFiles = "C:\Program Files"
	Targ = ProgramFiles + "\WndTabs.com\LineCount"
	Targ = InputBox("Enter target directory", Title, Targ)
	If (Len(Targ) = 0) Then Exit Sub

	' Create the target directory
	Dim pathParts
	pathParts = Split(Targ, "\")
	S = ""
	For Each Part in PathParts
		S = S + Part
		MakeDir S
		S = S + "\"
	Next

	' Create 'Reports' directory
	MakeDir S + "Reports"

	' Files to copy
	Dim files(1)
	files(0) = "PLC.txt"
	files(1) = "License.txt"

	' Copy the files
	For Each File In Files 
		' Check if we're talking about a directory
		If Fso.FolderExists(File) Then
			' It's a directory
			FSO.CopyFolder File, Targ & "\" & File, True
		Else
			' It's a file
			FSO.CopyFile File, Targ & "\" & File, True
		End If
	Next
	
	' Extract the files from the cabinets
	DoExpand "expand LineCount.cab -F:*.* """ & Targ & """"
	DoExpand "expand Reports.cab -F:*.* """ & Targ & "\Reports"""
	
	' Register the addin
	CmdLine = "RegSvr32 /s """ & Targ & "\LineCount.dll"""
	Err = Shell.Run(CmdLine,, True)
	If (Err <> 0) Then
		MsgBox "There was an error registering the component server.  The command line was: " & _
			vbCRLF & vbCRLF & CmdLine & vbCRLF & vbCRLF & _
			"Please ensure that the ""regsvr32"" program is on your path.", 16, Title
		Exit Sub
	End If

	' Workspace Whiz! Interface
	If (MsgBox( _
		"Would you like to install the Workspace Whiz! Interface at this time?" & vbCRLF & _
		"The interface is required for VC5/6, but not for Visual Studio .NET."  & vbCRLF & _
		vbCRLF & _
		"Answer ""No"" if you already have Workspace Whiz! installed", 4, Title) = 6) Then
		
		Shell.Run WWhizIntInstaller,, True
		
	End If 
	
	
	' Finished...
	MsgBox "Installation Complete." & vbCRLF & vbCRLF & _
		"You will see a PLC toolbar next time you run VC/VS.NET", , _
		Title
End Sub

Sub DoExpand(CmdLine)
	Err = Shell.Run(CmdLine,, True)
	If (Err <> 0) Then
		MsgBox "There was an error expanding the cabinet file.  The command line was: " & _
			vbCRLF & vbCRLF & CmdLine & vbCRLF & vbCRLF & _
			"Please ensure that the operating system's ""expand"" program is on your path.", 16, Title
		Exit Sub
	End If
End Sub

Sub MakeDir(Dir)
	On Error Resume Next
	FSO.CreateFolder(Dir)
	On Error Goto 0
End Sub

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Experion
Canada Canada
You may know Oz from his WndTabs days. Oz has long since left client side development to work on web technologies and to consult in the R&D management field.

Comments and Discussions