:Start of demo1 demo1.dsc
DragonSphereSoftware

DragonSphere Software Demos


If you are viewing this script in your browser you can save it as a VDS 5.x source file (*.dsc) to run it.




#-----------------------------------------------------------------------------#
#                                                                             #
# Several demostrations showing the usage of the VDSShortCut.dll              #
#                                                                             #
# Author:  Johnny Kinsey                                                      #
#                                                                             #
# Copyright: Copyright © 2007 DragonSphere Software                           #
#                                                                             #
#-----------------------------------------------------------------------------#


External vdsshortcut.dll
If @Greater(@Name(@Sysinfo(DSVER)),4)
#DEFINE COMMAND,SHORTCUT
#DEFINE FUNCTION,SHORTCUT
End
# Create a new Shortcut file (.LNK)
%%LinkId = @ShortCut(New)
If %%LinkId
  # Set properties for the new Shortcut file
  ShortCut Set,Target,%%LinkId,c:\myapp.exe
  ShortCut Set,Description,%%LinkId,This is just a demo of the ShortCut commands
  ShortCut Set,WorkingDir,%%LinkId,C:\
  ShortCut Set,Icon,%%LinkId,c:\myapp.exe,1
  ShortCut Set,HotKey,%%LinkId,Ctrl+Alt+J
  ShortCut Set,ShowCmd,%%LinkId,Minimized
  ShortCut Set,Arguments,%%LinkId,"%1"
  # Save the new shortcut.
  ShortCut Save,%%LinkId,c:\test.lnk
  If @OK()
    Info c:\test.lnk was saved successfully.
  End
Else
  Warn Could not create a new Icon
End

# Load an existing shortcut file (*.LNK)
%%LinkId = @ShortCut(Load,C:\test.LNK)
If %%LinkId
  # Read the properties of the shortcut file
  %%Target = @ShortCut(Get,Target,%%LinkId)
  %%Description = @ShortCut(Get,Description,%%LinkId)
  %%WorkingDir = @ShortCut(Get,WorkingDir,%%LinkId)
  %%Arguments = @ShortCut(Get,Arguments,%%LinkId)
  %%Hotkey = @ShortCut(Get,HotKey,%%LinkId)
  %%ShowCmd = @ShortCut(Get,ShowCmd,%%LinkId)
  Parse "%%IconPath;%%IconIdx",@ShortCut(Get,Icon,%%LinkId,@fsep())
  Info test.lnk Properties@CR()Description: %%Description@cr()Target: %%Target@cr()WorkingDir: %%WorkingDir@cr()Arugments: %%Arguments@cr()IconPath: %%IconPath@cr()IconId: %%IconIdx@cr()Hotkey: %%Hotkey@cr()ShowCmd: %%ShowCmd
  ShortCut UnLoad,%%LinkId
Else
  Warn Cannot open Link
End

