Page 1 of 1
MakeFDirShortCut
Posted: Mon Feb 17, 2020 11:34 pm
by AUGE_OHR
hi,
does MakeFDirShortCut() also work for files
i have Problem to use it for files ...
is there a opposite function to "resolve" *.LNK

Re: MakeFDirShortCut
Posted: Tue Feb 18, 2020 8:05 am
by gfilatov
AUGE_OHR wrote: ↑Mon Feb 17, 2020 11:34 pm
hi,
does MakeFDirShortCut() also work for files
i have Problem to use it for files ...
...
Hi,
Try
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
Usage:
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
Re: MakeFDirShortCut
Posted: Tue Feb 18, 2020 9:44 pm
by AUGE_OHR
gfilatov wrote: ↑Tue Feb 18, 2020 8:05 am
Hi,
Try
so MakeFDirShortCut() does not work with files as i have try it
now i have use Part of my Xbase++ DXE LIB and rewrite for harbour / HMG
thx for your Code. there can be add this
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
where
aHotKey[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
and for Icon
Icon Index zero-based
{"shell32.dll", 3 }
{cAppPath+"Strait.ico", 0 }
{ AppName(.T.), 1 }
i also include opposite ResolveLink()
Re: MakeFDirShortCut
Posted: Wed Feb 19, 2020 1:43 am
by AUGE_OHR
about Hotkey : API Function MakeWord() is NOT include in Sample
Solution look here
viewtopic.php?f=5&p=61034#p61034
Re: MakeFDirShortCut
Posted: Tue Jun 23, 2020 6:20 am
by AUGE_OHR
AUGE_OHR wrote: ↑Mon Feb 17, 2020 11:34 pm
is there a opposite function to "resolve" *.LNK
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 )
i have use CHR(0) as "delimiter" but you will not "see" Parameter when not "seek" for CHR(0)
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