Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Special windows directories

Posted on 2003-03-20
5
Medium Priority
?
165 Views
Last Modified: 2010-04-04
I'd be glad if someone could say me how can i get these windows special directories: recent documents, start menu.
0
Comment
Question by:Tadas
  • 2
  • 2
5 Comments
 
LVL 3

Accepted Solution

by:
lmikle earned 200 total points
ID: 8174717
Use a SHGetSpecialFolderPath function (ShlObj unit).

var
  sPath : String;
  pPath : PChar;
begin
  GetMem(pPath,1024);
  If SHGetSpecialFolderPath(Application.Handle,
                            pPath,
                            CSIDL_RECENT,
                            False) Then
    Begin
      sPath := StrPas(pPath);
      ShowMessage('Recent path is '+sPath);
    End;

0
 
LVL 3

Expert Comment

by:lmikle
ID: 8174738
Sorry, forget FreeMem in the end of code - add as last following line:

FreeMem(sPath,1024);

0
 
LVL 3

Expert Comment

by:emadat
ID: 8174869
Use this function:

You should include the use of these units in your code:

ActiveX, SHFolder, ShlObj

//******************************************************************************
function GetSpecialPath(frmHandle: hWnd; iFolder: integer): string;
var
     Allocator: IMalloc;
     SpecialDir: PItemIdList;
     FBuf: array[0..MAX_PATH] of Char;
     PerDir: string;
begin
     if SHGetMalloc(Allocator) = NOERROR then
     begin
          SHGetSpecialFolderLocation(frmHandle, iFolder, SpecialDir);
          SHGetPathFromIDList(SpecialDir, @FBuf[0]);
          Allocator.Free(SpecialDir);
          result := string(FBuf);
     end;
end;
//******************************************************************************


possible constants are:

  CSIDL_DESKTOP
  CSIDL_INTERNET
  CSIDL_PROGRAMS
  CSIDL_CONTROLS
  CSIDL_PRINTERS
  CSIDL_PERSONAL
  CSIDL_FAVORITES
  CSIDL_STARTUP
  CSIDL_RECENT
  CSIDL_SENDTO
  CSIDL_BITBUCKET
  CSIDL_STARTMENU
  CSIDL_DESKTOPDIRECTORY
  CSIDL_DRIVES
  CSIDL_NETWORK
  CSIDL_NETHOOD
  CSIDL_FONTS
  CSIDL_TEMPLATES
  CSIDL_COMMON_STARTMENU
  CSIDL_COMMON_PROGRAMS
  CSIDL_COMMON_STARTUP
  CSIDL_COMMON_DESKTOPDIRECTORY
  CSIDL_APPDATA
  CSIDL_PRINTHOOD
  CSIDL_ALTSTARTUP
  CSIDL_COMMON_ALTSTARTUP
  CSIDL_COMMON_FAVORITES
  CSIDL_INTERNET_CACHE
  CSIDL_COOKIES
  CSIDL_HISTORY
0
 

Author Comment

by:Tadas
ID: 8204902
Thanks for Imikle and emadat. You helped me a lot. Actually, I likes imikle's comment more, but that doesn't matter.
0
 

Author Comment

by:Tadas
ID: 8204912
Experts-exchange is awsome thing. Thanks for answer.
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This is an update to some code that someone else posted on Experts Exchange. It is an alternate approach, I think a little easier to use, & makes sure that things like the Task Bar will update.
Integration Management Part 2
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question