"Lars Jensen" <streg@post1.tele.dk> wrote in message
news:Xns91E69619E2C8Cstregpost1teledk@130.225.247.90...
> Hej
>
> Hvordan finder man stien til mappen Programmer under
> windows-mappen. Mappen hedder jo noget andet på engelsk
> og tysk osv. Og det er vel heller ikke sikkert, at den altid ligger
> under en mappe, der hedder c:\windows, hvis man har
> installeret windows i en mappe med et andet navn.
>
> FileSystemObject har en egenskab GetSpecialFolder, der kan
> hente stien for system-mappen, temp-mappen og windows-
> mappen. Men der må da være nogle flere
> muligheder et sted.
>
> Hilsen Lars
Hej Lars
Du kan enten bruge registreringsdatabasen eller winAPI. Kig i
mappen
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion
Nøglenavne:
CommonFilesDir Common files (full path)
ProgramFilesDir Program files (full path)
ProgramFilesPath Program files (full path)
ConfigPath WINDOWS\Config (full path)
DevicePath WINDOWS\INF (full path)
ChannelFolderName IE4 Favorites\Channels (name only)
LinkFolderName IE4 Favorites\Links name (name only)
MediaPath Media (full path)
OldWinDir Old windows (full path)
SM_AccessoriesName StartMenu\Programs\Accesories (name only)
PF_AccessoriesName Program Files\Accesories (name only)
WallPaperDir IE4 wallpapers dir (full path)
For andre specielle mapper (mest undermapper i windows
mappen) kan du bruge API funktionen
SHGetSpecialFolderLocation.
' KODE KODE KODE
Option Explicit
Const MAX_PATH = 260
Public Enum SystemFolder
Const CSIDL_DESKTOP = &H0
Const CSIDL_INTERNET = &H1
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 CSIDL_COMMON_STARTMENU = &H16
Const CSIDL_COMMON_PROGRAMS = &H17
Const CSIDL_COMMON_STARTUP = &H18
Const CSIDL_COMMON_DESKTOPDIRECTORY = &H19
Const CSIDL_APPDATA = &H1A
Const CSIDL_PRINTHOOD = &H1B
Const CSIDL_ALTSTARTUP = &H1D
Const CSIDL_COMMON_ALTSTARTUP = &H1E
Const CSIDL_COMMON_FAVORITES = &H1F
Const CSIDL_INTERNET_CACHE = &H20
Const CSIDL_COOKIES = &H21
Const CSIDL_HISTORY = &H22
End Enum
Private Declare Function SHGetSpecialFolderLocation _
Lib "shell32" (ByVal hwnd As Long, _
ByVal nFolder As Long, _
Pidl As Long) As Long
Private Declare Function SHGetPathFromIDList _
Lib "shell32" (Pidl As Long, _
ByVal FolderPath As String) As Long
Private Function FindSystemFolder(ByVal lngNum As SystemFolder) As String
On Error GoTo FindSystemFolder_Err
Dim lpStartupPath As String * MAX_PATH
Dim Pidl As Long
Dim hResult As Long
hResult = SHGetSpecialFolderLocation(0, lngNum, Pidl)
If hResult = 0 Then
hResult = SHGetPathFromIDList(ByVal Pidl, lpStartupPath)
If hResult = 1 Then
lpStartupPath = Left$(Trim$(lpStartupPath), _
InStr (lpStartupPath, Chr(0)) - 1)
FindSystemFolder = Trim$(lpStartupPath)
End If
End If
FindSystemFolder_Err:
Exit Function
End Function
' SLUT SLUT SLUT
Håber du kan bruge det til noget
--
Mikkel Bundgaard
IT University of Copenhagen
http://officehelp.gone.dk
Codito, Ergo Sum