Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.clipper.visual-objects > #13910

Re: SHGetKnownFolderPath

From Jamal <vodotnet@gmail.com>
Newsgroups comp.lang.clipper.visual-objects
Subject Re: SHGetKnownFolderPath
Date 2023-08-25 23:52 -0400
Organization A noiseless patient Spider
Message-ID <ucbsua$e8ln$1@dont-email.me> (permalink)
References <c211f145-f262-4708-b481-694cef4a4fb1n@googlegroups.com>

Show all headers | View raw


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	

Back to comp.lang.clipper.visual-objects | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

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

csiph-web