November 28, 2020, 02:00:02 AM

Author Topic: [bmx] NTFS-Links by Fabian. [ 1+ years ago ]  (Read 489 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bmx] NTFS-Links by Fabian. [ 1+ years ago ]
« on: June 29, 2017, 12:28:41 AM »
Title : NTFS-Links
Author : Fabian.
Posted : 1+ years ago

Description : This program creates NTFS file links using the WinAPI.
You can download the executable program with icon <a href="http://webspace100.we.funpic.de/root/programs/NTFS-Links.exe" target="_blank">here[/url].


Code :
Code: BlitzMax
  1. Strict
  2.  
  3. Framework brl.blitz
  4.  
  5. Import brl.system
  6. Import brl.filesystem
  7.  
  8. AppTitle = "NTFS-Links"
  9. If Proceed ( "Do you want to use this tool to create a NTFS file link?" ) = 1
  10.   Local FileTo$ = RequestFile ( "Select the file to create the link to" , "All files (*):*" )
  11.   If FileTo
  12.     Local Exts$ = "All files (*):*"
  13.     If ExtractExt ( FileTo )
  14.       Exts = "Type of file to link to (*." + ExtractExt ( FileTo ) + "):" + ExtractExt ( FileTo ) + ";" + Exts
  15.     EndIf
  16.     Local FileFrom$ = RequestFile ( "Select the folder and file name to create the link" , Exts , True )
  17.     If FileFrom
  18.       LinkFiles FileFrom , FileTo
  19.       NotifySystemError GetSystemError ( )
  20.     EndIf
  21.   EndIf
  22. EndIf
  23.  
  24. Function LinkFiles ( LinkFrom$ , LinkTo$ )
  25. ?Win32
  26.   Return CreateHardLinkW ( LinkFrom.ToWString ( ) , LinkTo.ToWString ( ) , Null ) <> 0
  27.  
  28.   Extern "Win32"
  29.     Function CreateHardLinkW ( Src:Short Ptr , Dst:Short Ptr , SAttr:Byte Ptr )
  30.   EndExtern
  31. ?
  32. ?Linux | MacOS
  33.   Throw "This function is win32 only."
  34. ?
  35. EndFunction
  36.  
  37. Function NotifySystemError ( ID )
  38. ?Win32
  39.   Local Buf:Short [ 1024 ]
  40.   If FormatMessageW ( $1000 , Null , ID , 0 , Buf , Len Buf , Null )
  41.     Notify String.FromWString ( Buf )
  42.     Return True
  43.   EndIf
  44.  
  45.   Extern "Win32"
  46.     Function FormatMessageW ( Flags , Src:Byte Ptr , ID , Lang , Buf:Short Ptr , Size , Args:Byte Ptr )
  47.   EndExtern
  48. ?
  49. ?Linux | MacOS
  50.   Throw "This function is win32 only."
  51. ?
  52. EndFunction
  53.  
  54. Function GetSystemError ( )
  55. ?Win32
  56.   Return GetLastError ( )
  57.  
  58.   Extern "Win32"
  59.     Function GetLastError ( )
  60.   EndExtern
  61. ?
  62. ?Linux | MacOS
  63.   Throw "This function is win32 only."
  64. ?
  65. EndFunction


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal