چطوری آدرس شاخه های اصلی سیستم عامل رو پیدا کنیم؟
Dim i As String
i=FindSystemFolder(startup)
حالا خود مدل :
Option Explicit
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
Const MAX_PATH = 260
Public Enum SystemFolder
Desktop = 0
StartMenu_Programs = 2
My_Documents = 5
Favorites = 6
Startup = 7
Recent = 8
SendTo = 9
Start_Menu = 11
Windows_Desktop = 16
Network_Neighborhood = 19
Fonts = 20
ShellNew = 21
AllUsers_Desktop = 25
ApplicationData = 26
Printhood = 27
TemporaryInternetFiles = 32
Cookies = 33
History = 34
End Enum
Public 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_End:
Exit Function
FindSystemFolder_Err:
Err.Raise Err.Number, "FindSystemFolder::" & Err.Source, Err.Description
End Function
*از عباراتی که قرمز کردم به عنوان آرگومان برای ارسال به تابع استفاده کنین.