Option Explicit
Private Const LINK_FILE = "LINKER.EXE"
Dim FSO As FileSystemObject
Private Sub cmdCancel_Click()
Open App.Path & "\LinkerLog.txt" For Append As #1
Print #1, Now & ": ============================================"
Print #1, Now & ": Command Line Options: "; Command$
Print #1, Now & ": ============================================"
Print #1, vbCrLf & vbCrLf
Close #1
ShellWait App.Path & "\" & LINK_FILE & ".exe " & Command$
Unload Me
End Sub
Private Sub CmdOk_Click()
Dim CmdLine As String
CmdLine = Command$
CmdLine = Replace(CmdLine, "/ENTRY:__vbaS", "/ENTRY:DLLMain") ' BookMark #1
CmdLine = Replace(CmdLine, "/BASE:0x400000", "/BASE:0x10000000")
CmdLine = CmdLine & " /DLL /DEF:" & """" & txtCompiler.Text & """"
If Len(Dir(txtCompiler.Text, vbNormal)) <= 0 Then
MsgBox "No such DEF file.. please verify again!"
Exit Sub
End If
LINK CmdLine
End Sub
Private Sub Form_Load()
Dim intPos As Integer
Dim strPath As String
Dim fld As Folder
Dim fil As File
Set FSO = New FileSystemObject
' Determine if .DEF file exists
'
' Extract path from first .obj argument
intPos = InStr(1, Command$, ".OBJ", vbTextCompare)
strPath = Mid$(Command$, 2, intPos + 2)
intPos = InStrRev(strPath, "\")
strPath = Trim$(Left$(strPath, intPos - 1))
strPath = Replace$(strPath, """", "")
Debug.Print strPath
' MsgBox "Path=" & strPath
' Open folder
Set fld = FSO.GetFolder(strPath)
' MsgBox fld.Path
' Get files in folder
For Each fil In fld.Files
' MsgBox fil
If UCase$(FSO.GetExtensionName(fil)) = "DEF" Then
txtCompiler.Text = fil
Exit For
End If
Next
If txtCompiler.Text = vbNullString Then
LINK ' Default
Else
If MsgBox("Click Yes to apply DLL options over a Standard EXE Project," & vbCrLf & "otherwise click No to let VB handle the usual way.", vbYesNo) = vbNo Then
LINK ' Default
End If
End If
End Sub
Sub LINK(Optional CmdLine As String = vbNullString)
If CmdLine = vbNullString Then CmdLine = Command$
If CmdLine = vbNullString Then
Unload Me
Exit Sub
End If
Open App.Path & "\LinkerLog.txt" For Append As #1
Print #1, Now & ": ============================================"
Print #1, Now & ": Command Line Options: "; Command$
If CmdLine <> Command$ Then
Print #1, Now & ": Command Line Options: "; CmdLine ' Write only if there was a change
End If
Print #1, Now & ": ============================================"
Print #1, vbCrLf & vbCrLf
Close #1
ShellWait App.Path & "\" & LINK_FILE & " " & CmdLine ' i.e.: My SuperShell function
Unload Me
End Sub