[VB] récupàrer le répertoire du menu démarrer

récupàrer le répertoire du menu démarrer [VB] - Programmation

Marsh Posté le 05-04-2002 à 20:10:28    

Salut a tous  
j'aimerais bien pour un de mes programme pouvoir savoir dans quel répertoire repertoire ce trouve le menu démarrer mais je ne sais pas comment faire il fo que la fonction aille sous nt/2k/xp et 9x/me
pour le rép win ou system pas de pb mais le menu démarrer j'arrive pas  
 
HELP ME PLEASE ...
 
 :hello:


---------------
L'Internet serait une toile comme les autres si elle n'avait ses millions d'araignées ...
Reply

Marsh Posté le 05-04-2002 à 20:10:28   

Reply

Marsh Posté le 17-04-2002 à 16:08:42    

Je ne pense que le chemin d'accès est différent pour certain OS mais pour win 9x le chemin est : c:\windows\menu démarer
 [:warkangel]


---------------
[:warkangel] Chassé du paradis, l'ange déchu n'a pas d'autre choix que de devenir démon pour survivre en enfer  [:warkangel]    
Reply

Marsh Posté le 17-04-2002 à 16:13:24    

Justement moi je veux trouver le chemin sur n'importe quelle OS et aussi sous les système NT celui du compte qui est loggé et la ca change tout le problème ...


---------------
L'Internet serait une toile comme les autres si elle n'avait ses millions d'araignées ...
Reply

Marsh Posté le 17-04-2002 à 17:14:32    

Je me demande s'il n'y a pas moyen d'utiliser une des variables que le systeme stock ( genre %SYSTEM% qui indique le rep sys, etc...)
Je ne sais pas si le menu demarer fait partie de ces variables, je te laisse chercher

Reply

Marsh Posté le 17-04-2002 à 20:07:39    

tu detectes le type d'OS : 9x ou NT
si c un 9x : window\menu demarrer
si c un NT :  
tu recuperes le nom de l'utilisateur
et le rep est documents and settings\ton user\menu demarrer

Reply

Marsh Posté le 17-04-2002 à 21:16:22    

je suis p-e en train de me gourrer, mais je crois que la variable d'environnement de dos %windir% est très bien aussi. Il n'y a qu'à rajouter "\menu démarrer".
 
Pour NT dsl je ne connais pas encore son fonctionnement.

Reply

Marsh Posté le 17-04-2002 à 21:16:59    

Reply

Marsh Posté le 17-04-2002 à 22:23:00    

y'a effectivement un API qui permet de le faire (son nom m'échappe)

Reply

Marsh Posté le 18-04-2002 à 10:48:08    

HappyHarry a écrit a écrit :

tu detectes le type d'OS : 9x ou NT
si c un 9x : window\menu demarrer
si c un NT :  
tu recuperes le nom de l'utilisateur
et le rep est documents and settings\ton user\menu demarrer  




 
La méthode pour NT ne marche qu'à partir de 2000. POur NT4 c'est pas ca c'est winnt/profiles/nom utilisateur

Reply

Marsh Posté le 18-04-2002 à 16:59:10    

Et "menu demarrer", ca ne marche que sur un Windows francais ...


---------------
FAQ fclc++ - FAQ C++ - C++ FAQ Lite
Reply

Marsh Posté le 18-04-2002 à 16:59:10   

Reply

Marsh Posté le 18-04-2002 à 21:51:42    

merci a tous mais effectivement je veux ke mon prog "marche" sur n'import kel os bon pas forcément en dessous de win nt4
mais il fo bien sur ke les os anglais soi tenu en compte et je veux pas le rép système non le rép windows mais le rép du menu démarrer cerdoc


---------------
L'Internet serait une toile comme les autres si elle n'avait ses millions d'araignées ...
Reply

Marsh Posté le 19-04-2002 à 08:43:07    

Voici un exemple tiré de www.allapi.net
Ca devrait répondre aux questions sur le sujet
 
Const CSIDL_DESKTOP = &H0
Const CSIDL_PROGRAMS = &H2
Const CSIDL_CONTROLS = &H3
Const CSIDL_PRINTERS = &H4
Const CSIDL_PERSONAL = &H5
Const CSIDL_FAVORITES = &H6
Const CSIDL_STARTUP = &H7
Const CSIDL_RECENT = &H8
Const CSIDL_SENDTO = &H9
Const CSIDL_BITBUCKET = &HA
Const CSIDL_STARTMENU = &HB
Const CSIDL_DESKTOPDIRECTORY = &H10
Const CSIDL_DRIVES = &H11
Const CSIDL_NETWORK = &H12
Const CSIDL_NETHOOD = &H13
Const CSIDL_FONTS = &H14
Const CSIDL_TEMPLATES = &H15
Const MAX_PATH = 260
Private Type SHITEMID
    cb As Long
    abID As Byte
End Type
Private Type ITEMIDLIST
    mkid As SHITEMID
