Créer un dossier le bureau

Résolu
infoeduc Messages postés 5 Date d'inscription mercredi 29 août 2007 Statut Membre Dernière intervention 9 février 2008 - 21 déc. 2007 à 11:19
cs_ghuysmans99 Messages postés 3982 Date d'inscription jeudi 14 juillet 2005 Statut Membre Dernière intervention 30 juin 2013 - 21 déc. 2007 à 14:05
Bonjour,

Je cherche le code VB6 permettant de créer un nouveau dossier sur le bureau de Windows.

Merci d'avance pour vos réponses.

BRUNO 

4 réponses

PCPT Messages postés 13272 Date d'inscription lundi 13 décembre 2004 Statut Membre Dernière intervention 3 février 2018 47
21 déc. 2007 à 13:21
même pas besoin de tester la validité en fait, l'API s'en charge

snippet dispo ici :
http://www.codyx.org/snippet_creer-dossier-sur-bureau_525.aspx

++
<hr size="2" width="100%" />Prenez un instant pour répondre à [infomsg_SONDAGE-POP3-POUR-CS_769706.aspx ce sondage] svp
3
PCPT Messages postés 13272 Date d'inscription lundi 13 décembre 2004 Statut Membre Dernière intervention 3 février 2018 47
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
0
infoeduc Messages postés 5 Date d'inscription mercredi 29 août 2007 Statut Membre Dernière intervention 9 février 2008
21 déc. 2007 à 14:01
Merci beaucoup, ça fonctionne impec !!!

Cordialement

Bruno
0
cs_ghuysmans99 Messages postés 3982 Date d'inscription jeudi 14 juillet 2005 Statut Membre Dernière intervention 30 juin 2013 16
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>
0
Rejoignez-nous