Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

shortcut

Status
Not open for further replies.

mg911

Technical User
Jul 18, 2001
59
US
is there a way in basic - to create a shortcut to appear on the desktop -

or is there a way to create a shortcut and name it, and tell it the location

or is there a way i could just copy an icon to the desktop

1 of the 3 will be fine - i just need to know how to get a icon to the desktop

Thanks


 
At desktop, right click, new, shortcut. Ed Fair
efair@atlnet.com

Any advice I give is my best judgement based on my interpretation of the facts you supply.

Help increase my knowledge by providing some feedback, good or bad, on any advice I have given.

 
thanks -

but how do i do that in BASIC

 
implement the interfce IShellLink if your basic version supports building of COM applications John Fill
1c.bmp


ivfmd@mail.md
 
how can i implement it - and how do i know if i support it

is this easy code to write or very difficult???

Thanks again
 
i am just using the editor in windows

i also have visual studio -

if that helps at all
 
In this case see shell extensions. Short Cuts always are files. When you create a shortcut, windows creates in that place a file. In my opinion VisualBasic has a method which creates shortcuts, but I'm cpp programmer. John Fill
1c.bmp


ivfmd@mail.md
 
ok - well i guess i will figure it out

Thanks anyway

 
Create a couple of batch files to do some useless stuff. Create a couple of shortcuts to those files.
Copy the shortcuts to a floppy and then look at them with a disk editor like norton.
You'll see the machine code required to make them work.
You should then be able to create a basic program that will create a file with the same contents. Ed Fair
efair@atlnet.com

Any advice I give is my best judgement based on my interpretation of the facts you supply.

Help increase my knowledge by providing some feedback, good or bad, on any advice I have given.

 
edfair,
1. what machine code in a .lnk file?
2. what mashine code for basic programmers? John Fill
1c.bmp


ivfmd@mail.md
 
This will work in VB and, with minor modifications, will work with any flavor of BASIC.
[tt]
MyDesktop$ = Environ$("windir") & "\Desktop"
ShortcutFile$ = MyDesktop$ & "\" & App.Title & ".URL"
MyApp$ = App.Path & "\" & App.EXEName & ".exe"
FF = FreeFile
Open ShortcutFile$ For Binary As #FF
P$ = "[InternetShortcut]" & vbCrLf
P$ = P$ & "URL=" & MyApp$ & vbCrLf
P$ = P$ & "IconIndex = 0" & vbCrLf
P$ = P$ & "IconFile=" & MyApp$ & vbCrLf
Put #FF, 1, P$
Close #FF
[/tt]
Not that this code uses [tt]App.Title, App.Path and App.EXEName[/tt] to set the location and icon properties for the shortcut. Under Quick Basic or other versions, you would probably hard code that information, i.e.:[tt]

vbCrLf$ = CHR$(13) + CHR$(10)
MyApp$ = "C:\MyStuff\MyApp.exe"
P$ = P$ + "IconFile=" + "C:\MyStuff\MyIcon.ico" + vbCrLf$
[/tt]
(Replacing, of course, the "&"s with "+"s and making whatever minor adjustments are necessary for version compatibility.)

LNK files are very difficult to decypher but URL files are saved as plain text and serve the same purpose.

Hope this helps.

VCA.gif
 
Hi Craig, long time no see.
John, How about a .pif file containg 967 characters. Less than 25% populated. Contents evidently give everything neccessary to run the application.

Ed Fair
efair@atlnet.com

Any advice I give is my best judgement based on my interpretation of the facts you supply.

Help increase my knowledge by providing some feedback, good or bad, on any advice I have given.

 
your not being serious about the whole pif file ???


right???


 
.pif files are not links. They are separate executable programs. They can run itself or to start other programs (ie to be something like a link to an executable). But short cuts (.lnk files) can be to all kind of files. John Fill
1c.bmp


ivfmd@mail.md
 
so how could i make a pif file a desktop shortcut with a web address

thanks

 
The link in a URL file doesn't have to point to an Internet address. It can point to an application on a local hard drive or network drive. That's what my example does. It creates a shortcut on the desktop that executes the program named in the [tt]MyApp$[/tt] variable.

I thought that was what you required.
VCA.gif
 
DOH! I just noticed that you have Visual Studio. VB 5 and 6 support this call and earlier versions will allow it (with minor changes to the API declaration):
[tt]
Private Declare Function fCreateShellLink _
Lib "VB5STKIT.DLL" _
(ByVal lpstrFolderName As String, _
ByVal lpstrLinkName As String, _
ByVal lpstrLinkPath As String, _
ByVal lpstrLinkArgs As String) As Long
[/tt]
...then call it with...[tt]
retval = fCreateShellLink("..\..\Desktop", _
"My Desktop Link", "C:\MyStuff\MyApp.exe", "")
[/tt]
The disadvantages of using this (vs the URL format):
1) You can't specify the icon associated with the link
2) The user must have the VB runtimes. Naturally, you can't use this call with BASIC for DOS (the URL example could create a link using practically any version of BASIC.)

VCA.gif
 
thanks for the help guys

just to recap -

i need an icon to be created on the desktop
the icon needs to have a web address ( the icon needs to be created when i run a .bat or .com file. The reason for this is because i have some code to do some small checking to see if a certain director is present in the computer - but after the program finds out if the directory is there - then it can execute and make a desktop icon - to a web address - and the icon has a certain name -

hopefully i am not confusing you guys and making this harder than it should be

Thanks again
 
How much more do you need? I've shown you two ways to create a link with BASIC.... Here's a way to do it with a batch file:
Code:
@ECHO OFF
SET Fname=%windir%\DeskTop\123.URL
ECHO [InternetShortcut]>%Fname%
ECHO URL=http://www.123.com>>%Fname%
This will create a link to on the desktop.
VCA.gif
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top