PCPT
Messages postés13272Date d'inscriptionlundi 13 décembre 2004StatutMembreDernière intervention 3 février 201847 21 déc. 2007 à 13:15
salut,
Option Explicit
'
Private Const DESKTOP As Long = &H0
Private Type SHITEMID
SHItem As Long
itemID() As Byte
End Type
Private Type ITEMIDLIST
shellID As SHITEMID
End Type
Private Declare Function MakeSureDirectoryPathExists Lib
"imagehlp.dll" (ByVal lpPath As String) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal shidl As Long, ByVal shPath As String) As Long
Private Declare Function SHGetSpecialFolderLocation Lib
"shell32.dll" (ByVal hWnd As Long, ByVal folderid As Long, shidl As ITEMIDLIST) As
Long
Function CreateForderOnDesktop(ByVal sFolder As String) As String
' retourne vide si
échec, sinon le nom du chemin complet
CreateForderOnDesktop = vbNullString
Const sForbidden As String = "\/:*?""<>|"
Dim i As Integer, tIDL As ITEMIDLIST, sBuffer As String, sRet As String
' nom chemin
valide
If LenB(sFolder) Then
For i = 1 To LenB(sFolder) Step 2
If InStrB(1, sForbidden, MidB$(sFolder, i, 2)) Then
Exit Function
Next i
' chemin
DESKTOP
sBuffer = Space$(256)
If SHGetSpecialFolderLocation(App.hInstance, DESKTOP, tIDL) =
0 Then
If SHGetPathFromIDList(ByVal tIDL.shellID.SHItem, ByVal sBuffer) Then
sRet = Left$(sBuffer, InStr(sBuffer, Chr$(0)) -
1)
If Not (RightB$(sRet, 2) = "") Then sRet = sRet & ""
sRet = sRet & sFolder & ""
' crée le dossier.
pas d'erreur s'il existe puisqu'il sera toujours existant
ensuite
If Not (MakeSureDirectoryPathExists(sRet) = 0) Then
CreateForderOnDesktop =
sRet
End If
End If
End If
End Function
Private Sub Form_Load()
MsgBox CreateForderOnDesktop("nouveau
dossier")
End Sub
++
PCPT [AFCK]
<hr size="2" width="100%" />Prenez un instant pour répondre à [infomsg_SONDAGE-POP3-POUR-CS_769706.aspx ce sondage] svp
cs_ghuysmans99
Messages postés3982Date d'inscriptionjeudi 14 juillet 2005StatutMembreDernière intervention30 juin 201316 21 déc. 2007 à 14:05
Fais "Réponse Acceptée !" sur la réponse de PCPT (salut!) comme ça ton thread est indexé pour les recherches et n'apparaîtra plus dans les rss du forum ...
_______________________________________________________________________
VB.NETis good ...VB6is better <f></f>