[RESOLVED] Install VB6 App to Vista, desktop shortcut missing-VBForums
Results 1 to 29 of 29

Thread: [RESOLVED] Install VB6 App to Vista, desktop shortcut missing

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2007
    Posts
    17

    Resolved [RESOLVED] Install VB6 App to Vista, desktop shortcut missing

    Hello,

    I'm a newbie here, but have been kicking around in VB for more years than I like to remember.

    My question: we distribute a VB6 app that creates a desktop shortcut. At least it did so reliably on all OSs prior to Vista. No luck in Vista. The installer is a customized version of the "Setup1" program provided with the VB6 P&D Wizard.

    If this is old news, my apologies. I've searched around but could not find a thread covering it.

    Thanks in advance for any suggestions,
    M2
    Last edited by Mark II; Feb 8th, 2007 at 02:05 PM. Reason: remove "resolved"

  2. #2
    Addicted Member
    Join Date
    Jun 2006
    Location
    Egypt
    Posts
    162

    Re: Install VB6 App to Vista, desktop shortcut missing

    Welcome here

    The P & D wizard frequently fail in new windows versions , so it is rarely used now , search download.com for inno or setup2go or Windows installer.
    Mohammed Sayed - Egypt - Anesthetist



    =

    =

  3. #3
    Super Moderator Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: Install VB6 App to Vista, desktop shortcut missing

    Moved to applications deployment
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Feb 2007
    Posts
    17

    Re: Install VB6 App to Vista, desktop shortcut missing

    Mohammed,

    Thanks much. I am aware of more up-to-date installers, but the one we're using for this app (based on Setup1.exe from the P&D Wizard) works just fine with the exception of ... missing desktop shortcut when installing to Vista. I'd like to avoid creating a new installer for this app if at all possible.

    Is there some coding required to create the desktop icon when installing to Vista that was not required in prior OSs ?

    Thanks again,
    M2

  5. #5
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,083

    Re: Install VB6 App to Vista, desktop shortcut missing

    What code are you currently using to create the desktop shortcut when installing to XP?
    The user profiles are in a different location for Vista so if its looking in the old location it will fail.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Star Wars Gangsta Rap Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel Core 2 Extreme Ed., 2 WD Raptor 10K RPM 300 GB HDs, 2 GBs DDR2 667 MHz RAM, 2 Viewsonic 24" LCDs, Windows 7 SP-1/Windows 8.1, Office 2010, VS 2013

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Feb 2007
    Posts
    17

    Re: Install VB6 App to Vista, desktop shortcut missing

    Yoda,

    Here's the code. I think I'm getting a glimmer of where we're going. No hands on experience with Vista yet on my part.


    Dim lRet As Long
    Dim sFolderName As String
    Dim sLinkName As String
    Dim sLinkPath As String
    Dim sLinkArgs As String
    Dim fPrivate As Boolean
    Dim sParent As String

    sLinkName = "MyProgram"
    sLinkPath = gsDest.strAppDir & "MyProgram.exe"
    'gsDest.strAppDir, set elsewhere by user, is the folder we install to
    sLinkArgs = ""
    sParent = "$(Programs)"
    sFolderName = "..\..\desktop"
    fPrivate = True

    'observed: this works on OSs thru Win XP
    lRet = OSfCreateShellLink(sFolderName, sLinkName, sLinkPath, sLinkArgs, fPrivate, sParent)


    Thanks
    M2

  7. #7
    Addicted Member
    Join Date
    Jun 2006
    Location
    Egypt
    Posts
    162

    Re: Install VB6 App to Vista, desktop shortcut missing

    I use the same code & I remember that I faced a bug in this line once
    VB Code:
    1. sFolderName = "..\..\desktop"
    but I don't remember how I resolved it.
    Mohammed Sayed - Egypt - Anesthetist



    =

    =

  8. #8
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,083

    Re: Install VB6 App to Vista, desktop shortcut missing

    Yes, thats the problem but transversing the folder path will not work either as the Desktop folders are in completely different locations then it was under XP.

    'Private desktop...
    C:\Users\VB-Guru\Desktop

    'All users desktop...
    C:\Users\Public\Desktop
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Star Wars Gangsta Rap Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel Core 2 Extreme Ed., 2 WD Raptor 10K RPM 300 GB HDs, 2 GBs DDR2 667 MHz RAM, 2 Viewsonic 24" LCDs, Windows 7 SP-1/Windows 8.1, Office 2010, VS 2013

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Feb 2007
    Posts
    17

    Re: Install VB6 App to Vista, desktop shortcut missing

    I see.
    have I got this right? If I substitute in my code (for Vista installs) ...

    sFolderName = "C:\Users\Public\Desktop"

    Then we should generate a desktop shortcut visible to all users?
    (Or we could use the installing user's identifier to make a private shortcut.)

    Thanks again,
    M2

  10. #10
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,083

    Re: Install VB6 App to Vista, desktop shortcut missing

    Only if your user is installing the app under an Administrator profile or the Run As... with similar credentials.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Star Wars Gangsta Rap Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel Core 2 Extreme Ed., 2 WD Raptor 10K RPM 300 GB HDs, 2 GBs DDR2 667 MHz RAM, 2 Viewsonic 24" LCDs, Windows 7 SP-1/Windows 8.1, Office 2010, VS 2013

  11. #11

    Thread Starter
    Junior Member
    Join Date
    Feb 2007
    Posts
    17

    Re: Install VB6 App to Vista, desktop shortcut missing

    OK, I understand that part.

    Now if I can just find the button to mark this thread as resolved, I'm good to go.

    Thanks very much for the help.

    M2

  12. #12
    Addicted Member
    Join Date
    Jun 2006
    Location
    Egypt
    Posts
    162

    Re: [RESOLVED] Install VB6 App to Vista, desktop shortcut missing

    You must use APIs first to get the desktop path not just using a static path , a user may install Vista on his D:\ drive
    Mohammed Sayed - Egypt - Anesthetist



    =

    =

  13. #13
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,083

    Re: [RESOLVED] Install VB6 App to Vista, desktop shortcut missing

    Yes, that is correct and best to use APIs vs environment variables. In Vista there is none shown for profile path.

    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Star Wars Gangsta Rap Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel Core 2 Extreme Ed., 2 WD Raptor 10K RPM 300 GB HDs, 2 GBs DDR2 667 MHz RAM, 2 Viewsonic 24" LCDs, Windows 7 SP-1/Windows 8.1, Office 2010, VS 2013

  14. #14
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,083

    Re: [RESOLVED] Install VB6 App to Vista, desktop shortcut missing

    Just tested it on my Vista system with vb 6 code that should be simple to convert to vb.net.
    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function SHGetSpecialFolderPath Lib "shell32.dll" Alias "SHGetSpecialFolderPathA" ( _
    4. ByVal hwnd As Long, ByVal pszPath As String, ByVal csidl As Long, ByVal fCreate As Long) As Long
    5.  
    6. Private Const CSIDL_COMMON_DESKTOPDIRECTORY As Long = &H19
    7. Private Const CSIDL_DESKTOPDIRECTORY As Long = &H10
    8.  
    9. Private Sub Form_Load()
    10.     Dim strPath As String * 255
    11.     'All users desktop path
    12.     SHGetSpecialFolderPath Me.hwnd, strPath, CSIDL_COMMON_DESKTOPDIRECTORY, 0
    13.     MsgBox strPath 'C:\Users\Public\Desktop
    14.     strPath = vbNullString
    15.     'Private user desktop path
    16.     SHGetSpecialFolderPath Me.hwnd, strPath, CSIDL_DESKTOPDIRECTORY, 0
    17.     MsgBox strPath 'C:\Users\VB-Guru\Desktop
    18. End Sub

    Edit: Woot! 36,000 posts!
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Star Wars Gangsta Rap Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel Core 2 Extreme Ed., 2 WD Raptor 10K RPM 300 GB HDs, 2 GBs DDR2 667 MHz RAM, 2 Viewsonic 24" LCDs, Windows 7 SP-1/Windows 8.1, Office 2010, VS 2013

  15. #15

    Thread Starter
    Junior Member
    Join Date
    Feb 2007
    Posts
    17

    Re: [RESOLVED] Install VB6 App to Vista, desktop shortcut missing

    Great. Tested and works on XP Home Edition, SP2 with VB6 also.
    Returns ...
    C:\Documents and Settings\All Users\Desktop
    C:\Documents and Settings\user name\Desktop

  16. #16

    Thread Starter
    Junior Member
    Join Date
    Feb 2007
    Posts
    17

    Re: [RESOLVED] Install VB6 App to Vista, desktop shortcut missing

    Looks like I was premature with the "resolved" tag.

    The SHGetSpecialFolderPath call does indeed return the full path to either the public or private desktop.

    But ... taking that path and inserting it as "sFolderName" in the following ...
    lRet = OSfCreateShellLink(sFolderName, sLinkName, sLinkPath, sLinkArgs, fPrivate, sParent)
    fails to create a desktop icon on my XP machine.

    The same call works on my XP machine if I set ...
    sFolderName = "..\..\desktop"
    but that construct, it seems, does not work on a Vista machine.

    I'm stumped.
    M2

  17. #17
    Addicted Member
    Join Date
    Jun 2006
    Location
    Egypt
    Posts
    162

    Re: [RESOLVED] Install VB6 App to Vista, desktop shortcut missing

    Can you debug it to see what does the SHGetSpecialFolderPath return ?
    Mohammed Sayed - Egypt - Anesthetist



    =

    =

  18. #18

    Thread Starter
    Junior Member
    Join Date
    Feb 2007
    Posts
    17

    Re: [RESOLVED] Install VB6 App to Vista, desktop shortcut missing

    SHGetSpecialFolderPath returns either
    C:\Documents and Settings\All Users\Desktop
    or
    C:\Documents and Settings\user name\Desktop
    depending on whether public or private path is called for (on my XP machine).

    These seem just right, but do not work when inserted in the OSfCreateShellLink call.

  19. #19
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,083

    Re: [RESOLVED] Install VB6 App to Vista, desktop shortcut missing

    Perhaps wrapping the returned path with an extra set of double quotes will help since it will contain spaces which usually gives an error/headache.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Star Wars Gangsta Rap Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel Core 2 Extreme Ed., 2 WD Raptor 10K RPM 300 GB HDs, 2 GBs DDR2 667 MHz RAM, 2 Viewsonic 24" LCDs, Windows 7 SP-1/Windows 8.1, Office 2010, VS 2013

  20. #20

    Thread Starter
    Junior Member
    Join Date
    Feb 2007
    Posts
    17

    Re: [RESOLVED] Install VB6 App to Vista, desktop shortcut missing

    I read somewhere that the OSfShellLink API does not like values as arguments, only variables. My testing seems to bear that out.

    So, in making the call ...
    lRet = OSfCreateShellLink(sFolderName, sLinkName, sLinkPath, sLinkArgs, fPrivate, sParent)
    I use only variables, not string values like "xxx". The variable sFolderName has previously been set to...
    "..\..\desktop" (this works)
    or (for public desktop)
    "C:\Documents and Settings\All Users\Desktop" (this fails).

    I tried the double-qoute approach, but no luck.

    (BTW, any way to remove the "resolved" tag from a thread??)

    Thanks,
    M2

  21. #21
    Addicted Member
    Join Date
    Jun 2006
    Location
    Egypt
    Posts
    162

    Re: [RESOLVED] Install VB6 App to Vista, desktop shortcut missing

    I guess you can edit the first post to remove the Resolved mark.
    Mohammed Sayed - Egypt - Anesthetist



    =

    =

  22. #22

    Thread Starter
    Junior Member
    Join Date
    Feb 2007
    Posts
    17

    Re: Install VB6 App to Vista, desktop shortcut missing

    Thanks. I did so, but the check mark (indicating "resolved") preceding the thread title is still there.

  23. #23
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,083

    Re: Install VB6 App to Vista, desktop shortcut missing

    Change the subject icon on the first post.


    Try passing the variables as ByValue instead.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Star Wars Gangsta Rap Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel Core 2 Extreme Ed., 2 WD Raptor 10K RPM 300 GB HDs, 2 GBs DDR2 667 MHz RAM, 2 Viewsonic 24" LCDs, Windows 7 SP-1/Windows 8.1, Office 2010, VS 2013

  24. #24

    Thread Starter
    Junior Member
    Join Date
    Feb 2007
    Posts
    17

    Re: Install VB6 App to Vista, desktop shortcut missing

    Byval has no effect; failed call still fails, successful call still succeeds.

    Maybe I should try this another way:
    Does anyone know of any VB6/API code which will place a program shortcut on a Windows Vista desktop?

    I have code that works for every Windows version except Vista, and I am already testing for Vista in Setup1.exe anyway.

    Thanks,
    M2

  25. #25
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,083

    Re: Install VB6 App to Vista, desktop shortcut missing

    I have a CodeBank thread that deals with shortcut links etc.

    Maybe it will help or guide you to creating one.


    http://vbforums.com/showthread.php?t=322799
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Star Wars Gangsta Rap Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel Core 2 Extreme Ed., 2 WD Raptor 10K RPM 300 GB HDs, 2 GBs DDR2 667 MHz RAM, 2 Viewsonic 24" LCDs, Windows 7 SP-1/Windows 8.1, Office 2010, VS 2013

  26. #26

    Thread Starter
    Junior Member
    Join Date
    Feb 2007
    Posts
    17

    Re: Install VB6 App to Vista, desktop shortcut missing

    Thanks, but I don't see the makings of a solution there.

    If anyone can post some code to do this job, I'd very much appreciate it.
    M2

  27. #27

    Thread Starter
    Junior Member
    Join Date
    Feb 2007
    Posts
    17

    Re: Install VB6 App to Vista, desktop shortcut missing

    The following is reported by our users to create Public or Private desktop shortcuts on Windows XP and Vista. Have not tried it with any earlier OSs at this point.

    Getting the paths to the public and private desktop folders via "WScript.Shell" should have worked, but had trouble there so used API calls for that piece.

    Thanks to all for their suggestions.

    --------------------------------------------------------------


    Private Sub CreateDesktopShortcut(ByVal TargetPath As String, ByVal PrivateFlag As Boolean, ByVal ShortcutName As String)



    'first, get DESKTOP paths (public/private)
    'WScript.Shell not used for this piece ... seems always to return public path ??


    Const CSIDL_COMMON_DESKTOPDIRECTORY As Long = &H19
    Const CSIDL_DESKTOPDIRECTORY As Long = &H10

    Dim NullChar As String
    NullChar = Chr$(0)

    Dim i As Integer
    Dim PaddedDesktopPath As String * 255
    Dim FullDesktopPath As String


    'these calls return long strings with trailing null characters

    If Not PrivateFlag Then
    'get Public desktop path
    SHGetSpecialFolderPath Me.hwnd, PaddedDesktopPath, CSIDL_COMMON_DESKTOPDIRECTORY, 0
    Else
    'get Private user desktop path
    SHGetSpecialFolderPath Me.hwnd, PaddedDesktopPath, CSIDL_DESKTOPDIRECTORY, 0
    End If

    'get rid of null characters

    i = InStr(PaddedDesktopPath, NullChar)
    If i > 1 Then FullDesktopPath = Left(PaddedDesktopPath, i - 1)


    'for testing
    ''''''MsgBox Len(FullDesktopPath) & " " & FullDesktopPath



    'we have full path to the desktop ... public or private
    'use it to create shortcut using WScript.shell


    Dim VbsObj As Object
    Dim MyShortcut As Object

    Set VbsObj = CreateObject("WScript.Shell")

    Set MyShortcut = VbsObj.CreateShortCut(FullDesktopPath & "\" & ShortcutName & ".lnk")

    MyShortcut.TargetPath = TargetPath

    MyShortcut.save



    End Sub

  28. #28
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,083

    Re: [RESOLVED] Install VB6 App to Vista, desktop shortcut missing

    Glad to see that using some of my codebank code worked.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Star Wars Gangsta Rap Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel Core 2 Extreme Ed., 2 WD Raptor 10K RPM 300 GB HDs, 2 GBs DDR2 667 MHz RAM, 2 Viewsonic 24" LCDs, Windows 7 SP-1/Windows 8.1, Office 2010, VS 2013

  29. #29
    New Member
    Join Date
    Apr 2008
    Posts
    2

    Re: [RESOLVED] Install VB6 App to Vista, desktop shortcut missing

    Quote Originally Posted by Mark II
    Hello,

    I'm a newbie here, but have been kicking around in VB for more years than I like to remember.

    My question: we distribute a VB6 app that creates a desktop shortcut. At least it did so reliably on all OSs prior to Vista. No luck in Vista. The installer is a customized version of the "Setup1" program provided with the VB6 P&D Wizard.

    If this is old news, my apologies. I've searched around but could not find a thread covering it.

    Thanks in advance for any suggestions,
    M2
    To answer your question, I presume that your customized installer implements what is in this article: "Make P&D Wizard create Desktop shortcuts".

    The following updates are intended to fix two issues with this excellent code example:

    A) Internationalization. The article assumes that the name of the Windows desktop folder is "Desktop". The shortcut creation will fail in most non-US Windows because this is not the case.

    B) Windows Vista. The article assumes that the location of the user's Windows desktop is "{CSIDL_PROGRAMS}\..\..\Desktop". This assumption is true under (US) XP where {CSIDL_PROGRAMS} = "%SYSTEMDRIVE%\Documents and Settings\<user>\Start Menu\Programs" and {CSIDL_DESKTOP} = "%SYSTEMDRIVE%\Documents and Settings\<user>\Desktop", but is NOT true for Vista where {CSIDL_PROGRAMS} = "%SYSTEMDRIVE%\Users\<user>\AppData\Roaming\Microsoft\Windows\Start Menu" and CSIDL_DESKTOP = "%SYSTEMDRIVE\Users\<user>\Desktop". This update fixes this issue as well.

    Here are the updates to "http://www.freevbcode.com/ShowCode.asp?ID=3650" that fix these issues. In basSetup1's 'CreateIcons' Sub, add the Declarations below to the existing declarations within this sub. Next, replace the entire If-Then-End If section given in the mentioned article ("If UCase(strGroup) = "DESKTOP" Then...") with the Code snippet below.

    Declarations:

    Dim intCommonDepth As Integer
    Dim DesktopPathArr As Variant
    Dim ProgramsMenuPathArr As Variant


    Code:

    If UCase(strGroup) = "DESKTOP" Then
    DesktopPathArr = Split(GetSpecialFolder(frmSetup1.hwnd, CSIDL_DESKTOP), "\")

    'Get programs path, used in the function below
    ProgramsMenuPathArr = Split(GetSpecialFolder(frmSetup1.hwnd, CSIDL_PROGRAMS), "\")

    intCommonDepth = -1
    Do While ((intCommonDepth + 1) < UBound(DesktopPathArr)) And ((intCommonDepth + 1) < UBound(ProgramsMenuPathArr))
    If DesktopPathArr(intCommonDepth + 1) <> ProgramsMenuPathArr(intCommonDepth + 1) Then Exit Do
    intCommonDepth = intCommonDepth + 1
    Loop

    strGroup = ""
    For intIdx2 = intCommonDepth + 1 To UBound(ProgramsMenuPathArr)
    strGroup = strGroup & "..\"
    Next intIdx2

    For intIdx2 = intCommonDepth + 1 To UBound(DesktopPathArr)
    strGroup = strGroup & DesktopPathArr(intIdx2)
    If intIdx2 < UBound(DesktopPathArr) Then strGroup = strGroup & "\"
    Next intIdx2
    End If

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.