Solved

Modifying Shortcuts (.LNK) under VB5

Posted on 1998-07-08
5
403 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

840 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