- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all:
has anyone ever used SHGetSpecialFolderLocation to get the user's personal files directory on a windows based machine? Would hihgly appreciate an example on how to call this in a Fortran environment.
Thanks
has anyone ever used SHGetSpecialFolderLocation to get the user's personal files directory on a windows based machine? Would hihgly appreciate an example on how to call this in a Fortran environment.
Thanks
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You'd be better off using SHGetSpecialFolderPath; SH...Location returns a PIDL which is useful in things like managing shell namespace's tree view, but ShGetSpecialFolderPath should be simpler to use.
To my surprise, I don't find INTERFACE for ShGet... functions in SHELL32.f90 of 6.6B. I wrote my own module with interfaces (attached) (Please remove extra declarations from it if the compiler complains about redeclarations of symbols).
I discovered that on NT systems the function returns a UNICODE string, while on 9x systems it returns an ANSI string; so, a run-time test is required (the sample is for "application data" folder):
(It uses declaration of WideCharToMultiByte from attached file; you might need to adjust type declarations or insert LOCs if 6.6B complains -- the original code was written for 5.0D which didn't have any of INTERFACEs used and thus no possibility of conflict with DFWIN).
HTH
Jugoslav
P.S. D'oh, "attach files" feature doesn't work again. I'll try in the next message or paste the code as-is.
To my surprise, I don't find INTERFACE for ShGet... functions in SHELL32.f90 of 6.6B. I wrote my own module with interfaces (attached) (Please remove extra declarations from it if the compiler complains about redeclarations of symbols).
I discovered that on NT systems the function returns a UNICODE string, while on 9x systems it returns an ANSI string; so, a run-time test is required (the sample is for "application data" folder):
USE SHELL TYPE (T_OSVERSIONINFO):: VI CHARACTER(512),AUTOMATIC:: wLocalDir CHARACTER(256):: sLocalDir iSt = SHGetSpecialFolderPath(hFrame, wLocalDir, CSIDL_APPDATA, .TRUE.) VI%dwOSVersionInfoSize = SIZEOF(VI) iSt = GetVersionEx(VI) IF (VI%dwPlatformId .EQ. VER_PLATFORM_WIN32_NT) THEN iSt = WideCharToMultiByte(0, 0, wLocalDir, -1, & sLocalDir, LEN(sLocalDir), 0, 0) ELSE sLocalDir = wLocalDir END IF
(It uses declaration of WideCharToMultiByte from attached file; you might need to adjust type declarations or insert LOCs if 6.6B complains -- the original code was written for 5.0D which didn't have any of INTERFACEs used and thus no possibility of conflict with DFWIN).
HTH
Jugoslav
P.S. D'oh, "attach files" feature doesn't work again. I'll try in the next message or paste the code as-is.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
...here it is

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page