SHGetFolderLocation

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

SHGetFolderLocation

Jerome Chan
I can't seem to be able to find this function in the shell library. I'm
trying to locate the application data "CSIDL_APPDATA" folder location; I
need to store some application specific data here.

Or should I just pop up a folder browser window and ask the user to
select a folder and store the folder path in the HKEY_CURRENT_USER
registry?


Reply | Threaded
Open this post in threaded view
|

Re: SHGetFolderLocation

Bill Schwab
> I can't seem to be able to find this function in the shell library. I'm
> trying to locate the application data "CSIDL_APPDATA" folder location; I
> need to store some application specific data here.

Which OS are you using?  It looks like something that starts w/ 2k and ME.

Have a good one,

Bill

--
Wilhelm K. Schwab, Ph.D.
[hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: SHGetFolderLocation

Steve Alan Waring
In reply to this post by Jerome Chan
Hi Jerome,

Jerome Chan wrote:
> I can't seem to be able to find this function in the shell library.
> I'm trying to locate the application data "CSIDL_APPDATA" folder
> location; I need to store some application specific data here.

From:
   http://msdn.microsoft.com/library/en-us/dnw2kcli/html/W2Kcli_chapter4.asp

"To help ensure your application can run on Windows 9x, Windows NT 4 as well
as Windows 2000, always link to the SHGetFolderPath implementation in
SHFOLDER.DLL. Windows 2000 natively implements SHGetFolderPath in
SHELL32.DLL, but other versions of Windows do not include SHGetFolderPath in
SHELL32.DLL."

The Shell prackages at:
http://www.dolphinharbor.org/dh/projects/shell/index.html include this, but
you can easily add a new ExternalLibrary subclass with the fileName
"SHFolder" and the following methods:


!ShellFolderLibrary methodsFor!
SHGetFolderPath: hwndOwner nFolder: nFolder hToken: hToken dwFlags: dwFlags
pszPath: pszPath
"Takes the CSIDL of a folder and returns the pathname.
HRESULT SHGetFolderPath(
HWND hwndOwner,
int nFolder,
HANDLE hToken,
DWORD dwFlags,
LPTSTR pszPath
);"
"Remarks from MSDN:
This function is a superset of SHGetSpecialFolderPath, included with earlier
versions of the Shell. It is implemented in a redistributable DLL,
SHFolder.dll, that also simulates many of the new Shell folders on older
platforms such as Windows 95, Windows 98, and Windows NT 4.0. This DLL
always calls the current platform's version of this function. If that fails,
it will try to simulate the appropriate behavior. Only some CSIDLs are
supported, including:
CSIDL_ADMINTOOLS = 16r30
CSIDL_APPDATA = 16r1A
CSIDL_COMMON_ADMINTOOLS = 16r2F
CSIDL_COMMON_APPDATA = 16r23
CSIDL_COMMON_DOCUMENTS = 16r2E
CSIDL_COOKIES = 16r21
CSIDL_FLAG_CREATE = 16r8000
CSIDL_HISTORY = 16r22
CSIDL_INTERNET_CACHE = 16r20
CSIDL_MYPICTURES = 16r27
CSIDL_PERSONAL = 16r5
CSIDL_PROGRAM_FILES = 16r26
CSIDL_PROGRAM_FILES_COMMON = 16r2B
CSIDL_SYSTEM = 16r25
CSIDL_WINDOWS = 16r24
"
<stdcall: hresult SHGetFolderPathA handle sdword handle dword lpstr>
^self invalidCall
! !
!ShellFolderLibrary categoriesFor:
#SHGetFolderPath:nFolder:hToken:dwFlags:pszPath:!public!win32
functions-shell library! !
!ShellFolderLibrary methodsFor!
pathFromCSIDL: anInteger
"Answer the full file path of the folder specified by anInteger, a Windows
CSIDL , or nil if it doesn't exist."
| buffer result |
buffer := String new: File maxPath.
result := self
SHGetFolderPath: nil
nFolder: anInteger
hToken: nil
dwFlags: 0
pszPath: buffer.
^result = 0 ifTrue: [buffer trimNulls] ifFalse: [nil]! !
!ShellFolderLibrary categoriesFor: #pathFromCSIDL:!public!win32
functions-shell library! !



Steve
--
Steve Waring
Email: [hidden email]
Journal: http://www.stevewaring.net/blog/home/index.html


Reply | Threaded
Open this post in threaded view
|

Re: SHGetFolderLocation

Jerome Chan
Thanks!