|
-
Feb 3rd, 2006, 02:39 PM
#1
Thread Starter
Fanatic Member
how to update an existing desktop shortcut?
How do I update or change the target of an existing desktop shortcut when my application runs using VB6.
He who never made a mistake never made a discovery?
-
Feb 3rd, 2006, 03:05 PM
#2
Re: how to update an existing desktop shortcut?
-
Feb 3rd, 2006, 03:22 PM
#3
Thread Starter
Fanatic Member
Re: how to update an existing desktop shortcut?
I think this is helpful, but I am not creating the shortcut with VB, the shortcut already exist. I just want to modify the existing short using VB.
How would I do that using eny of those examples?
He who never made a mistake never made a discovery?
-
Feb 3rd, 2006, 03:24 PM
#4
Re: how to update an existing desktop shortcut?
If you call the same process again with a different path, it will modify the existing shortcut rather than create a new one, providing that the name of the shortcut does NOT change.
you have to scroll down to the bottom for more information (which is normally hidden - that's the reason i've linked to google's page cache )
-
Feb 3rd, 2006, 03:55 PM
#5
Thread Starter
Fanatic Member
Re: how to update an existing desktop shortcut?
I tried this and it created a new short cut. I am not sure what part just does the updating?
VB Code:
'modify flash shortcut on desktop
Dim strGroupName As String, strLinkName As String
Dim strLinkPath As String, strLinkArguments As String
Dim fPrivate As Boolean, sParent As String
Dim fSuccess As Boolean
strLinkName = "Agent Prospecting Presentation"
strLinkPath = "c:\MyWestfieldPresentation\Westfield_1to1F_v1.exe"
strLinkArguments = ""
fPrivate = True ' Add shortcut to desktop.
strGroupName = "..\..\Desktop"
sParent = "$(Programs)"
fSuccess = fCreateShellLink(strGroupName & vbNullChar, strLinkName, strLinkPath, strLinkArguments & vbNullChar, fPrivate, sParent)
He who never made a mistake never made a discovery?
-
Feb 3rd, 2006, 04:04 PM
#6
Re: how to update an existing desktop shortcut?
if a shortcut called "Agent Prospecting Presentation" already exists on the desktop then it just replaces it with the link you specified instead of creating a new one.
if you have a shortcut "Agent Prospecting Presentation" which links to "C:\windows\notepad.exe" and then run your code it'll replace it
-
Feb 3rd, 2006, 04:13 PM
#7
Thread Starter
Fanatic Member
Re: how to update an existing desktop shortcut?
But thats not what happened. My shortcut already exist on the desktop. It's currently pointing to a different exe. When I ran the code it created a new shortcut, so now I have 2 shortcuts on the desktop.
He who never made a mistake never made a discovery?
-
Feb 3rd, 2006, 04:29 PM
#8
Re: how to update an existing desktop shortcut?
that's strange, it works perfectly for me.
so are you saying that you have two shortcuts on your desktop with exactly the same name?
-
Feb 3rd, 2006, 04:35 PM
#9
Thread Starter
Fanatic Member
Re: how to update an existing desktop shortcut?
Yep, I two shortcuts with the same name on the desktop. The properties are different but they have the same name.
He who never made a mistake never made a discovery?
-
Feb 3rd, 2006, 04:44 PM
#10
Re: how to update an existing desktop shortcut?
well i've got no explanation for that. what OS are you using, I'm running XP.
Perhaps you should just check for the shortcut, delete it and then make your new one.
-
Feb 6th, 2006, 01:29 PM
#11
Thread Starter
Fanatic Member
Re: how to update an existing desktop shortcut?
I am also running WinXP, but I was installing my app on a Win2000 OS. I don't think that would make any difference.
Deleting one and then making a new one would be accaptable. Is this the correct whay to do that?
VB Code:
If strLinkName = "Agent Prospecting Presentation" Then
Kill "c:\MyWestfieldPresentation\Westfield_1to1F_v1.exe"
Else
strLinkName = "Agent Prospecting Presentation"
strLinkPath = "c:\MyWestfieldPresentation\Westfield_1to1F_v1.exe"
strLinkArguments = ""
fPrivate = True ' Add shortcut to desktop.
strGroupName = "..\..\Desktop"
sParent = "$(Programs)"
fSuccess = fCreateShellLink(strGroupName & vbNullChar, strLinkName, strLinkPath, strLinkArguments & vbNullChar, fPrivate, sParent)
End If
He who never made a mistake never made a discovery?
-
Feb 6th, 2006, 01:49 PM
#12
Re: how to update an existing desktop shortcut?
That would delete your .exe. You just want to delete the link on the dektop 'Agent Prospecting Presentation.lnk'
Presumably you'd have to find the location of the user's desktop first, so you can kill the link - Finding Special Folders
-
Feb 6th, 2006, 02:24 PM
#13
Re: how to update an existing desktop shortcut?
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! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|