Ich benutze in etwa folgenden Code, um die Dateien auszulesen, auf die Verknüpfungen verweisen.
Code
'Definitionen
DEF MultiByteToWideChar(6) ! "Kernel32","MultiByteToWideChar"
DEF CoInitialize(1) ! "OLE32","CoInitialize"
DEF CoUnInitialize(0) ! "OLE32","CoUninitialize"
DEF CoCreateInstance(5) ! "OLE32","CoCreateInstance"
Def Shgetpathfromidlist(2) !"SHELL32","SHGetPathFromIDListA"
Def Shgetspecialfolderlocation(3) !"SHELL32","SHGetSpecialFolderLocation"
'Konstanten
DEF &PShell_Release 8
DEF &PShell_GetPath 12
DEF &PShell_Resolve 76
DEF &PFile_Release 8
DEF &PFile_Save 24
DEF &PFile_Load 20
DEF &Papierkorb $A
DEF &Control_Panel $3
DEF &DESKTOP $0
DEF &DESKTOPDIRECTORY $10
DEF &My_Computer $11
DEF &FONTS $14
DEF &Netzwerkumgebung $13
DEF &NETZWERK $12
DEF &EIGENE_DATEIEN $5
DEF &Drucker $4
DEF &Startmenü_Programme $2
DEF &Letzte_Dokumente $8
DEF &SENDTO $9
DEF &STARTMENU $B
DEF &Autostart $7
DEF &TEMPLATES $15
'globale Variablen
Declare CLSID_IShellLink#
Declare IID_IShellLink#
Declare IID_IPersistFile#
Declare FindData#
Declare Counter&
Declare SL$, SSS$, DesktopPath$, Verkn$, Autostart$
Proc GetLinkPath
Parameters LNK$
Declare Command&,Buffer$,PFile&
Declare Pshell&
Declare WideFile$
Dim FindData#,320
Dim CLSID_IShellLink#,16
Long CLSID_IShellLink#,0 = $00021401
Word CLSID_IShellLink#,4 = $0000
Word CLSID_IShellLink#,6 = $0000
Byte CLSID_IShellLink#,8 = $C0
Byte CLSID_IShellLink#,9 = $00
Byte CLSID_IShellLink#,10 = $00
Byte CLSID_IShellLink#,11 = $00
Byte CLSID_IShellLink#,12 = $00
Byte CLSID_IShellLink#,13 = $00
Byte CLSID_IShellLink#,14 = $00
Byte CLSID_IShellLink#,15 = $46
'
Dim IID_IShellLink#,16
Long IID_IShellLink#,0 = $000214EE
Word IID_IShellLink#,4 = $0000
Word IID_IShellLink#,6 = $0000
Byte IID_IShellLink#,8 = $C0
Byte IID_IShellLink#,9 = $00
Byte IID_IShellLink#,10 = $00
Byte IID_IShellLink#,11 = $00
Byte IID_IShellLink#,12 = $00
Byte IID_IShellLink#,13 = $00
Byte IID_IShellLink#,14 = $00
Byte IID_IShellLink#,15 = $46
'
Dim IID_IPersistFile#,16
Long IID_IPersistFile#,0 = $0000010b
Word IID_IPersistFile#,4 = $0000
Word IID_IPersistFile#,6 = $0000
Byte IID_IPersistFile#,8 = $C0
Byte IID_IPersistFile#,9 = $00
Byte IID_IPersistFile#,10 = $00
Byte IID_IPersistFile#,11 = $00
Byte IID_IPersistFile#,12 = $00
Byte IID_IPersistFile#,13 = $00
Byte IID_IPersistFile#,14 = $00
Byte IID_IPersistFile#,15 = $46
'
CoInitialize(0)
CoCreateInstance(CLSID_IShellLink#,0,1,IID_IShellLink#,Addr(PShell&))
Command& = Long(Pshell&,0)
CALL(LONG(COMMAND&,0),PShell&,IID_IPersistFile#,Addr(PFile&))'Interface ermitteln
WideFile$ = Space$(Len(LNK$)*2)
MultiByteToWideChar(0,1,addr(LNK$),-1,addr(WideFile$),Len(WideFile$))'LNK-File umwandeln
Command& = Long(PFile&,0)
CALL(LONG(COMMAND&,&PFile_Load),PFile&,Addr(WideFile$),1)'LinkFile laden
Command& = Long(Pshell&,0)
CALL(LONG(COMMAND&,&PShell_Resolve),PShell&,%hwnd,$3)
Buffer$ = Space$(260)
CALL(LONG(COMMAND&,&PShell_GetPath),PShell&,ADDR(Buffer$),260,FindData#,$1)'(Shortname)Pfad in Buffer$
CALL(LONG(COMMAND&,&PShell_Release),PShell&)
Command& = Long(PFile&,0)
CALL(LONG(COMMAND&,&PFile_Release),PFile&)
CoUnInitialize()
Dispose CLSID_IShellLink#
Dispose IID_IShellLink#
Dispose IID_IPersistFile#
Dispose FindData#
Return LongName$(Buffer$)
EndProc
Proc GetShellFolder
Parameters PRINT%,Folder&
Declare Itemid&, Result#, Retstr$,ERR&
Dim Result#, 261
Clear Result#
LET ERR&=Shgetspecialfolderlocation(%HWND,Folder&,@Addr(Itemid&))
CASE PRINT%=1 : PRINT "RUCKGABE von Shgetspecialfolderlocation="+@STR$(ERR&)
CASE ERR&=0 : LET Retstr$="Identifier wurde ermittelt, kein Pfad zu ermitteln..."
LET ERR&=Shgetpathfromidlist(Itemid&,Result#)
CASE PRINT%=1 : PRINT "RUCKGABE von Shgetpathfromidlist="+@STR$(ERR&)
IF String$(Result#,0)<>""
Retstr$ = String$(Result#,0)
endif
Dispose Result#
Return Retstr$
Endproc
Counter& = 1
ClearList
DesktopPath$ = GetShellFolder(0,&Desktop)
Autostart$ = GetShellFolder(0,&Autostart)
AddFiles DesktopPath$+"\"+"*.LNK"
SL$ = MoveListToStr$(";")
SSS$ = " "
ClearList
Whilenot SSS$ = ""
SSS$ = SUBSTR$(SL$,Counter&,";")
IF SSS$<>""
Verkn$ = GetLinkPath(DesktopPath$+"\"+SSS$)
Addstring DesktopPath$+"\"+SSS$+": "+Verkn$
Counter& = Counter& + 1
endif
Wend
ClearList
AddFiles Autostart$+"\"+"*.LNK"
SL$ = MoveListToStr$(";")
SSS$ = " "
ClearList
Whilenot SSS$ = ""
SSS$ = SUBSTR$(SL$,Counter&,";")
IF SSS$<>""
Verkn$ = GetLinkPath(Autostart$+"\"+SSS$)
Addstring Autostart$+"\"+SSS$+": "+Verkn$
Counter& = Counter& + 1
endif
Wend
Editbox("Verknüpfungen in "+DesktopPath$,1)
Alles anzeigen
Unter 32Bit klappt das alles ganz wunderbar. Verweist aber unter 64Bit eine Verknüfung in C:\Program Files, wird als Ziel aber C:\Program Files (x86) ausgeben (Umleitung des WOW64 Emulators). Gibt es eine Möglichkeit, auch mit einem 32Bit Programm an den richtigen Pfad zu kommen?