does MakeFDirShortCut() also work for files

i have Problem to use it for files ...

is there a opposite function to "resolve" *.LNK

Moderator: Rathinagiri
Hi,
Code: Select all
*------------------------------------------------------------------------------*
PROCEDURE MakeShortCut(WshShell, LinkName, ;
TargetPath, Arguments, IconLocation, Description, WorkingDirectory)
*------------------------------------------------------------------------------*
local FileShortcut
FileShortcut := WshShell:CreateShortcut(LinkName)
FileShortcut:TargetPath := TargetPath
FileShortcut:Arguments := Arguments
FileShortcut:WindowStyle := 1
FileShortcut:IconLocation := IconLocation
FileShortcut:Description := Description
FileShortcut:WorkingDirectory := WorkingDirectory
FileShortcut:Save()
FileShortcut := Nil
RETURN
Code: Select all
*------------------------------------------------------------------------------*
PROCEDURE CreateShortcuts()
*------------------------------------------------------------------------------*
local WshShell := CreateObject("WScript.Shell")
local DesktopFolder := WshShell:SpecialFolders:Item("Desktop")
MakeShortCut(WshShell, DesktopFolder + "\Shutdown.lnk", ;
"%systemroot%\System32\shutdown.exe", "-s -t 0", ;
"%systemroot%\System32\shell32.dll,27", ;
"Shutdown Computer (Power Off)", "%systemroot%\System32\")
MakeShortCut(WshShell, DesktopFolder + "\Log Off.lnk", ;
"%systemroot%\System32\shutdown.exe", "-l", ;
"%systemroot%\System32\shell32.dll,44", ;
"Log Off (Switch User)", "%systemroot%\System32\")
MakeShortCut(WshShell, DesktopFolder + "\Restart.lnk", ;
"%systemroot%\System32\shutdown.exe", "-r -t 0", ;
"%systemroot%\System32\shell32.dll,176", ;
"Restart Computer (Reboot)", "%systemroot%\System32\")
MsgInfo("Created <Shutdown>, <Restart> and <Log Off> shortcuts", "Result")
WshShell := Nil
RETURN
so MakeFDirShortCut() does not work with files as i have try it
Code: Select all
// Shortcut Hotkey
IF !EMPTY( aHotKey ) .AND. VALTYPE( aHotKey ) = "A"
IF LEN( aHotKey ) = 2
nLoByte := aHotKey[ 1 ]
nHiByte := aHotKey[ 2 ]
// this have to be fixed for harbour / HMG
oShellLink:Hotkey := MakeWord( nLoByte , nHiByte )
ENDIF
ENDIF
// Icon need Method
IF !EMPTY( aIcon ) .AND. VALTYPE( aIcon ) = "A"
IF LEN( aIcon ) = 2
oShellLink:SetIconLocation( aIcon[ 1 ], aIcon[ 2 ] )
ENDIF
ENDIF
and for IconaHotKey[1] -> ASCI Number e.g. ASC("Z")
aHotKey[2] -> CTRL+ALT -> 2+4
(1) SHIFT key
(2) CTRL key
(4) ALT key
(8) Extended key
i also include opposite ResolveLink()Icon Index zero-based
{"shell32.dll", 3 }
{cAppPath+"Strait.ico", 0 }
{ AppName(.T.), 1 }
here Function to "resolve" a *.LNK ! Note : i also return Parameter of *.LNK if given
Code: Select all
RETURN cTarget + IF( EMPTY( cPara ), "", CHR( 0 ) + cPara )
Code: Select all
cString := DXE_ResolveLink("c:\Users\a\Desktop\HBFTP.lnk")
nPosi := AT( CHR(0), cString )
IF nPosi > 0
cExe := SUBSTR(cString,1,nPosi-1)
cPara := SUBSTR(cString,nPosi+1)
ELSE
cExe := cString
ENDIF