I think shortcuts are special file with .lnk extensions even if you do not see it
Try change:
intoDim file_name As String = "my_shortcut"
Dim file_name As String = "my_shortcut.lnk"
HI,
I get a broblem with Windows shortcuts.
With win explorer I create a shortcut pointing on the file "program.asm1802" named "my_shortcut".
Win utilities (as editor ) invoked with the shortcut name, works on the real pointed to file "program.asm1802" as I think it would be,
but thinBasic program below returns %FALSE (0) in dummy1 and %TRUE (1) in dummy2
Do I make a mistake or ThinBasic dislikes windows shortcuts ?
Regards
Dany
'---Load Console and File modules Uses "Console" Uses "file" Dim dummy1 As Long Dim dummy2 As Long Dim file_name As String = "my_shortcut" dummy1 = FILE_Exists(file_name) PrintL file_name & " file exists ? ", dummy1 file_name = "program.asm1802" dummy2 = FILE_Exists(file_name) PrintL file_name & " file exists ? ", dummy2 '---Wait for a key press PrintL "Press a key to end program" WaitKey( 30 )
I think shortcuts are special file with .lnk extensions even if you do not see it
Try change:
intoDim file_name As String = "my_shortcut"
Dim file_name As String = "my_shortcut.lnk"
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
Hi Eros,
As usual, ThinBasic the fastest hotine in the world.
I did not think to look for extension. As you know, I'm from Unix world and almost always working as 'root'
so my Win Explorer is configured to display hidden/system files and of course extensions.
But the '.lnk' IS NOT displayed
But now appears a new problem.
When I try to load linked to file content, I get, the data descripting the link itself, not the data contained in file.
I tried other way of links on directories. It seems to work fine, also with symbolics links across partitions.
I also noticed that one can use indifferently '/' or '\' as directory separator. Great for a unix<->windows user.
Regards,
Dany
Last edited by dco045; 25-01-2018 at 12:43.
You can use the following function to get target path of a .lnk shortcut link file.
Than use returned TargetPath (if any) to open your target file.
#minversion 1.10.4 uses "Console" '-------------------------------------------------------- ' Use this function to find target path of a .lnk file '-------------------------------------------------------- Function Link_GetTargetPath(byval sLinkFilePath as string) as String dim iShell as iDispatch dim iLink as iDispatch iShell = NewCom("WScript.Shell") IF IsComObject(iShell) Then 'https://msdn.microsoft.com/fr-fr/library/xsy6k3ys(v=vs.84).aspx iLink = iShell.CreateShortcut(sPath) IF IsComObject(iLink) Then function = iLink.TargetPath '---Other possible info can be found at https://msdn.microsoft.com/fr-fr/library/xk6kst2k(v=vs.84).aspx 'iLink.Description 'iLink.TargetPath 'iLink.WorkingDirectory iLink = Nothing end If iShell = Nothing end If end Function String sPath = APP_SourcePath & "MyLink.lnk" '<---Change as needed printl "Trying to find link info of:", sPath printl "Link path is...............:", Link_GetTargetPath(sPath) WaitKey
Last edited by ErosOlmi; 25-01-2018 at 18:13.
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
Bookmarks