![]() |
|
|
Регистрация | << Правила форума >> | FAQ | Пользователи | Календарь | Поиск | Сообщения за сегодня | Все разделы прочитаны |
![]() |
|
Опции темы | Поиск в этой теме | Опции просмотра |
#1
|
|||
|
|||
![]() Есть ли типа GetWindowsDirectory но для рабочего стола?
Перерыл литературу. А почему то такой полезной функции не нашел. |
#2
|
||||
|
||||
![]() В реестре вроде где то записано...
Что делать, когда сломался комп: 1. Если вы юзер - делать ноги. 2. Если ремонтник - делать деньги. 3. Если вы программист - делать вид, что так было задумано. |
#3
|
|||
|
|||
![]() Только написав запрос на английском нашел
Код:
function GetDeskTopPath : string; var shellMalloc: IMalloc; ppidl: PItemIdList; PerDir: string; begin ppidl := nil; try if SHGetMalloc(shellMalloc) = NOERROR then begin SHGetSpecialFolderLocation(Form1.Handle, CSIDL_DESKTOP, ppidl); SetLength(Result, MAX_PATH); if not SHGetPathFromIDList(ppidl, PChar(Result)) then raise exception.create('SHGetPathFromIDList failed : invalid pidl'); SetLength(Result, lStrLen(PChar(Result))); end; finally if ppidl <> nil then shellMalloc.free(ppidl); end; end; _ttp://www.sql.ru/forum/actualthread.aspx?tid=342673 Очень расписали. Тема снята. |
#4
|
|||
|
|||
![]() Точнее полный вариант выглядит так
Код:
procedure TForm1.FormCreate(Sender: TObject); var shellMalloc: IMalloc; ppidl: PItemIdList; DesktopPath: string; begin ppidl := nil; try if SHGetMalloc(shellMalloc) = NOERROR then begin SHGetSpecialFolderLocation(Form1.Handle, CSIDL_DESKTOP, ppidl); SetLength(DesktopPath, MAX_PATH); if not SHGetPathFromIDList(ppidl, PChar(DesktopPath)) then raise exception.create('SHGetPathFromIDList failed : invalid pidl'); SetLength(DesktopPath, lStrLen(PChar(DesktopPath))); end; finally if ppidl <> nil then shellMalloc.free(ppidl); end; label11.Caption:=DesktopPath; //тут string'ом сидит путь до рабочего стола end; |
#5
|
||||
|
||||
![]() Вот еще на всякий случай
Код:
type TSystemPath = (spDesktop, spStartMenu, spPrograms, spStartup, spPersonal, spAppData, spFonts, spSendTo, spRecent, spFavorites, spCache, spCookies, spHistory, spNetHood, spPrintHood, spTemplates, spLocADat, spWindRoot, spWindSys, spTempPath, spRootDir, spProgFiles, spComFiles, spConfigPath, spDevicePath, spMediaPath, spWallPaper); ......... function GetSystemPath(SystemPath: TSystemPath): string; var ph: PChar; begin with TRegistry.Create do try RootKey := HKEY_CURRENT_USER; OpenKey('\Software\Microsoft\Windows\CurrentVersion\' + 'Explorer\Shell Folders', True); case SystemPath of spDesktop: Result := ReadString('Desktop'); spStartMenu: Result := ReadString('Start Menu'); spPrograms: Result := ReadString('Programs'); spStartup: Result := ReadString('Startup'); spPersonal: Result := ReadString('Personal'); spAppData: Result := ReadString('AppData'); spFonts: Result := ReadString('Fonts'); spSendTo: Result := ReadString('SendTo'); spRecent: Result := ReadString('Recent'); spFavorites: Result := ReadString('Favorites'); spCache: Result := ReadString('Cache'); spCookies: Result := ReadString('Cookies'); spHistory: Result := ReadString('History'); spNetHood: Result := ReadString('NetHood'); spPrintHood: Result := ReadString('PrintHood'); spTemplates: Result := ReadString('Templates'); spLocADat: Result := ReadString('Local AppData'); spWindRoot: begin GetMem(ph, 255); GetWindowsDirectory(ph, 254); Result := Strpas(ph); Freemem(ph); end; spWindSys: begin GetMem(ph, 255); GetSystemDirectory(ph, 254); Result := Strpas(ph); Freemem(ph); end; spTempPath: begin GetMem(ph, 255); GetTempPath(254, ph); Result := Strpas(ph); Freemem(ph); end; spRootDir: begin GetMem(ph, 255); GetSystemDirectory(ph, 254); Result := (Copy(Strpas(ph), 1, 2)); Freemem(ph); end; end; RootKey := HKEY_LOCAL_MACHINE; OpenKey('\SOFTWARE\Microsoft\Windows\CurrentVersion', True); case SystemPath of spProgFiles: Result := ReadString('ProgramFilesDir'); spComFiles: Result := ReadString('CommonFilesDir'); spConfigPath: Result := ReadString('ConfigPath'); spDevicePath: Result := ReadString('DevicePath'); spMediaPath: Result := ReadString('MediaPath'); spWallPaper: Result := ReadString('WallPaperDir'); end; finally CloseKey; Free; end; { if (Result <> '') and (Result[Length(Result)] <> '\') then Result := Result + '\';} end; — Как тебя понимать? — Понимать меня не обязательно. Обязательно меня любить и кормить вовремя. На Delphi, увы, больше не программирую. Рекомендуемая литература по программированию |