# Read and Update properties in an existing shortcut file (*.LNK)
Info Updating c:\test.lnk
%%LinkId = @ShortCut(Load,C:\test.LNK)
If %%LinkId
  # Begin Reading
  %%Target = @ShortCut(Get,Target,%%LinkId)
  %%Description = @ShortCut(Get,Description,%%LinkId)
  %%WorkingDir = @ShortCut(Get,WorkingDir,%%LinkId)
  %%Arguments = @ShortCut(Get,Arguments,%%LinkId)
  %%Hotkey = @ShortCut(Get,HotKey,%%LinkId)
  %%ShowCmd = @ShortCut(Get,ShowCmd,%%LinkId)
  Parse "%%IconPath;%%IconIdx",@ShortCut(Get,Icon,%%LinkId,@fsep())
  Info Original Properties@CR()Description: %%Description@cr()Target: %%Target@cr()WorkingDir: %%WorkingDir@cr()Arugments: %%Arguments@cr()IconPath: %%IconPath@cr()IconId: %%IconIdx@cr()Hotkey: %%Hotkey@cr()ShowCmd: %%ShowCmd
  # Begin updating
  ShortCut Set,Target,%%LinkId,c:\myapp2.exe
  # clear the description
  ShortCut Set,Description,%%LinkId,
  # clear the working directory
  ShortCut Set,WorkingDir,%%LinkId,
  # Change the Icon
  ShortCut Set,Icon,%%LinkId,c:\myapp.exe,0
  # Change the Hotkey
  ShortCut Set,HotKey,%%LinkId,Ctrl+Alt+L
  # Change the show command
  ShortCut Set,ShowCmd,%%LinkId,Normal Window
  # Remove the arguments
  ShortCut Set,Arguments,%%LinkId,
  # Save the updates of the current shortcut
  ShortCut Save,%%LinkId
  # Reload the shortcut and read back the changes
  %%LinkId = @ShortCut(Load,C:\test.LNK)
  If %%LinkId
    # Begin Reading
    %%Target = @ShortCut(Get,Target,%%LinkId)
    %%Description = @ShortCut(Get,Description,%%LinkId)
    %%WorkingDir = @ShortCut(Get,WorkingDir,%%LinkId)
    %%Arguments = @ShortCut(Get,Arguments,%%LinkId)
    %%Hotkey = @ShortCut(Get,HotKey,%%LinkId)
    %%ShowCmd = @ShortCut(Get,ShowCmd,%%LinkId)
    Parse "%%IconPath;%%IconIdx",@ShortCut(Get,Icon,%%LinkId,@fsep())
    Info Updated Properties@CR()Description: %%Description@cr()Target: %%Target@cr()WorkingDir: %%WorkingDir@cr()Arugments: %%Arguments@cr()IconPath: %%IconPath@cr()IconId: %%IconIdx@cr()Hotkey: %%Hotkey@cr()ShowCmd: %%ShowCmd
    ShortCut UnLoad,%%LinkId
  Else
    Warn Cannot open shortcut file
  End
Else
  Warn Cannot open shortcut file
End

# Save an existing shortcut file to different file name
# Read and Update properties in an existing shortcut file (*.LNK)
Info Saving c:\test.lnk to c:\test2.lnk
%%LinkId = @ShortCut(Load,C:\test.LNK)
If %%LinkId
  # Begin Reading
  %%Target = @ShortCut(Get,Target,%%LinkId)
  %%Description = @ShortCut(Get,Description,%%LinkId)
  %%WorkingDir = @ShortCut(Get,WorkingDir,%%LinkId)
  %%Arguments = @ShortCut(Get,Arguments,%%LinkId)
  %%Hotkey = @ShortCut(Get,HotKey,%%LinkId)
  %%ShowCmd = @ShortCut(Get,ShowCmd,%%LinkId)
  Parse "%%IconPath;%%IconIdx",@ShortCut(Get,Icon,%%LinkId,@fsep())
  Info test.lnk Properties@CR()Description: %%Description@cr()Target: %%Target@cr()WorkingDir: %%WorkingDir@cr()Arugments: %%Arguments@cr()IconPath: %%IconPath@cr()IconId: %%IconIdx@cr()Hotkey: %%Hotkey@cr()ShowCmd: %%ShowCmd
  # Save the current shortcut to a different file leaving the old shortcut file in place.
  # If you needed to change any property do that before saving to the new shortcut.
  ShortCut Save,%%LinkId,C:\test2.lnk
  # Load the new shortcut file
  %%LinkId = @ShortCut(Load,C:\test2.lnk)
  If %%LinkId
    # Begin Reading
    %%Target = @ShortCut(Get,Target,%%LinkId)
    %%Description = @ShortCut(Get,Description,%%LinkId)
    %%WorkingDir = @ShortCut(Get,WorkingDir,%%LinkId)
    %%Arguments = @ShortCut(Get,Arguments,%%LinkId)
    %%Hotkey = @ShortCut(Get,HotKey,%%LinkId)
    %%ShowCmd = @ShortCut(Get,ShowCmd,%%LinkId)
    Parse "%%IconPath;%%IconIdx",@ShortCut(Get,Icon,%%LinkId,@fsep())
    Info test2.lnk Properties@CR()Description: %%Description@cr()Target: %%Target@cr()WorkingDir: %%WorkingDir@cr()Arugments: %%Arguments@cr()IconPath: %%IconPath@cr()IconId: %%IconIdx@cr()Hotkey: %%Hotkey@cr()ShowCmd: %%ShowCmd
    ShortCut UnLoad,%%LinkId
  Else
    Warn Cannot open shortcut file.
  End
Else
  Warn Cannot open shortcut file.
End
Exit
:End of demo1