tags:

views:

924

answers:

6
A: 

Looking around on creating shortcuts, looks like there's a lot of jumping through hoops with scripting objects. But am I missing something? If you have a path to the shortcut, the name should be exactly what you find in the path, not some attribute you have to look up.

 Dim f As FileInfo = New FileInfo("C:\Name of shortcut.lnk")
 Dim title As String = f.Name.Replace(".lnk", String.Empty)
Joshua Belden
NO, I don't need the filename. Thanks for your reply.to get the filename without i will use 'Path.GetFileNameWithoutExtension'
Cooper.Wu
A: 

Please define "title". The only attributes that sound relevent are the shortcut's file name, the target's file name, and the .lnk file's description data.

Anonymous
@Anon, answers aren't generally to be used as a discussion board. This is better left as a comment to the question - you risk downvotes by doing this (not from me since I'm lenient with newcomers).
paxdiablo
I asked for clarification. If this was more appropriate for a comment, then you're saying I'm not allowed to ask for clarification? Comments require 50 "reputation", and "answers" do not. Please explain exactly what I should be doing differently.
Anonymous
This clarification has already been requested in the comments.
paxdiablo
It wasn't there when I posted this. My question stands.
Anonymous
Really? It says 16mins ago, your "answer" was 11mins ago. I hope it didn't take 5 minutes to type that in.
paxdiablo
Between researching the question and typing in this text box that slows down every keypress, yes it took over five minutes to _respond_ to the question.
Anonymous
Yes, you cannot ask for clarification in answers. If you don't have enough repuration to post a comment, you cannot ask for clarification at all. The world isn't fair :)
Sander
The world is poorly-documented and uses Javascript when it doesn't have to. That doesn't mean every site should follow the example.
Anonymous
A: 

Assuming you mean the title of the file the link points to, not the link itself, and that you are talking about Windows, then it's done via a feature in NTFS, alternative streams. You can access those streams using code in this article.

JRL
+1  A: 

It sounds like you might be trying to get the title of the file the link points to, as JRL suggests.

If you're not trying to do that, I'd recommend opening up one of these .lnk files in a hex editor like XVI32. You can probably tell from there whether the Chinese name displayed is embedded in the .lnk file or is somewhere else.

If it's somewhere else, it may be an Extended File Property. There's some source code that may help with retrieving that info: Extended File Properties

If by some chance it is inside the .lnk file, I recommend looking at the Windows Shortcut Specification to get offset information and such on the location of that data.

Steven Richards
+1  A: 

There is a Desktop.ini hidden file in shortcuts directory, the Desktop.ini file records display strings info of shortcuts.

Desktop.ini file sample:

 [LocalizedFileNames]
Windows Update.lnk=@%SystemRoot%\system32\wucltux.dll,-1
Default Programs.lnk=@%SystemRoot%\system32\sud.dll,-1
Cooper.Wu
Good find! Does that give you your answer, or are you still looking for a way to get at the string?
Steven Richards
@Steven Richards, i have wrote some demo code to implement. there is no question to get the strings.
Cooper.Wu
A: 

You can use the property system APIs in latest relase of Code pack:

(all the 670+ properties in the system are accesible using simple property accessors)

http://code.msdn.microsoft.com/WindowsAPICodePack

I know your current need is only limited title of lnk files. Using the above library, the sample code might look like:

ShellLink myLink = ShellObject.FromParsingName("c:\somepath\myLink.lnk");

string title = myLink.Properties.System.Title.Value;

// This is what its pointing to... string target = myLink.Properties.System.TargetParsingPath.Value;

Keeron
Yes, this will solve problem too. Thanks.
Cooper.Wu