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
Set the Desktop as the initial directory 02-Oct-02
Category
System
Language
Delphi 2.x
Views
60
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   procedure FreePidl(pidl: PItemIDList);
2   begin
3     CoTaskMemFree(pidl);
4   end;
5   
6   procedure TForm1.Button2Click(Sender: TObject);
7   var
8     pidl: PItemIDList;
9     buf: array[0..MAX_PATH] of Char;
10  begin
11    if Succeeded(ShGetSpecialFolderLocation(Handle, CSIDL_DESKTOP, pidl)) then
12    begin
13      if ShGetPathfromIDList(pidl, buf) then
14        ShowMessage(buf);
15      FreePIDL(pidl);
16    end;
17  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