Page 1 sur 1
Trouver le dossier temporaire
Publié : jeu. 29/janv./2004 10:20
par Le Soldat Inconnu
Code : Tout sélectionner
Procedure.s GetTempDirectory()
Protected WinTemp.s
WinTemp = Space(255)
If GetTempPath_(255, WinTemp)
Else
WinTemp = "c:\Temp\"
EndIf
If Right(WinTemp, 1) <> "\" : WinTemp = WinTemp + "\" : EndIf
ProcedureReturn WinTemp
EndProcedure
;- Test
Debug GetTempDirectory()
Publié : sam. 04/nov./2006 18:12
par Kwai chang caine
Bonjour soldat
Je viens de trouver ce code pour connaitre l'adresse du dossier temporaire, mais pourquoi retourne t'il l'adresse sous format DOS ??
J'en ai essayé un autre qui viens de toi aussi, mais quand à lui il ne retourne pas apparement l'adresse du fichier temp.
Code : Tout sélectionner
; Auteur : Le Soldat Inconnu, d'après le code de je sais plus ...
; Version de PB : 3.90
;
; Explication du programme :
; Récupérer les dossier spéciaux de windows
Procedure.s GetSpecialFolderLocation(lngCSIDL.l)
Protected lngRet.l, strLocation.s, pidl.l
strLocation = Space(260)
lngRet = SHGetSpecialFolderLocation_(0, lngCSIDL, @pidl)
If lngRet = 0
SHGetPathFromIDList_(pidl, @strLocation)
If lngRet = 0
strLocation = RTrim(strLocation)
If Right(strLocation, 1) <> "\"
strLocation = strLocation + "\"
EndIf
ProcedureReturn strLocation
EndIf
CoTaskMemFree_(pidl)
EndIf
EndProcedure
;- Programme principal
For n = 0 To 80
If GetSpecialFolderLocation(n) <> ""
Debug RSet(Str(n), 2, "0") + " " + GetSpecialFolderLocation(n)
EndIf
Next; Auteur : Le Soldat Inconnu, d'après le code de je sais plus ...
; Version de PB : 3.90
;
; Explication du programme :
; Récupérer les dossier spéciaux de windows
Procedure.s GetSpecialFolderLocation(lngCSIDL.l)
Protected lngRet.l, strLocation.s, pidl.l
strLocation = Space(260)
lngRet = SHGetSpecialFolderLocation_(0, lngCSIDL, @pidl)
If lngRet = 0
SHGetPathFromIDList_(pidl, @strLocation)
If lngRet = 0
strLocation = RTrim(strLocation)
If Right(strLocation, 1) <> "\"
strLocation = strLocation + "\"
EndIf
ProcedureReturn strLocation
EndIf
CoTaskMemFree_(pidl)
EndIf
EndProcedure
;- Programme principal
For n = 0 To 80
If GetSpecialFolderLocation(n) <> ""
Debug RSet(Str(n), 2, "0") + " " + GetSpecialFolderLocation(n)
EndIf
Next
Quelqu'un en aurait il un qui retourne le chemin complet du repertoire temporaire.
Merci
Bonne journée

Publié : sam. 04/nov./2006 20:24
par nico
Code : Tout sélectionner
Procedure.s GetTempDirectory()
Protected WinTemp.s
WinTemp = Space(255)
If GetTempPath_(255, WinTemp)
Else
WinTemp = "c:\Temp\"
EndIf
If Right(WinTemp, 1) <> "\" : WinTemp = WinTemp + "\" : EndIf
ProcedureReturn WinTemp
EndProcedure
Chemin.s= GetTempDirectory()
LongPathName.s=Space(#MAX_PATH)
Debug Chemin
; Transformation Nom court en Nom long
If OpenLibrary(0,"Kernel32")
CallFunction(0,"GetLongPathNameA",Chemin,@LongPathName,#MAX_PATH)
CloseLibrary(0)
EndIf
Debug LongPathName
Publié : sam. 04/nov./2006 22:10
par Droopy
PB inclus la fonction
GetTemporaryDirectory() 
Publié : dim. 05/nov./2006 7:57
par Kwai chang caine
Merci beaucoup à vous deux.
Que ferais-je sans vous.
Excelente journée