Code: Select all
EnableExplicit
Global Path$
Global IcoPath$ = "C:\Windows\System32\Shell32.dll"
Procedure Seticon()
Protected idxIcon, PathMem$, PathDesktop$, flgINI
IcoPath$ = OpenFileRequester("Open file", IcoPath$, "exe, dll|*.exe;*.dll", 0)
If Asc(IcoPath$)
PathMem$ = Space(260)
PokeS(@PathMem$, IcoPath$)
If PickIconDlg_(0, @PathMem$, 260, @idxIcon)
PathDesktop$ = Path$ + "desktop.ini"
If FileSize(PathDesktop$) > 0
SetFileAttributes(PathDesktop$, 0)
flgINI = OpenPreferences(PathDesktop$, #PB_Preference_NoSpace)
Else
flgINI = CreatePreferences(PathDesktop$, #PB_Preference_NoSpace)
EndIf
If flgINI
PreferenceGroup(".ShellClassInfo")
WritePreferenceString("IconFile", PathMem$)
WritePreferenceInteger("IconIndex", idxIcon)
ClosePreferences()
SetFileAttributes(PathDesktop$, #PB_FileSystem_ReadOnly | #PB_FileSystem_Hidden)
SetFileAttributes(Path$, #PB_FileSystem_System)
EndIf
EndIf
EndIf
EndProcedure
Path$ = ProgramParameter()
If Not FileSize(Path$) = -2
Path$ = PathRequester("Open", GetHomeDirectory())
If Not Asc(Path$)
End
EndIf
EndIf
If Right(Path$, 1) <> #PS$
Path$ + #PS$
EndIf
Seticon()