window links

BlitzMax Forums/BlitzMax Programming/window links

I googled and couldn't fine anything that could help me.
Is there a way to access or interpret the information contain in a link such as a file link or a directory link.
I am still working on my filerequester and I am running in to problems.

you can look at what I have so far if you follow my signature link.

theres some nice examples on how to resolve a shortcut link to the referenced file available on this link. im not sure how folders work but this should point you in the right direction.

http://www.catch22.net/tuts/tips2.asp

thanks Kev. I'll look in to it.

I have produced this code from information I collected.
it reads the shortcut file and returns the actual path or filename along with a lot of information included.
I still have not been able to decode per item. If anybody is willing to help me solve it I would really appreciate it.

I would like to have it tested and any problems reported please and thanks in advance.
my main concern is the final output which is the item being linked to.
does it produce the long file name or the old DOS file name?

I think it will be a problem with vista but I don't really know sence I don't have it.

The code is really raw and undocumented. Sorry, I don't have much time to detail it now.
SuperStrict
'flags
Const SHELLID			:Int = $0001
Const FILE_OR_DIR		:Int = $0002
Const INCLUDE_DESCRIPTION:Int = $0004
Const RELATIVE_PATH_STR	:Int = $0008
Const HAS_WORKING_DIR	:Int = $0010
Const HAS_ARGUMENTS		:Int = $0020
Const HAS_CUSTOM_ICON	:Int = $0040
'attributes
Const READONLY			:Int = $0001
Const HIDDEN			:Int = $0002
Const SYSTEM_FILE		:Int = $0004
Const VOLUME_LABEL		:Int = $0008 ' (Not possible)
Const TARGET_IS_DIRECTORY:Int = $0010
Const TARGET_MODIFIED_PRE:Int = $0020 ' (archive)
Const TARGET_ENCRYPTED	:Int = $0040
Const TARGET_NORMAL		:Int = $0080
Const TARGET_IS_TEMP	:Int = $0100
Const TARGET_A_PARSE_FILE:Int = $0200
Const TARGET_HAS_PARS_daT:Int = $0400
Const TARGET_IS_COMPRESS :Int = $0800
Const TARGET_IS_OFFLINE	:Int = $1000
' values to pass to target application
Const SW_HIDE			:Int = $001
Const SW_NORMAL		:Int = $002
Const SW_SHOWMINIMIZED	:Int = $004
Const SW_SHOWMAXIMIZED	:Int = $008
Const SW_SHOWNOACTIVATE	:Int = $010
Const SW_SHOW			:Int = $020
Const SW_MINIMIZE		:Int = $040
Const SW_SHOWMINNOACTIVE	:Int = $080
Const SW_SHOWNA		:Int = $100
Const SW_RESTORE		:Int = $200
Const SW_SHOWDEFAULT	:Int = $400' openfile.bmx
' volume flag
Const ON_LOCAL_DRIVE	:Int = $01
'type of volume

Const UNKNOWN			:Int = 0
Const NO_ROOT_DIR		:Int = 1
Const REMOVABLE		:Int = 2 '(Floppy, Zip, etc..)
Const FIXED			:Int = 3 'fixed (Hard disk)
Const REMOTE			:Int = 4 'Remote (Network drive)
Const CD_ROM			:Int = 5 
Const RAM_DRIVE		:Int = 6 '(Shortcuts To stuff on a ram drive, now that’s smart...)


Local file:TStream=OpenFile("oper.lnk")

If Not file RuntimeError "could not open file openfile.bmx";End


	Print StreamSize(file)
	Local i:Int = ReadInt(file) 
	Print i + "  " + Hex(i) 
	Local S:String = Null
	For I = 0 To 15
		 s:+ Chr(ReadByte(file) ) 
	Next
	Print "GUID short cut ="+s.Length
	Local flags:Int = ReadInt(file) 
	Print "flags =          = " + Bin(flags) 
	If flags & SHELLID             Print "      has shellid"
	If flags & FILE_OR_DIR         Print "      its a file or directory"
	If flags & INCLUDE_DESCRIPTION Print "      include description"
	If flags & RELATIVE_PATH_STR   Print "      include relative path string"
	If flags & HAS_WORKING_DIR     Print "      has working dir"
	If flags & HAS_ARGUMENTS       Print "      has arguments"
	If flags & HAS_CUSTOM_ICON     Print "      has custom icon"
	
	Local attributes:Int = ReadInt(file) 
	Print "file attributes  = " + Bin(attributes) 
	If attributes & READONLY				Print "              READONLY"
	If attributes & HIDDEN				Print "              HIDDEN"
	If attributes & SYSTEM_FILE			Print "              SYSTEM FILE"
	If attributes & VOLUME_LABEL			Print "              VOLUME LABEL"
	If attributes & TARGET_IS_DIRECTORY	Print "              TARGET IS DIRECTORY"
	If attributes & TARGET_MODIFIED_PRE	Print "              TARGET MODIFIED PRVIOUSLY"
	If attributes & TARGET_ENCRYPTED		Print "              TARGET IS ENCRYPTED"
	If attributes & TARGET_NORMAL			Print "              TARGET IS NORMAL"
	If attributes & TARGET_IS_TEMP		Print "              TARGET IS TEMPORARY"
	If attributes & TARGET_A_PARSE_FILE	Print "              TARGET IS A PARSE FILE"
	If attributes & TARGET_HAS_PARS_DAT	Print "              TARGET HAS PARSE DATA"
	If attributes & TARGET_IS_COMPRESS 	Print "              TARGET IS COMPRESSED"
	If attributes & TARGET_IS_OFFLINE		Print "              TARGET IS OFFLINE"

	 
	Local l:Long = ReadLong(file) 
	Print "creation time    = " + Hex(l) 
	l = ReadLong(file) 
	Print "modification time= " + Hex(l) 
	l = ReadLong(file) 
	Print "last access time = " + Hex(l)
	i = ReadInt(file) 
	Print "file length      = " + Hex(i)
	i = ReadInt(file) 
	Print "custom icon #    = " + Hex(i) 
	Local WND:Int = ReadInt(file) 
	Print "ShowWnd value    = " + Hex(WND) 
	Print "set to :" 
	If WND & SW_HIDE  			Print "             Hidden"
	If WND & SW_NORMAL 			Print "			Normal"
	If WND & SW_SHOWMINIMIZED	Print "             Minimized"
	If WND & SW_SHOWMAXIMIZED     Print "			Maximized"
	If WND & SW_SHOWNOACTIVATE    Print "			Active"
	If WND & SW_SHOW              Print "			Show"
	If WND & SW_MINIMIZE          Print "             Minimized"
	If WND & SW_SHOWMINNOACTIVE   Print "             Active"
	If WND & SW_SHOWNA 			Print "			ShowA"
	If WND & SW_RESTORE 		Print "			Restored"
	If WND & SW_SHOWDEFAULT 		Print "             Show Defalult"	 
	i = ReadInt(file) 
	Print "hot key          = " + Hex(i)
	l = ReadLong(file)
	Print "unknown          = " + Hex(l) 
	
	If flags & SHELLID
		i = ReadShort(file) 
		Print "shell id length = " + i
		Local itemcount:Int = 0
		Repeat
			i = ReadShort(file) 
			itemcount:+ 1
			Print "item " + itemcount + " length = " + i
			s= Null
			For Local n:Int = 0 Until (i-2)
				s:+ Chr(ReadByte(file) ) 
			Next
			Print "       "+s
			'SeekStream(file,(StreamPos(file) + i-2)) 
			 
		Until i = 0
	EndIf
	Local fileinfostart:Int = StreamPos(file) 
	Print "file info start = "+fileinfostart
	i = ReadInt(file) 
	Print "file info to end length = " + i
	i = ReadInt(file) 
	Print "first structure advance = " + Hex(i) + " bytes"
	Local fileinfoend:Int = fileinfostart+i
	Local volumeflag:Int = ReadInt(file) 
	Print "file flags = " + Bin(volumeflag)
	If volumeflag & ON_LOCAL_DRIVE
			Print "               Local Drive"
	Else
			Print "               Shared Drive"
	EndIf 
	i = ReadInt(file) 
	If (volumeflag & ON_LOCAL_DRIVE) = True
		Print "offset of local volume info = " + i
	EndIf
	i = ReadInt(file) 
	If (volumeflag & ON_LOCAL_DRIVE) = True
		Print "Offset of base pathname on Local system = " + i
	EndIf
	i = ReadInt(file) 
	If (volumeflag & ON_LOCAL_DRIVE) = False
		Print "offset of network volume info = " + i
	EndIf
	i = ReadInt(file) 
	Print "Offset of remaining pathname = " + i
	Print StreamPos(file)' - fileinfostart)
	Print fileinfoend
	Local Typeofvolume:Int
	If VolumeFlag & ON_LOCAL_DRIVE
		i = ReadInt(file)
		Print "length of local volume table = " + Hex(i)
		Typeofvolume = ReadInt(file) 
		If Typeofvolume = UNKNOWN 	Print "			unknown"
		If Typeofvolume = NO_ROOT_DIR Print "		no root diectory"
		If Typeofvolume = REMOVABLE	Print "			removable drive"
		If Typeofvolume = FIXED		Print "			fixed Volume"
		If Typeofvolume = REMOTE		Print "		Remote (Network drive)"
		If Typeofvolume = CD_ROM		Print "		CD_ROM"
		If Typeofvolume = RAM_DRIVE	Print "			ram drive"
		i = ReadInt(file) 
		Print "Volume serial number = $" + Hex(i) 
		i = ReadInt(file) 
		Print "offset Volume name = "+Hex(i) 
	Else
		i = ReadInt(file)
		Print "length of Network volume table = " + i
		i = ReadInt(file) 
		Print "unknown always the same = " Hex(i)
		i = ReadInt(file) 
		Print "offset network shared name " + Hex(i) 
		i = ReadInt(file)
		Print "unknown always 0 = " + i
		i = ReadInt(file) 
		Print "unknown always the same = "+Hex(i)
		Print "offset Volume name = "+Hex(i) 
	EndIf
	If flags & FILE_OR_DIR
		Local name:String = Null
		i = ReadByte(file)
		Print "this -> "+i
		i = ReadByte(file)
		While i <> 0
			name:+Chr(i)
			i = ReadByte(file) 
		Wend
		Print name 
	EndIf
		 


CloseStream file


[edit]
I got the documentation from here:
http://mediasrv.ns.ac.yu/extra/fileformat/windows/lnk/shortcut.pdf