2013년 1월 18일 금요일

특정 폴더 찾기


uses WinApi.Shlobj, ActiveX;

procedure TForm2.Button1Click(Sender: TObject);
var
  PIDL: PItemIDList;
  // Path: String;
  Path: PChar;
  Folder: integer;
  AMalloc: IMalloc;
begin
  Folder:= CSIDL_INTERNET_CACHE;
  // SetLength(Path,MAX_PATH);
  Path:= StrAlloc(Max_Path);
  SHGetSpecialFolderLocation(Application.Handle, Folder, PIDL);
  // if SHGetPathFromIDList(PIDL, pChar(Path)) then
  if SHGetPathFromIDList(PIDL, Path) then
    Edit1.Text:= Path;
  SHGetMalloc(AMalloc);
  StrDispose(Path);
end;

Path 변수를 String 과 PChar 2가지의 방법으로 구현하여 보았습니다.
당연 String 으로 할 경우에는 StrDispose 가 필요없습니다.

댓글 없음:

델파이의 부활(Antigravity와의 만남)?

 델파이 프로그램을 사용하여 개인적으로 필요한 프로그램을 생성해 왔는데, 얼마전부터 파이썬으로 옮겨갔다.  그런데 Google 의 Antigravity를 만나고 나서 델파이에 대한 미련을 버리지 못해  제미나이가 Delphi이에 대한 학습도 엄청 했을...