End Type
Private Declare Function ShellAbout Lib "shell32.dll" Alias "ShellAboutA" (ByVal hWnd As Long, ByVal szApp As String, ByVal szOtherStuff As String, ByVal hIcon As Long) As Long
Private Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" (ByVal hwndOwner As Long, ByVal nFolder As Long, pidl As ITEMIDLIST) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
Private Sub Form_Load()
    'KPD-Team 1998
    'URL: http://www.allapi.net/
    'E-Mail: KPDTeam@Allapi.net
    'Show an about window
    ShellAbout Me.hWnd, App.Title, "Created by the KPD-Team 1999", ByVal 0&
    'Set the graphical mode to persistent
    Me.AutoRedraw = True
    'Print the folders to the form
    Me.Print "Start menu folder: " + GetSpecialfolder(CSIDL_STARTMENU)
    Me.Print "Favorites folder: " + GetSpecialfolder(CSIDL_FAVORITES)
    Me.Print "Programs folder: " + GetSpecialfolder(CSIDL_PROGRAMS)
    Me.Print "Desktop folder: " + GetSpecialfolder(CSIDL_DESKTOP)
End Sub
Private Function GetSpecialfolder(CSIDL As Long) As String
    Dim r As Long
    Dim IDL As ITEMIDLIST
    'Get the special folder
    r = SHGetSpecialFolderLocation(100, CSIDL, IDL)
    If r = NOERROR Then
        'Create a buffer
        Path$ = Space$(512)
        'Get the path from the IDList
        r = SHGetPathFromIDList(ByVal IDL.mkid.cb, ByVal Path$)
        'Remove the unnecessary chr$(0)'s
        GetSpecialfolder = Left$(Path, InStr(Path, Chr$(0)) - 1)
        Exit Function
    End If
    GetSpecialfolder = ""
End Function

Reply

Marsh Posté le 19-04-2002 à 09:07:59    

voilà

Reply

Marsh Posté le 19-04-2002 à 11:12:45    

tegu a écrit a écrit :

Voici un exemple tiré de www.allapi.net
Ca devrait répondre aux questions sur le sujet
 
Const CSIDL_DESKTOP = &H0
Const CSIDL_PROGRAMS = &H2
Const CSIDL_CONTROLS = &H3
Const CSIDL_PRINTERS = &H4
Const CSIDL_PERSONAL = &H5
Const CSIDL_FAVORITES = &H6
Const CSIDL_STARTUP = &H7
Const CSIDL_RECENT = &H8
Const CSIDL_SENDTO = &H9
Const CSIDL_BITBUCKET = &HA
Const CSIDL_STARTMENU = &HB
Const CSIDL_DESKTOPDIRECTORY = &H10
Const CSIDL_DRIVES = &H11
Const CSIDL_NETWORK = &H12
Const CSIDL_NETHOOD = &H13
Const CSIDL_FONTS = &H14
Const CSIDL_TEMPLATES = &H15
Const MAX_PATH = 260
Private Type SHITEMID
    cb As Long
    abID As Byte
End Type
Private Type ITEMIDLIST
    mkid As SHITEMID
End Type
Private Declare Function ShellAbout Lib "shell32.dll" Alias "ShellAboutA" (ByVal hWnd As Long, ByVal szApp As String, ByVal szOtherStuff As String, ByVal hIcon As Long) As Long
Private Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" (ByVal hwndOwner As Long, ByVal nFolder As Long, pidl As ITEMIDLIST) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
Private Sub Form_Load()
    'KPD-Team 1998
    'URL: http://www.allapi.net/
    'E-Mail: KPDTeam@Allapi.net
    'Show an about window
    ShellAbout Me.hWnd, App.Title, "Created by the KPD-Team 1999", ByVal 0&
    'Set the graphical mode to persistent
    Me.AutoRedraw = True
    'Print the folders to the form
    Me.Print "Start menu folder: " + GetSpecialfolder(CSIDL_STARTMENU)
    Me.Print "Favorites folder: " + GetSpecialfolder(CSIDL_FAVORITES)
    Me.Print "Programs folder: " + GetSpecialfolder(CSIDL_PROGRAMS)
    Me.Print "Desktop folder: " + GetSpecialfolder(CSIDL_DESKTOP)
End Sub
Private Function GetSpecialfolder(CSIDL As Long) As String
    Dim r As Long
    Dim IDL As ITEMIDLIST
    'Get the special folder
    r = SHGetSpecialFolderLocation(100, CSIDL, IDL)
    If r = NOERROR Then
        'Create a buffer
        Path$ = Space$(512)
        'Get the path from the IDList
        r = SHGetPathFromIDList(ByVal IDL.mkid.cb, ByVal Path$)
        'Remove the unnecessary chr$(0)'s
        GetSpecialfolder = Left$(Path, InStr(Path, Chr$(0)) - 1)
        Exit Function
    End If
    GetSpecialfolder = ""
End Function  




 
 
merci  
c'est meme plus que ce ke je demandais mais c parfait ton exemple


---------------
L'Internet serait une toile comme les autres si elle n'avait ses millions d'araignées ...
Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed