🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.delphi.nativeapi
Article #164

Re: SHGetFolderPath in ShellAPI?

#164
From: Rob Kennedy
Date: Mon, 26 Jan 2004 21:12
45 lines
2928 bytes
Matt wrote:
> I'm trying to write a function to return various user paths (Desktop, My
> Documents, Start Menu, etc.).  Everything I've seen references
> SHGetFolderPath, but I can't find it.  I'm using Delphi 6 Pro with all the
> latest patches and library updates.  Is that API call something that they
> just forgot, and I need to upgrade to D7, or am I just looking in the wrong
> place?

A missing API declaration is never a reason to upgrade your Delphi 
version. There's nothing magical about a function declaration (unless 
it's in System or SysInit), so if you need an API function that Borland 
didn't declare for you, just declare it yourself. Below are some 
declarations for ShGetFolderPath and its partner, ShGetFolderLocation. 
On the other hand, you could just use ShGetSpecialFolderPath instead. 
See the documentation on MSDN to determine the differences.

interface

uses Windows, ShlObj;

function ShGetFolderPath(hWndOwner: HWnd; csidl: Integer; hToken: 
THandle; dwReserved: DWord; lpszPath: PChar): HResult; stdcall;
function ShGetFolderPathA(hWndOwner: HWnd; csidl: Integer; hToken: 
THandle; dwReserved: DWord; lpszPath: PAnsiChar): HResult; stdcall;
function ShGetFolderPathW(hWndOwner: HWnd; csidl: Integer; hToken: 
THandle; dwReserved: DWord; lpszPath: PWideChar): HResult; stdcall;
function ShGetFolderLocation(hWndOwner: HWnd; csidl: Integer; hToken: 
THandle; dwReserved: DWord; out pidl: PItemIDList): HResult; stdcall;

const
   shfolder = 'ShFolder.dll';

implementation

uses ShellAPI;

function ShGetFolderPath; external shfolder name 'SHGetFolderPathA';
function ShGetFolderPathA; external shfolder name 'SHGetFolderPathA';
function ShGetFolderPathW; external shfolder name 'SHGetFolderPathW';
function ShGetFolderLocation; external shell32 name 'SHGetFolderLocation';

end.

-- 
Rob
Technical Details
Message-ID: <401582d0$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <401579db@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f94dd,93f2f86ad6d00508
X-Google-Attributes: gidf94dd,public
X-Google-ArrivalTime: 2004-01-26 13:40:56 PST
Date: Mon, 26 Jan 2004 15:12:52 -0600
From: Rob Kennedy <.>
Organization: none
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.delphi.nativeapi
Subject: Re: SHGetFolderPath in ShellAPI?
References: <401579db@newsgroups.borland.com>
In-Reply-To: <401579db@newsgroups.borland.com>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 68.74.197.249
Message-ID: <401582d0$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1075151568 68.74.197.249 (26 Jan 2004 13:12:48 -0700)
Lines: 45
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail