Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.clipper.visual-objects > #13907 > unrolled thread
| Started by | Stefan Ungemach <stefan.ungemach@bingo-ev.de> |
|---|---|
| First post | 2023-08-24 08:13 -0700 |
| Last post | 2023-08-31 03:52 -0700 |
| Articles | 4 — 2 participants |
Back to article view | Back to comp.lang.clipper.visual-objects
SHGetKnownFolderPath Stefan Ungemach <stefan.ungemach@bingo-ev.de> - 2023-08-24 08:13 -0700
Re: SHGetKnownFolderPath Stefan Ungemach <stefan.ungemach@bingo-ev.de> - 2023-08-24 08:50 -0700
Re: SHGetKnownFolderPath Jamal <vodotnet@gmail.com> - 2023-08-25 23:52 -0400
Re: SHGetKnownFolderPath Stefan Ungemach <stefan.ungemach@bingo-ev.de> - 2023-08-31 03:52 -0700
| From | Stefan Ungemach <stefan.ungemach@bingo-ev.de> |
|---|---|
| Date | 2023-08-24 08:13 -0700 |
| Subject | SHGetKnownFolderPath |
| Message-ID | <c211f145-f262-4708-b481-694cef4a4fb1n@googlegroups.com> |
Has anyone used the SHGetKnownFolderPath API function in VO yet? I've played around with it, but never get a result. Last attempt was:
DEFINE FOLDERID_SkyDrive := "{A52BBA46-E9E1-435f-B3D9-28DAA648C0F6}"
_dll function SHGetKnownFolderPath(pszGUID as psz,dwFlags as dword,hHandle as ptr,pOut ref psz) as logic pascal:Shell32.SHGetKnownFolderPath
function getOneDriveDir() as string pascal
local cRueck as string
local pszPath as psz
pszPath := memalloc( MAX_PATH )
if SHGetKnownFolderPath( string2psz(FOLDERID_SkyDrive), 0, NULL, @pszpath )
? "success"
cRueck := psz2string( pszPath )
endif
memfree( pszPath )
return cRueck
[toc] | [next] | [standalone]
| From | Stefan Ungemach <stefan.ungemach@bingo-ev.de> |
|---|---|
| Date | 2023-08-24 08:50 -0700 |
| Message-ID | <891c617d-9034-4b94-adec-2a63ea602b25n@googlegroups.com> |
| In reply to | #13907 |
Stefan Ungemach schrieb am Donnerstag, 24. August 2023 um 17:13:42 UTC+2:
> Has anyone used the SHGetKnownFolderPath API function in VO yet? I've played around with it, but never get a result. Last attempt was:
>
> DEFINE FOLDERID_SkyDrive := "{A52BBA46-E9E1-435f-B3D9-28DAA648C0F6}"
> _dll function SHGetKnownFolderPath(pszGUID as psz,dwFlags as dword,hHandle as ptr,pOut ref psz) as logic pascal:Shell32.SHGetKnownFolderPath
> function getOneDriveDir() as string pascal
> local cRueck as string
> local pszPath as psz
>
>
> pszPath := memalloc( MAX_PATH )
> if SHGetKnownFolderPath( string2psz(FOLDERID_SkyDrive), 0, NULL, @pszpath )
> ? "success"
> cRueck := psz2string( pszPath )
> endif
> memfree( pszPath )
> return cRueck
Update: This doesn't work either and even does not rech the "success" line:
_dll function SHGetKnownFolderPath(pszGUID ref _WINGUID,dwFlags as dword,hHandle as ptr,pOut ref psz) as logic pascal:Shell32.SHGetKnownFolderPath#514
function getOneDriveDir() as string pascal
local cRueck as string
local pszPath as psz
local struGUID is _WINGUID
if CreateGuidFromString(FOLDERID_SkyDrive, @struGUID)
pszPath := memalloc( MAX_PATH )
if SHGetKnownFolderPath( @struGUID, 0, NULL, @pszpath )
? "success"
cRueck := psz2string( pszPath )
? len(cRueck)
endif
memfree( pszPath )
endif
return cRueck
[toc] | [prev] | [next] | [standalone]
| From | Jamal <vodotnet@gmail.com> |
|---|---|
| Date | 2023-08-25 23:52 -0400 |
| Message-ID | <ucbsua$e8ln$1@dont-email.me> |
| In reply to | #13907 |
Stefan,
This was tricky to find the solution for as I never used before.
I was getting a success but only the letter C was returned. I found out
the pszPath returned as WCHAR type. VO has undocumented function to
return the correct result using W2String() which uses Win32
WideCharToMultiByte() and VO's Mem2String() to return the full path
correctly.
Here is the full working code. Let me know how it goes.
_dll function SHGetKnownFolderPath(pszGUID as _WINGUID, dwFlags as
DWORD, hHandle as ptr, pOut ref ptr) as int
pascal:Shell32.SHGetKnownFolderPath
function GetKnownFolderPath(cGuidString as string) as string pascal
local cFolderPath as string
local pszPath as psz
LOCAL pGuid as _WINGUID
pGuid := MemAlloc( _sizeof( _WINGUID ) )
CreateGuidFromString(cGuidString, pGuid)
// ? Guid2String( pGuid )
pszPath := MemAlloc( MAX_PATH )
if SHGetKnownFolderPath( pGuid, 0, null_ptr, @pszPath ) = S_OK
cFolderPath := W2String(pszPath)
endif
MemFree( pGuid )
return cFolderPath
FUNCTION Start()
local a := {} as array
local i as dword
a := {ComputerFolder,Favorites,
Documents,Pictures,Music,Videos,Downloads,Desktop,PublicDocuments,PublicPictures,PublicMusic,PublicVideos,PublicDownloads,UserProfile,Contacts,Links,PublicFolder,Programs}
for i := 1 to ALen(a)
? GetKnownFolderPath(a[i])
next
WAIT
RETURN nil
// defines
DEFINE ComputerFolder := "{0AC0837C-BBF8-452A-850D-79D08E667CA7}"
DEFINE Favorites := "{1777F761-68AD-4D8A-87BD-30B759FA33DD}"
DEFINE Documents := "{FDD39AD0-238F-46AF-ADB4-6C85480369C7}"
DEFINE Pictures := "{33E28130-4E1E-4676-835A-98395C3BC3BB}"
DEFINE Music := "{4BD8D571-6D19-48D3-BE97-422220080E43}"
DEFINE Videos := "{18989B1D-99B5-455B-841C-AB7C74E4DDFC}"
DEFINE Downloads := "{374DE290-123F-4565-9164-39C4925E467B}"
DEFINE Desktop := "{B4BFCC3A-DB2C-424C-B029-7FE99A87C641}"
DEFINE PublicDocuments := "{ED4824AF-DCE4-45A8-81E2-FC7965083634}"
DEFINE PublicPictures := "{B6EBFB86-6907-413C-9AF7-4FC2ABF07CC5}"
DEFINE PublicMusic := "{3214FAB5-9757-4298-BB61-92A9DEAA44FF}"
DEFINE PublicVideos := "{2400183A-6185-49FB-A2D8-4A392A602BA3}"
DEFINE PublicDownloads := "{3D644C9B-1FB8-4F30-9B45-F670235F79C0}"
DEFINE UserProfile := "{5E6C858F-0E22-4760-9AFE-EA3317B67173}"
DEFINE Contacts := "{56784854-C6CB-462B-8169-88E350ACB882}"
DEFINE Links := "{BFB9D5E0-C6A9-404C-B2B2-AE6DB6AF4968}"
DEFINE PublicFolder := "{DFDF76A2-C82A-4D63-906A-5644AC457385}"
DEFINE Programs := "{A77F5D77-2E2B-44C3-A6A2-ABA601054A51}"
Jamal
On 8/24/2023 11:13 AM, Stefan Ungemach wrote:
> Has anyone used the SHGetKnownFolderPath API function in VO yet? I've played around with it, but never get a result. Last attempt was:
>
> DEFINE FOLDERID_SkyDrive := "{A52BBA46-E9E1-435f-B3D9-28DAA648C0F6}"
> _dll function SHGetKnownFolderPath(pszGUID as psz,dwFlags as dword,hHandle as ptr,pOut ref psz) as logic pascal:Shell32.SHGetKnownFolderPath
> function getOneDriveDir() as string pascal
> local cRueck as string
> local pszPath as psz
>
>
> pszPath := memalloc( MAX_PATH )
> if SHGetKnownFolderPath( string2psz(FOLDERID_SkyDrive), 0, NULL, @pszpath )
> ? "success"
> cRueck := psz2string( pszPath )
> endif
> memfree( pszPath )
> return cRueck
[toc] | [prev] | [next] | [standalone]
| From | Stefan Ungemach <stefan.ungemach@bingo-ev.de> |
|---|---|
| Date | 2023-08-31 03:52 -0700 |
| Message-ID | <28000e1c-4d42-4761-a391-ef2e0eba3b97n@googlegroups.com> |
| In reply to | #13910 |
Jamal schrieb am Samstag, 26. August 2023 um 05:52:45 UTC+2: > Stefan, > > This was tricky to find the solution for as I never used before. > I was getting a success but only the letter C was returned. I found out > the pszPath returned as WCHAR type. VO has undocumented function to > return the correct result using W2String() which uses Win32 > WideCharToMultiByte() and VO's Mem2String() to return the full path > correctly. > > Here is the full working code. Let me know how it goes. Hi Jamal, thanks for pointing out W2String() to me. After a slight modification (ShGetKnownFolderPath returns false for some reason the following code now works for me: function GetKnownFolderPath(cGuidString as string) as string pascal local cFolderPath as string local pszPath as psz local struGUID is _WINGUID if CreateGuidFromString(cGuidString, @struGUID) pszPath := MemAlloc( MAX_PATH ) SHGetKnownFolderPath( @struGUID, 0, null_ptr, @pszPath ) cFolderPath := W2String(pszPath) memfree( pszPath ) endif return cFolderPath
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.clipper.visual-objects
csiph-web