Results 1 to 4 of 4
  1. #1
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    NJ, USA
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Creating a desktop icon on a package deployment (Access 2K)

    I am packaging a small database with manual and icon to a company via the Internet. I want to have an icon placed automatically on the desktop. Is there a simple way of doing this? If so how do I do it?

    Thanks. Fay

  2. #2
    3 Star Lounger
    Join Date
    Jun 2001
    Location
    Salem, Oregon, USA
    Posts
    219
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Creating a desktop icon on a package deployment (Access 2K)

    I don't know if this would work, although I can't see why it wouldn't -- if you are using Microsoft's Developer package, you are offered the opportunity to run a program after the install completes -- could you perhaps include in the install, the icon and a batch file to run, that simply and merely copies the icon from one location to the desktop -- if you know the path of the user's desktop?

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Creating a desktop icon on a package deployment (Access 2K)

    There actually is a knowledge base article on this MOD2000: How to Create a Desktop Shortcut for Your Solution that uses a workaround to create a desktop icon. Unfortunately is is cumbersome, clumsy and may or may not work depending on the version of Windows being run at the other end, so I don't really recommend it. I tried the same technique with Access 97 and had no luck with it on Win95 and Win98 machines. One of the 3rd party installers like Wise and Installshield will do this for you easily but it isn't a simple task to do it with the packaging wizard, assuming you can make it work at all. I'd suggest you settle for the item in the Programs listing instead.
    Charlotte

  4. #4
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Creating a desktop icon on a package deployment (Access 2K)

    For anyone interested, recommend using the Windows Script Host (WSH) CreateShortcut method. This is simplest method available (unless you'd rather tangle with the Microsoft Windows Installer (MSI)) and works in Windows 98 or later. Example:

    Public Sub CreateNewShortcutEx(ByRef strShortcutName As String, _
    ByRef strAppPath As String, _
    ByRef strUserName As String)

    ' REF: Windows Script Host Object Model (Ver 1.0)
    ' LIBRARY: IWshRuntimeLibrary
    ' FILE: C:WINDOWSSYSTEMWSHOM.OCX
    ' strShortcutName: File name for shortcut w/o the ".LNK" extension
    ' strAppPath: full path to app installation folder
    ' strUserName: Security acct UserName
    ' NOTE: This will overwrite any existing shortcut w/same name

    Dim wsh As New IWshShell_Class
    Dim shortcut As IWshShortcut_Class
    Dim strDesktopPath As String

    strDesktopPath = apiGetDesktopPathUser

    Set shortcut = wsh.CreateShortcut(strDesktopPath & strShortcutName & ".LNK")
    With shortcut
    ' Use Chr() function to add double-quotes if space in path
    .TargetPath = Chr(34) & Application.SysCmd(acSysCmdAccessDir) & _
    "MSACCESS.EXE" & Chr(34)
    .Arguments = Chr(34) & strAppPath & "AppMyApp.mde" & Chr(34) & " " & _
    "/WRKGRP " & Chr(34) & strAppPath & "AppMyApp.mdw" & Chr(34) & " " & _
    "/USER " & strUserName

    .IconLocation = strAppPath & "IconsMyAppIcon.ico"
    .Description = strShortcutName
    .WindowStyle = WshMaximizedFocus
    .Save
    End With

    Set wsh = Nothing
    Set shortcut = Nothing

    End Sub

    To use this method, set a reference to WSH as noted in comments. Note this shortcut is intended for secured db, thus includes path to workgroup file. The Access SysCmd function returns correct path to current installation of Office (even if more than one version installed). For this to work, you need reliable method to get path to user's Windows desktop on target machine. Declare the following Windows API function, type definition, and constant declarations:

    Public Declare Function SHGetSpecialFolderLocation Lib _
    "Shell32.dll" (ByVal hWndOwner As Long, ByVal nFolder As Long, _
    pidl As ItemIDList) As Long

    Public Declare Function SHGetPathFromIDList Lib "Shell32.dll" _
    (ByVal pidl As Long, ByVal pszPath As String) As Long

    ' SHGetSpecialFolderLocation ID List structure defs:
    Public Type ShortItemId
    cb As Long
    abID As Byte
    End Type

    Public Type ItemIDList
    mkid As ShortItemId
    End Type

    ' Constants:
    Const CSIDL_STARTMENU = &HB
    Const CSIDL_DESKTOPDIRECTORY = &H10
    Const CSIDL_COMMON_DESKTOPDIRECTORY = &H19

    The CreateShortcut sub calls this function:

    Public Function apiGetDesktopPathUser() As String
    apiGetDesktopPathUser = GetSpecialFolder(CSIDL_DESKTOPDIRECTORY)
    End Function

    GetSpecialFolder function:

    Function GetSpecialFolder(ByVal CSIDL As Long) As String

    Dim lngIDL As Long
    Dim strPath As String
    Dim idl As ItemIDList ' structure
    Const NOERROR = 0
    Const MAX_LENGTH = 260

    ' Fill the idl structure with the specified folder item:
    lngIDL = SHGetSpecialFolderLocation(Application.hWndAccessA pp, CSIDL, IDL)

    If lngIDL = NOERROR Then
    ' Get the path from the IDL list
    strPath = Space$(MAX_LENGTH)
    lngIDL = SHGetPathFromIDList(ByVal idl.mkid.cb, ByVal strPath)

    If lngIDL Then
    GetSpecialFolder = Left$(strPath, InStr(strPath, Chr$(0)) - 1) & ""
    End If
    End If

    End Function

    As shown above, in typical WIN API fashion, getting desktop path in Windows is more convoluted than needs to be, with arcane data structures, etc. Some code originally from MSKB article referenced, but had to be modified to avoid errors - ByVal/ByRef mismatches, etc. The above functions work correctly in WIN 98, WIN 2K, & WIN XP, allowing you to create desktop shortcut in reliable fashion.

    HTH

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •