• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 440
  • Last Modified:

Modifying Shortcuts (.LNK) under VB5

How can a VB5 program under W95/NT4
1) read in details of a shortcut (.lnk) file, ie target, command params
2) write & save details to shortcut (.lnk) file, ie change target.
?
I already know how to LAUNCH shortcuts, I need to know how to MODIFY shortcut (.LNK) files
0
ImmanuelOnse
Asked:
ImmanuelOnse
1 Solution
 
twardCommented:
The only way I can see to do it is to write a C DLL Function to do it as there are no API Functions that I see to do it.
0
 
clifABBCommented:
There are API functions for this in "STKIT432.DLL" or "STKIT532.DLL".
0
 
twardCommented:
Are they to Modify or just Create?

I do know there is the fCreateShellLink but will that allow a modification?  I guess you could fRemoveShellLink and then
fCreateShellLink?
0
 
cymbolicCommented:
You can read a .lnk file in for binary in VB, and examine it to get the information you want.  THen delete the old one and create a modified new one.  There is a consistent format in the .lnk file.  Use a decent file viewer, like the LIST.COM program written by Verne Buerg.  It has a hex viewing option that will allow you to see all bytes of a .lnk file and give you enough info to break one down in code to pick out the pieces.  Notepad ain't worth whale poop for something like this!
0
 
ImmanuelOnseAuthor Commented:
Soln: refer VB 5 CD in \Tools\Unsupprt\ShellLnk

I'm writing a program which starts at a given dir & then modifies shortcuts in subdirs down the tree. If a shortcut refers to K:\MSOFFICE it is modified to C:\Program Files\MSOffice, otherwise shortcuts are left alone.

cymbolic has gone for a brute-force approach. This I already knew was possible for reading shortcuts in. Even Notepad showed the necc strings in the file, so I could have just openned the file directly & searched for K:\MSOffice & gone on from there. I also knew that the MICROSOFT way to do this is through OLE. Refer: MSDN CD2 - Chapter 9 of "Programming the W95 User Interface". What I didn't have was a way to do this from VB5.

As this will be done to 18000 users where I work I need to do it in a manner which will be approved by my team & by our MS Rep

clifABB & tward are the closest to what I needed.

Since posting my question I have found references to "STKIT432.DLL", "shlobj" & in particular MS KB articles (C code)
Q130698 How to: obtain filename & path from a shell link or shortcut
Q179904 How to: change the icon of a shortcut through IShellLink
Q155303 How to: create shortcuts (shell links) within windows
Q140443 How to: create a  shortcut on the desktop

While hunting references over at Carl & Gary's VB page I found an excerpt from comp.lang.basic.visual.misc "Re: Creating .lnk and .pif files" posted by MDT. It mentioned the example on the VB 5 CD in \Tools\Unsupprt\ShellLnk This example, & TestSLnk within it, do everything needed for creating & modifying shortcuts
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now