Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Modifying Shortcuts (.LNK) under VB5

Posted on 1998-07-08
5
Medium Priority
?
439 Views
Last Modified: 2012-05-05
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
Comment
Question by:ImmanuelOnse
5 Comments
 
LVL 7

Expert Comment

by:tward
ID: 1465267
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
 
LVL 6

Expert Comment

by:clifABB
ID: 1465268
There are API functions for this in "STKIT432.DLL" or "STKIT532.DLL".
0
 
LVL 7

Expert Comment

by:tward
ID: 1465269
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
 
LVL 9

Accepted Solution

by:
cymbolic earned 100 total points
ID: 1465270
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
 

Author Comment

by:ImmanuelOnse
ID: 1465271
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

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

879 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question