|
|
Создание ярлыка на текущее приложение с ключами /decompile /compact (в папке приложения)
Option Compare Database
Option Explicit
Private Sub CreateDecompile_and_Compact_Shortcut()
Dim sAppIconPathNo As String
Dim iWindowStyle As Integer
Dim sMSAccessPath$, sMSAccessFolder$, sPathToRunFile$
Dim s$
Dim sLNKPath$
s = CurrentProject.path & "\* - Decompile*.lnk"
If Dir(s) <> "" Then Kill (s)
s = CurrentProject.path & "\* - Compact*.lnk"
If Dir(s) <> "" Then Kill (s)
sLNKPath = CurrentDb.Name & " - Decompile and Compact.lnk"
sMSAccessPath = SysCmd(acSysCmdAccessDir) & "msaccess.exe"
sMSAccessFolder = FolderByPath(sMSAccessPath)
iWindowStyle = 7
sPathToRunFile = """" & CurrentProject.path & "\" & CurrentProject.Name & """"
sAppIconPathNo = sMSAccessPath & ",0"
CreateShortcut sLNKPath, sMSAccessPath, sMSAccessFolder, sAppIconPathNo, , sPathToRunFile & " /decompile /compact", , iWindowStyle
sLNKPath = CurrentDb.Name & " - Decompile Only.lnk"
CreateShortcut sLNKPath, sMSAccessPath, sMSAccessFolder, sAppIconPathNo, , sPathToRunFile & " /decompile", , iWindowStyle
sLNKPath = CurrentDb.Name & " - Compact Only.lnk"
CreateShortcut sLNKPath, sMSAccessPath, sMSAccessFolder, sAppIconPathNo, , sPathToRunFile & " /compact", , iWindowStyle
End Sub
Private Sub CreateShortcut(ByRef ShortcutPath As String, ByRef STargetCommand As String, _
ByRef SWorkingDirectory As String, Optional ByRef SHIconPath As String = "", _
Optional ByRef HotKey As String = "", Optional ByRef SArguments As String = "", _
Optional ByRef SHDescription As String = "", Optional ByRef WindowStyle As Integer = vbNormalFocus)
Dim WshShell As Object
Dim oShellLink As Object
Dim sLinkPath As String
Set WshShell = CreateObject("WScript.Shell")
On Error GoTo 0
Set oShellLink = WshShell.CreateShortcut(ShortcutPath)
With oShellLink
.TargetPath = STargetCommand
.Arguments = SArguments
.WorkingDirectory = SWorkingDirectory
.IconLocation = SHIconPath
.HotKey = HotKey
.WindowStyle = WindowStyle
.Description = SHDescription
.Save
End With
Set oShellLink = Nothing
Set WshShell = Nothing
End Sub
Public Function FolderByPath(varPath As Variant, Optional bolRetNoSlash As Boolean = False) As String
On Error GoTo FolderByPath_Err
FolderByPath = Mid(varPath, 1, InStrRev(varPath, "\"))
If Dir(FolderByPath, vbDirectory) = "" Then FolderByPath = "C:"
If bolRetNoSlash = True Then
If Right(FolderByPath, 1) = "\" Then
FolderByPath = Mid(FolderByPath, 1, Len(FolderByPath) - 1)
End If
End If
FolderByPath_Bye:
Exit Function
FolderByPath_Err:
If bolRetNoSlash = False Then
FolderByPath = "C:\"
Else
FolderByPath = "C:"
End If
Resume FolderByPath_Bye
End Function
|
|