Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8828401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:35:55+00:00 2026-06-14T07:35:55+00:00

I use windows shell to enumerate items in the control panel and add item

  • 0

I use windows shell to enumerate items in the control panel and add item name in memo , in the end release IShellFolder and PITEMIDLIST but get error.

Code :

procedure TForm1.Button1Click(Sender: TObject);
var
  psfDeskTop : IShellFolder;
  psfControl : IShellFolder;
  pidControl : PITEMIDLIST;
  pidChild : PITEMIDLIST;
  pidAbsolute : PItemIdList;
  pEnumList : IEnumIDList;
  celtFetched : ULONG;
  FileInfo : SHFILEINFOW;

begin

  OleCheck(SHGetDesktopFolder(psfDeskTop));
  OleCheck(SHGetSpecialFolderLocation(0, CSIDL_CONTROLS, pidControl));
  OleCheck(psfDeskTop.BindToObject(pidControl, nil, IID_IShellFolder,
    psfControl));
  OleCheck(psfControl.EnumObjects(0, SHCONTF_NONFOLDERS or SHCONTF_INCLUDEHIDDEN
    or SHCONTF_FOLDERS, pEnumList));
  while pEnumList.Next(1, pidChild, celtFetched) = 0 do
  begin

    pidAbsolute := ILCombine(pidControl, pidChild);
    SHGetFileInfo(LPCTSTR(pidAbsolute), 0, FileInfo, SizeOf(FileInfo),
      SHGFI_PIDL or SHGFI_DISPLAYNAME);
    Memo1.Lines.Add(FileInfo.szDisplayName);

  end;
  //OK
  psfDeskTop._Release;
  //Error
  psfControl._Release;
  //Error
  //pEnumList._Release;
  CoTaskMemFree(pidControl);
  CoTaskMemFree(pidChild);
  CoTaskMemFree(pidAbsolute);
end;

Why it’s Ok to release psfDeskTop but get error when release psfControl and pEnumList ? is there any other way to release them ? or do I need some judgement before i release them?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T07:35:56+00:00Added an answer on June 14, 2026 at 7:35 am

    Interfaced Objects are released by internal referencecounter, there is not need to release them (You shall not release them).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use SHGetFileInfo to get windows control panel icon,I use Shell to
I have to use windows to write some shell scripts. I decided to use
In a traditional Windows shell, I can use net helpmsg to get the string-based
I use emacs23.4 on window xp. So the shell-mode use windows cmd.exe. I encountered
I use this to read a widestring out of the cmd (Windows Shell). var
I've implemented a directory walking algorithm for the Windows Shell using IShellItem , IShellFolder
I was wanting to write a simple windows shell extension to add to the
Is there a way that I can use Python on Windows to execute shell
I try to kill all processes of a specified user. i use Try Shell(C:\WINDOWS\system32\taskkill.exe
I want to enumerate all the file in the C:\Windows\Fonts\ First I use FindFirst&FindNext

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.