Taskbar - VB
Формулировка задачи:
Привет...
ну вот скрипт, мне надо поменять расположения то есть вместо (ssfDESKTOP) надо C:\Users\Admin\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar
Подскажите пожалуйста
Решение задачи: «Taskbar»
textual
Листинг программы
Option Explicit
Private Type UUID
data1 As Long
data2 As Integer
data3 As Integer
data4(7) As Byte
End Type
Private Declare Function SHGetKnownFolderPath Lib "Shell32.dll" (rfid As UUID, ByVal dwFlags As Long, ByVal hToken As Long, ppszPath As Long) As Long
Private Declare Function CLSIDFromString Lib "ole32.dll" (ByVal lpszCLSID As Long, ByRef clsid As UUID) As Long
Private Declare Function lstrlen Lib "kernel32.dll" Alias "lstrlenW" (ByVal lpString As Long) As Long
Private Declare Function lstrcpyn Lib "kernel32.dll" Alias "lstrcpynW" (ByVal lpString1 As Long, ByVal lpString2 As Long, ByVal iMaxLength As Long) As Long
Private Sub Form_Load()
Const FOLDERID_UserPinned As String = "{9E3995AB-1F9C-4F13-B827-48B24B6C7174}"
Dim sUserPinned As String
'If OSVer.MajorMinor >= 6 Then ' Vista+
sUserPinned = GetKnownFolderPath(FOLDERID_UserPinned)
'End If
MsgBox sUserPinned & "\" & "TaskBar"
End Sub
Public Function GetKnownFolderPath(ByVal KnownFolderID As String) As String
On Error GoTo ErrorHandler
'https://msdn.microsoft.com/en-us/library/windows/desktop/dd378457(v=vs.85).aspx
Const KF_FLAG_NOT_PARENT_RELATIVE As Long = &H200&
Const KF_FLAG_DEFAULT_PATH As Long = &H400&
Const KF_FLAG_CREATE As Long = &H8000&
'If OSVer.MajorMinor < 6 Then Exit Function
Dim rfid As UUID
Dim lr As Long
Dim sPath As String
Dim Ptr As Long
Dim strLen As Long
CLSIDFromString StrPtr(KnownFolderID), rfid
lr = SHGetKnownFolderPath(rfid, KF_FLAG_NOT_PARENT_RELATIVE Or KF_FLAG_DEFAULT_PATH, 0&, Ptr)
If 0 = lr Then
strLen = lstrlen(Ptr)
sPath = String$(strLen, vbNullChar)
lstrcpyn StrPtr(sPath), Ptr, strLen + 1&
GetKnownFolderPath = sPath
End If
Exit Function
ErrorHandler:
Debug.Print Err; "Engine.GetKnownFolderPath"; "KnownFolderID:"; KnownFolderID
End Function