?
Solved

Special windows directories

Posted on 2003-03-20
5
Medium Priority
?
164 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

771 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