Code : Tout sélectionner
Debug OpenFileRequester("FileReq","fichier","*.*",0)
si qq voit comment faire

Code : Tout sélectionner
Debug OpenFileRequester("FileReq","fichier","*.*",0)
Code : Tout sélectionner
Procedure.s Cible_Link(pszShortcutFile.s)
CoInitialize_(0)
#STGM_READ = 0
#SLGP_SHORTPATH=2
#SLR_NO_UI=1
If CoCreateInstance_(?CLSID_ShellLink,0,1,?IID_IShellLink,@psl.IShellLinkA ) = 0
If psl\QueryInterface(?IID_IPersistFile,@ppf.IPersistFile) = 0
size.l=MultiByteToWideChar_(#CP_ACP,0,pszShortcutFile,-1,0,0)
Dim unicode.w(size)
MultiByteToWideChar_(#CP_ACP, 0, pszShortcutFile, Len(pszShortcutFile), unicode(), size)
If ppf\Load(unicode(), #STGM_READ)=0
If psl\Resolve(0, #SLR_NO_UI)=0
szGotPath.s=Space(1024)
If psl\GetPath(@szGotPath, 1024, 0, #SLGP_SHORTPATH)=0
Debug szGotPath
EndIf
EndIf
EndIf
ppf\Release()
EndIf
psl\Release()
EndIf
CoUninitialize_()
ProcedureReturn szGotPath
DataSection
CLSID_ShellLink:
; 00021401-0000-0000-C000-000000000046
Data.l $00021401
Data.w $0000,$0000
Data.b $C0,$00,$00,$00,$00,$00,$00,$46
IID_IShellLink:
; DEFINE_SHLGUID(IID_IShellLinkA, 0x000214EEL, 0, 0);
; C000-000000000046
Data.l $000214EE
Data.w $0000,$0000
Data.b $C0,$00,$00,$00,$00,$00,$00,$46
IID_IPersistFile:
; 0000010b-0000-0000-C000-000000000046
Data.l $0000010B
Data.w $0000,$0000
Data.b $C0,$00,$00,$00,$00,$00,$00,$46
EndDataSection
EndProcedure
LINK$=OpenFileRequester("Choisir un raccourci", "Raccourci", "*.lnk", 0)
Cible$=Cible_Link(LINK$)
If Cible$<>""
Debug Cible$
MessageRequester("La cible trouvée est:", Cible$)
EndIf
Code : Tout sélectionner
; German forum : http://robsite.de/php/pureboard/viewtopic.php?t=3078&highlight=
; Author: Danilo
; Date: 09. December 2003
;
; create shell links/shortcuts
; translated from my old example that used CallCOM()
;
; by Danilo, 09.12.2003
;
; requires PB 3.81+ !!!
Procedure CreateShellLink(PATH$, LINK$, Argument$, DESCRIPTION$, WorkingDirectory$, ShowCommand.l, HotKey.l, IconFile$, IconIndexInFile.l)
CoInitialize_(0)
If CoCreateInstance_(?CLSID_ShellLink, 0, 1, ?IID_IShellLink, @psl.IShellLinkA) = 0
Set_ShellLink_preferences :
; The file TO which is linked ( = target for the Link )
;
psl\SetPath(@PATH$)
; Arguments for the Target
;
psl\SetArguments(@Argument$)
; Working Directory
;
psl\SetWorkingDirectory(@WorkingDirectory$)
; Description ( also used as Tooltip for the Link )
;
psl\SetDescription(@DESCRIPTION$)
; Show command:
; SW_SHOWNORMAL = Default
; SW_SHOWMAXIMIZED = aehmm... Maximized
; SW_SHOWMINIMIZED = play Unreal Tournament
psl\SetShowCmd(ShowCommand)
; Hotkey:
; The virtual key code is in the low-order byte,
; and the modifier flags are in the high-order byte.
; The modifier flags can be a combination of the following values:
;
; HOTKEYF_ALT = ALT key
; HOTKEYF_CONTROL = CTRL key
; HOTKEYF_EXT = Extended key
; HOTKEYF_SHIFT = SHIFT key
;
psl\SetHotkey(HotKey)
; Set Icon for the Link:
; There can be more than 1 icons in an icon resource file,
; so you have to specify the index.
;
psl\SetIconLocation(@IconFile$, IconIndexInFile)
ShellLink_SAVE :
; Query IShellLink For the IPersistFile interface For saving the
; shortcut in persistent storage.
If psl\QueryInterface(?IID_IPersistFile, @ppf.IPersistFile) = 0
; Ensure that the string is Unicode.
Mem.s = Space(1000) ; AllocateMemory(1,1000)
MultiByteToWideChar_(#CP_ACP, 0, LINK$, -1, Mem, 1000)
; Save the link by calling IPersistFile::Save.
hres = ppf\Save(@Mem, #True)
result = 1
ppf\Release()
EndIf
psl\Release()
EndIf
CoUninitialize_()
ProcedureReturn result
DataSection
CLSID_ShellLink :
; 00021401-0000-0000-C000-000000000046
Data.l $00021401
Data.w $0000, $0000
Data.b $C0, $00, $00, $00, $00, $00, $00, $46
IID_IShellLink :
; DEFINE_SHLGUID(IID_IShellLinkA, 0x000214EEL, 0, 0);
; C000-000000000046
Data.l $000214EE
Data.w $0000, $0000
Data.b $C0, $00, $00, $00, $00, $00, $00, $46
IID_IPersistFile :
; 0000010b-0000-0000-C000-000000000046
Data.l $0000010B
Data.w $0000, $0000
Data.b $C0, $00, $00, $00, $00, $00, $00, $46
EndDataSection
EndProcedure
Procedure.s GetFileFromShellLink(pszShortcutFile.s)
; Pour récupérer la cible du raccourci
CoInitialize_(0)
#STGM_READ = 0
#SLGP_SHORTPATH = 2
If CoCreateInstance_(?CLSID_ShellLink2, 0, 1, ?IID_IShellLink2, @psl.IShellLinkA ) = 0
If psl\QueryInterface(?IID_IPersistFile2, @ppf.IPersistFile) = 0
size.l = MultiByteToWideChar_(#CP_ACP, 0, pszShortcutFile, -1, 0, 0)
Dim unicode.w(size)
MultiByteToWideChar_(#CP_ACP, 0, pszShortcutFile, Len(pszShortcutFile), unicode(), size)
If ppf\Load(unicode(), #STGM_READ) = 0
szGotPath.s = Space(size + 1)
If psl\GetPath(@szGotPath, size + 1, 0, #SLGP_SHORTPATH) = 0
Debug size
Debug szGotPath
EndIf
EndIf
ppf\Release()
EndIf
psl\Release()
EndIf
CoUninitialize_()
ProcedureReturn szGotPath
DataSection
CLSID_ShellLink2 :
; 00021401-0000-0000-C000-000000000046
Data.l $00021401
Data.w $0000, $0000
Data.b $C0, $00, $00, $00, $00, $00, $00, $46
IID_IShellLink2 :
; DEFINE_SHLGUID(IID_IShellLinkA, 0x000214EEL, 0, 0);
; C000-000000000046
Data.l $000214EE
Data.w $0000, $0000
Data.b $C0, $00, $00, $00, $00, $00, $00, $46
IID_IPersistFile2 :
; 0000010b-0000-0000-C000-000000000046
Data.l $0000010B
Data.w $0000, $0000
Data.b $C0, $00, $00, $00, $00, $00, $00, $46
EndDataSection
EndProcedure
;- Explication des paramètres de la fonction
; CreateLink(PATH$, LINK$, Argument$, DESCRIPTION$, WorkingDirectory$, ShowCommand.l, HotKey.l, IconFile$, IconIndexInFile.l)
; PATH$ = Cible du raccourci ("c:\program files\PureBasic\purebasic.exe")
; LINK$ = Nom et emplacement du raccourci ("c:\pb.lnk")
; Argument$ = arguments
; DESCRIPTION$ = Description et Tooltip ("Start PureBasic")
; WorkingDirectory$ = Répertoire de travail ("c:\program files\PureBasic\")
; ShowCommand.l = Type d'ouverture de la fenêtre #SW_SHOWNORMAL ou #SW_SHOWMAXIMIZED ou #SW_SHOWMINIMIZED
; HotKey.l = Touche de raccourci, mettre 0 pour aucune touche de raccourci
; IconFile$, IconIndexInFile.l = Adresse de l'icône + Index de l'icône ( "c:\program files\PureBasic\purebasic.exe" , 0 )
;- Test
; On va créer un raccourci vers l'éditeur de PB à l'adresse "c:\PB.lnk"
CreateShellLink("c:\program files\PureBasic\purebasic.exe", "c:\PureBasic.lnk", "", "Pure FUN", "c:\program files\PureBasic\", #SW_SHOWNORMAL, 0, "c:\program files\PureBasic\purebasic.exe", 0)
MessageRequester("Cible", GetFileFromShellLink("c:\PureBasic.lnk"), 0)
Code : Tout sélectionner
; German forum : http://robsite.de/php/pureboard/viewtopic.php?t=3078&highlight=
; Author: Danilo
; Date: 09. December 2003
;
; create shell links/shortcuts
; translated from my old example that used CallCOM()
;
; by Danilo, 09.12.2003
;
; requires PB 3.81+ !!!
DataSection
CLSID_ShellLink :
; 00021401-0000-0000-C000-000000000046
Data.l $00021401
Data.w $0000, $0000
Data.b $C0, $00, $00, $00, $00, $00, $00, $46
IID_IShellLink :
; DEFINE_SHLGUID(IID_IShellLinkA, 0x000214EEL, 0, 0);
; C000-000000000046
Data.l $000214EE
Data.w $0000, $0000
Data.b $C0, $00, $00, $00, $00, $00, $00, $46
IID_IPersistFile :
; 0000010b-0000-0000-C000-000000000046
Data.l $0000010B
Data.w $0000, $0000
Data.b $C0, $00, $00, $00, $00, $00, $00, $46
EndDataSection
Procedure CreateShellLink(PATH$, LINK$, Argument$, DESCRIPTION$, WorkingDirectory$, ShowCommand.l, HotKey.l, IconFile$, IconIndexInFile.l)
CoInitialize_(0)
If CoCreateInstance_(?CLSID_ShellLink, 0, 1, ?IID_IShellLink, @psl.IShellLinkA) = 0
Set_ShellLink_preferences :
; The file TO which is linked ( = target for the Link )
;
psl\SetPath(@PATH$)
; Arguments for the Target
;
psl\SetArguments(@Argument$)
; Working Directory
;
psl\SetWorkingDirectory(@WorkingDirectory$)
; Description ( also used as Tooltip for the Link )
;
psl\SetDescription(@DESCRIPTION$)
; Show command:
; SW_SHOWNORMAL = Default
; SW_SHOWMAXIMIZED = aehmm... Maximized
; SW_SHOWMINIMIZED = play Unreal Tournament
psl\SetShowCmd(ShowCommand)
; Hotkey:
; The virtual key code is in the low-order byte,
; and the modifier flags are in the high-order byte.
; The modifier flags can be a combination of the following values:
;
; HOTKEYF_ALT = ALT key
; HOTKEYF_CONTROL = CTRL key
; HOTKEYF_EXT = Extended key
; HOTKEYF_SHIFT = SHIFT key
;
psl\SetHotkey(HotKey)
; Set Icon for the Link:
; There can be more than 1 icons in an icon resource file,
; so you have to specify the index.
;
psl\SetIconLocation(@IconFile$, IconIndexInFile)
ShellLink_SAVE :
; Query IShellLink For the IPersistFile interface For saving the
; shortcut in persistent storage.
If psl\QueryInterface(?IID_IPersistFile, @ppf.IPersistFile) = 0
; Ensure that the string is Unicode.
Mem.s = Space(1000) ; AllocateMemory(1,1000)
MultiByteToWideChar_(#CP_ACP, 0, LINK$, -1, Mem, 1000)
; Save the link by calling IPersistFile::Save.
hres = ppf\Save(@Mem, #True)
result = 1
ppf\Release()
EndIf
psl\Release()
EndIf
CoUninitialize_()
ProcedureReturn result
EndProcedure
Procedure.s GetFileFromShellLink(pszShortcutFile.s)
; Pour récupérer la cible du raccourci
CoInitialize_(0)
#STGM_READ = 0
#SLGP_SHORTPATH = 2
If CoCreateInstance_(?CLSID_ShellLink, 0, 1, ?IID_IShellLink, @psl.IShellLinkA ) = 0
If psl\QueryInterface(?IID_IPersistFile, @ppf.IPersistFile) = 0
size.l = MultiByteToWideChar_(#CP_ACP, 0, pszShortcutFile, -1, 0, 0)
Dim unicode.w(size)
MultiByteToWideChar_(#CP_ACP, 0, pszShortcutFile, Len(pszShortcutFile), unicode(), size)
If ppf\Load(unicode(), #STGM_READ) = 0
szGotPath.s = Space(size + 1)
If psl\GetPath(@szGotPath, size + 1, 0, #SLGP_SHORTPATH) = 0
Debug size
Debug szGotPath
EndIf
EndIf
ppf\Release()
EndIf
psl\Release()
EndIf
CoUninitialize_()
ProcedureReturn szGotPath
EndProcedure
;- Explication des paramètres de la fonction
; CreateLink(PATH$, LINK$, Argument$, DESCRIPTION$, WorkingDirectory$, ShowCommand.l, HotKey.l, IconFile$, IconIndexInFile.l)
; PATH$ = Cible du raccourci ("c:\program files\PureBasic\purebasic.exe")
; LINK$ = Nom et emplacement du raccourci ("c:\pb.lnk")
; Argument$ = arguments
; DESCRIPTION$ = Description et Tooltip ("Start PureBasic")
; WorkingDirectory$ = Répertoire de travail ("c:\program files\PureBasic\")
; ShowCommand.l = Type d'ouverture de la fenêtre #SW_SHOWNORMAL ou #SW_SHOWMAXIMIZED ou #SW_SHOWMINIMIZED
; HotKey.l = Touche de raccourci, mettre 0 pour aucune touche de raccourci
; IconFile$, IconIndexInFile.l = Adresse de l'icône + Index de l'icône ( "c:\program files\PureBasic\purebasic.exe" , 0 )
;- Test
; On va créer un raccourci vers l'éditeur de PB à l'adresse "c:\PB.lnk"
CreateShellLink("c:\program files\PureBasic\purebasic.exe", "c:\PureBasic.lnk", "", "Pure FUN", "c:\program files\PureBasic\", #SW_SHOWNORMAL, 0, "c:\program files\PureBasic\purebasic.exe", 0)
MessageRequester("Cible", GetFileFromShellLink("c:\PureBasic.lnk"))