Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to Set the Desktop as the initial directory Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
02-Oct-02
Category
System
Language
Delphi 2.x
Views
46
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius 

In a TOpenDialog, you can set the initial directory. How do I set it as the 
desktop? I could set it as c:\windows\desktop, but then what if Windows is not on 
the user's c drive?

Answer:

There is a shell function that can be used to inquire about the location of several 
shell-related folders. You need to add ShlObj to the uses clause for this, plus 
ActiveX for the CoTaskMemFree.
1   
2   procedure FreePidl(pidl: PItemIDList);
3   begin
4     CoTaskMemFree(pidl);
5   end;
6   
7   procedure TForm1.Button2Click(Sender: TObject);
8   var
9     pidl: PItemIDList;
10    buf: array[0..MAX_PATH] of Char;
11  begin
12    if Succeeded(ShGetSpecialFolderLocation(Handle, CSIDL_DESKTOP, pidl)) then
13    begin
14      if ShGetPathfromIDList(pidl, buf) then
15        ShowMessage(buf);
16      FreePIDL(pidl);
17    end;
18  end;


See win32.hlp (or better msdn.microsoft.com, the list has been extended for Win98/2000) for a list of CSIDL values. There is also a newer ShGetSpecialFolderPath API that directly returns the path, but it is not available on older Win95 and NT installations.

			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC