Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [DBP] Add Windows Shortcuts (.lnk files)

Author
Message
N3wton
14
Years of Service
User Offline
Joined: 3rd Jun 2009
Location: Leeds, UK
Posted: 28th Dec 2009 11:36 Edited at: 28th Dec 2009 11:44
I dunno why I decided to look into this but I did and this is my solution to adding shortcut files (.lnk files) to windows from your DBPro code.

I have made 3 functions.
- Add_Shortcut_Desktop
- Add_Shortcut
- Add_Shortcut_Ex

Basically the first of the 3 add a shortcut to the current users desktop, The second function has a list of 16 special folder locations where a shortcut can be added and the last function you enter the exact location of where you want the .lnk file to be saved.

Add_Shortcut_Desktop


Add_Shortcut


Add_Shortcut_Ex


The 3 commands require most of the same information :
Name$ - The name of the shortcut the user see's.
FileLocation$ - Where the actual application that the shortcut file is pointing to is saved.
IconLocation$ - The loction of the icon you wish the shortcut file to use.
FileDescription$ - The description of the file (This is displayed on mouse over).
WorkingDIR$ - The actual applications working directory.
ShortcutKeys$ - Keys the user can press to activate the shortcut (e.g. CTRL+SHIFT+P).

Here's an example of how to use each command



and finally here's some code you can put into a DBPro file and run to see that it works. The code below will add three shortcuts to MS-Paint onto your desktop.

NOTE : I Use windows 7 and thus Add_Shortcut_Ex may not use the correct location to the desktop. (C:\Users\" + Windows Username$() + "\Desktop).
Also It uses the Windows Username$() from the matrix plugin coolection.




GIDustin
15
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 29th Dec 2009 01:26
Well that will come in handy one of these days. Copying this to my libraries folder.

Thanks!

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 26th Jan 2010 13:18
That's perfect! I'll stick this in the installer I'm making.

My installer is a bit of a cheat really as it doesn't really extract compressed files or anything (yet) but it will stick all of your files into a selected folder, get you to accept a license agreement and now add a shortcut to the desktop!

Thanks again!

c64 Maddddd
20
Years of Service
User Offline
Joined: 31st Jul 2003
Location: United Kingdom
Posted: 17th Feb 2010 21:56
This is just what I wonted for my program. However, I have a problem.

The shortcut I wont to create has an extension, the target box in the manually created shortcut reads: "C:\Dos_File\DCS\Quick Launcher.exe" 69
But I cant get your routine to create the same, it keep on showing error, I entered in:


There must be an extra command for entering "69" in.
Do you know, it will compleat what I wont

DarkBasic is grate on the PC, but..
the Commodore 64 is the BEST!!
c64 Maddddd
20
Years of Service
User Offline
Joined: 31st Jul 2003
Location: United Kingdom
Posted: 18th Feb 2010 21:04
Found it:

Write String 1, "oShellLink.Arguments = "+quote+"69"+quote

Works perfect

DarkBasic is grate on the PC, but..
the Commodore 64 is the BEST!!
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 20th Feb 2010 01:42
Niiice N3wton! I'll include this in every setup I make from now on!

TheComet

Login to post a reply

Server time is: 2024-04-26 19:45:00
Your offset time is: 2024-04-26 19:45:00