473,382 Members | 1,717 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

I'm Looking For A Control . . .

.. . . that allows me to drag and drop shortcuts on to a form. It should be
able to launch the application when the icon is double-clicked. Is there
such a control in Visual Studio 2005? Are there any third-party controls
that have this functionality?
Apr 26 '07 #1
3 1342
Hi,

You do not need a control. All you need is code like this:

System.Diagnostics.Process.Start("C:\file2run") 'use the actual path

Naturally, you could attach this code to the click event for an image or
command button (for example).

Dick

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
Apr 27 '07 #2
Thank you for the response. On your suggestion, I've tried out the "Start"
method. It looks like this is used to directly run applications or run a
document with a "File Type" association.

I was really hoping to be able to directly run a shortcut. For example, I
might want to create a shortcut to "System" on "Control Panel" or a printer
and then start that shortcut. When I tried the "Start" method out on a
shortcut it said "No application is associated with the specified file for
this operation".

Is there a similar method that works on shortcuts? Is it possible to pull
the "Target" and icon information out of a shortcut and then use "Start" to
run it? Will this also work with special shortcuts like system objects
(printers and network connections, etc.) or just documents and programs?

"Dick Grier" wrote:
Hi,

You do not need a control. All you need is code like this:

System.Diagnostics.Process.Start("C:\file2run") 'use the actual path

Naturally, you could attach this code to the click event for an image or
command button (for example).

Dick

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
Apr 30 '07 #3
I think I’m getting closer to finding what I need, but I’m not there yet.

I found this article on Shell Links:
http://msdn2.microsoft.com/en-us/library/aa969393.aspx. Basically, it says
that what I’m trying to do is “resolve” the shell link.

Searching on “resolve shell link” led me
http://msdn2.microsoft.com/en-us/library/ms630340.aspx which contains a
Visual Basic example of the resolution process. It looks like it was written
for VB 5.0 so I’ve tried to update it to a .Net version. This is what I came
up with.

Imports Shell32
Imports Shell32.ShellSpecialFolderConstants

Module Module1

Public Sub Main()

ResolveShellLink("C:\Documents and Settings\All Users\" & _
"Start Menu\Programs\Accessories", _
"Calculator.lnk")
ResolveShellLink ("C:\Documents and Settings\All Users\Desktop", _
"System.lnk")

End Sub
Private Function ResolveShellLink(PathName As String, _
ShortcutName As String) As Boolean

Dim objShell As Shell = New Shell()
If objShell Is Nothing Then Return False

Dim objFolder As Folder = objShell.NameSpace(PathName)
If objFolder Is Nothing Then Return False

Dim objFolderItem As FolderItem = objFolder.ParseName(ShortcutName)
If objFolderItem Is Nothing Then Return False

Dim objShellLink As ShellLinkObject = _
CType(objFolderItem.GetLink(), ShellLinkObject)
If objShellLink Is Nothing Then Return False

objShellLink.Resolve(1)

Return True

End Function

End Module

After adding a reference to COM module “Microsoft Shell Controls And
Automation” I was able to compile and run this code without any errors.
Unfortunately, it didn’t run “Calculator” or the shortcut to “System” that I
had placed on my desktop. What needs to be done to get this to run the
applications in the shortcuts?
"Herman Jones" wrote:
Thank you for the response. On your suggestion, I've tried out the "Start"
method. It looks like this is used to directly run applications or run a
document with a "File Type" association.

I was really hoping to be able to directly run a shortcut. For example, I
might want to create a shortcut to "System" on "Control Panel" or a printer
and then start that shortcut. When I tried the "Start" method out on a
shortcut it said "No application is associated with the specified file for
this operation".

Is there a similar method that works on shortcuts? Is it possible to pull
the "Target" and icon information out of a shortcut and then use "Start" to
run it? Will this also work with special shortcuts like system objects
(printers and network connections, etc.) or just documents and programs?

"Dick Grier" wrote:
Hi,

You do not need a control. All you need is code like this:

System.Diagnostics.Process.Start("C:\file2run") 'use the actual path

Naturally, you could attach this code to the click event for an image or
command button (for example).

Dick

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.

May 1 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Matan Holtzer | last post by:
Hello I'm looking for a replacement for the imgedit.ocx control. Up untill now, I was using this control in my application for displaying and annotating scanned tiff images (both single and...
3
by: MikeY | last post by:
Hi Everyone, I am working in C#, windows forms.My question is this. All my button dynamic controls properties are present and accounted for except for the"FlatStyle" properties. I can't seem to...
1
by: Johann Blake | last post by:
I am looking for a good solution on how to implement data access in an application so that there is a clean separation between the data access layer, the business layer and the GUI layer. I am...
4
by: Daniel Walzenbach | last post by:
Hi, I'm looking for a nice tab control in ASP.NET. I have seen the tab control MS user in their CRM and it was really impressive. Does anybody know where to find a good one? Something like the...
1
by: Jj | last post by:
Hi, I'm looking for a control to open window to allow the user to search and select an item. I have one in place, but there is a lack of options and stability. So I'm looking for a control on...
6
by: Ray Cassick \(Home\) | last post by:
I am looking for a control that displays simple HTML text (just basic tags, not active content needed). I know I can use the IE ActiveX control but really want to stay away from the headaches if...
7
by: Bruce HS | last post by:
I'd like to call my ancestor Validation Function every time any control on a Win Form generates a Validating or Validated event. I'm using VB. I've extended Textbox, for instance, to have its...
2
by: Matt | last post by:
Hi, I am looking for a control that will allow me to host other controls inside it but have a method of showing and hiding. I have seen plenty of horizontal controls for doing this but I am looking...
1
by: Jeff Williams | last post by:
I am looking for a Currency control/Number Control which has the following behavior. If you are entering a number such as 123.67 the control behaves like this. 1. The field (control) is right...
3
by: itisthiyagu | last post by:
Hi, Im looking for ListBox which works like Windows-XP's Add/Remove programs listbox. where can i get this kind of listbox ? I want to show a text in ListItem & it should expand with its...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.