Soyez le premier à donner votre avis sur cette source.
Snippet vu 14 227 fois - Téléchargée 45 fois
Public Class clsGetSpecialFolder Public Enum CSIDL DESKTOP = &H0 PROGRAMS = &H2 CONTROLS = &H3 PRINTERS = &H4 PERSONAL = &H5 FAVORITES = &H6 STARTUP = &H7 RECENT = &H8 SENDTO = &H9 BITBUCKET = &HA STARTMENU = &HB DESKTOPDIRECTORY = &H10 DRIVES = &H11 NETWORK = &H12 NETHOOD = &H13 FONTS = &H14 TEMPLATES = &H15 End Enum Const MAX_PATH = 260 Private Structure SHITEMID Dim cb As Integer Dim abID As Byte End Structure Private Structure ITEMIDLIST Dim mkid As SHITEMID End Structure Private Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" (ByVal hwndOwner As Integer, ByVal nFolder As Integer, ByRef pidl As ITEMIDLIST) As Integer Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Integer, ByVal pszPath As String) As Integer Public Shared Function GetSpecialFolder(ByVal CSIDLrequest As CSIDL) As String Dim r As Integer Dim strDir As String Dim IDL As ITEMIDLIST 'Get the special folder r = SHGetSpecialFolderLocation(0, CSIDLrequest, IDL) If r = 0 Then ' NOERROR Then 'Create a buffer strDir = Space$(512) 'Get the path from the IDList r = SHGetPathFromIDList(IDL.mkid.cb, strDir) 'Remove the unnecessary chr$(0)'s strDir = strDir.Substring(0, InStr(strDir, Chr(0)) - 1) End If Return strDir End Function End Class
My.Computer.FileSystem.SpecialDirectorie
Donc même plus besion d'Enum, seul une ligne de code suffit.
Bye-Bye
Environment.GetFolderPath(enum)
...
Et cette classe est belle et bien en DotNet si vous douter essayer de la compiler en VB6 !! ;-)
Sinon, allez sur http:\docvb.free.fr, y a un fichier chm moins complet, avec moins d'exemples, mé il est en français.
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.