Page 1 of 2

Special folders

Posted: Tue Nov 06, 2012 8:42 pm
by esgici
Hi

A little work to obtain paths of special folders of windows.

Thanks to inspiration by friend Dave :)
Screen shoot<br />  of Special Folders test prg
Screen shoot
of Special Folders test prg
SpFldTst.jpg (115.6 KiB) Viewed 7380 times
SpFldTst.zip
Source files (.hbp, .prg) of Special Folders test prg
(2.95 KiB) Downloaded 446 times
Happy HMG'ing :D

Re: Special folders

Posted: Tue Nov 06, 2012 10:43 pm
by srvet_claudio
Hi Esgici.
Very good !!!
Regards,
Claudio.

Re: Special folders

Posted: Tue Nov 06, 2012 11:57 pm
by Pablo César
Very nice amigo Esgici ! Thank for your sharing !

Re: Special folders

Posted: Wed Nov 07, 2012 1:38 am
by Rathinagiri
Very useful Esgici.

I am very particular about the fonts folder for HMG_HPDF. Thanks.

Re: Special folders

Posted: Wed Nov 07, 2012 4:05 am
by bpd2000
Nice & thank you for sharing

Re: Special folders

Posted: Wed Nov 07, 2012 12:06 pm
by esgici
Hi

Found a more sophisticated and useful sample :

http://www.hexcentral.com/articles/foxpro-folders.htm

This is a foxpro function and seems could be adapt to Harbour.

But require a bit low-level expertness; because include something like shell32, ole32 :(

I hope that my amigo Pablo Cesar could achieve this task.

TIA

Re: Special folders

Posted: Wed Nov 07, 2012 1:49 pm
by srvet_claudio
Hi Esgici.
I hope you find it useful.

GET_FOLDER_LINK (id_SHGFP_TYPE, id_CSIDL) ---> Return cFolder

Best regards,
Claudio.

Code: Select all

// (c) Dr. Claudio Soto, 6 Mayo 2010

// see CSIDL_XXX description in ---> http://msdn.microsoft.com/en-us/library/windows/desktop/bb762494(v=vs.85).aspx
// define CSIDL_XXX in file     ---> shlobj.h

//**********
//  id_CSIDL
//**********
#define CSIDL_DESKTOP	0
#define CSIDL_INTERNET  1
#define CSIDL_PROGRAMS	2
#define CSIDL_CONTROLS	3
#define CSIDL_PRINTERS	4
#define CSIDL_PERSONAL	5
#define CSIDL_FAVORITES	6
#define CSIDL_STARTUP	7
#define CSIDL_RECENT	8
#define CSIDL_SENDTO	9
#define CSIDL_BITBUCKET	10
#define CSIDL_STARTMENU	11
#define CSIDL_MYMUSIC	13
#define CSIDL_MYVIDEO	14
#define CSIDL_DESKTOPDIRECTORY	16
#define CSIDL_DRIVES	17
#define CSIDL_NETWORK	18
#define CSIDL_NETHOOD	19
#define CSIDL_FONTS	20
#define CSIDL_TEMPLATES	21
#define CSIDL_COMMON_STARTMENU	22
#define CSIDL_COMMON_PROGRAMS	23
#define CSIDL_COMMON_STARTUP	24
#define CSIDL_COMMON_DESKTOPDIRECTORY	25
#define CSIDL_APPDATA   26
#define CSIDL_PRINTHOOD 27
#define CSIDL_LOCAL_APPDATA 28
#define CSIDL_ALTSTARTUP    29
#define CSIDL_COMMON_ALTSTARTUP	30
#define CSIDL_COMMON_FAVORITES	31
#define CSIDL_INTERNET_CACHE   32
#define CSIDL_COOKIES	33
#define CSIDL_HISTORY	34
#define CSIDL_COMMON_APPDATA	35
#define CSIDL_WINDOWS	36
#define CSIDL_SYSTEM	37
#define CSIDL_PROGRAM_FILES	38
#define CSIDL_MYPICTURES	39
#define CSIDL_PROFILE	40
#define CSIDL_SYSTEMX86	41
#define CSIDL_PROGRAM_FILESX86	42
#define CSIDL_PROGRAM_FILES_COMMON	43
#define CSIDL_PROGRAM_FILES_COMMONX86	44
#define CSIDL_COMMON_TEMPLATES	45
#define CSIDL_COMMON_DOCUMENTS	46
#define CSIDL_COMMON_ADMINTOOLS	47
#define CSIDL_ADMINTOOLS	48
#define CSIDL_CONNECTIONS	49
#define CSIDL_COMMON_MUSIC	53
#define CSIDL_COMMON_PICTURES	54
#define CSIDL_COMMON_VIDEO	55
#define CSIDL_RESOURCES	56
#define CSIDL_RESOURCES_LOCALIZED	57
#define CSIDL_COMMON_OEM_LINKS	58
#define CSIDL_CDBURN_AREA	59
#define CSIDL_COMPUTERSNEARME	61
#define CSIDL_FLAG_DONT_VERIFY	16384 // 0x4000
#define CSIDL_FLAG_CREATE	32768 // 0x8000
#define CSIDL_FLAG_MASK	65280 // 0xFF00


//***************
//  id_SHGFP_TYPE
//***************
#define SHGFP_TYPE_CURRENT  0   // Retrieve the folder's current path.
#define SHGFP_TYPE_DEFAULT  1   // Retrieve the folder's default path.
// If the folder has not been redirected, then SHGFP_TYPE_DEFAULT and SHGFP_TYPE_CURRENT retrieve the same path.

#include "hmg.ch"

Function Main
   MsgInfo (GET_FOLDER_LINK (SHGFP_TYPE_CURRENT, CSIDL_FAVORITES))
Return Nil



#pragma begindump

#include <windows.h>
#include <shlobj.h>

#include "hbapi.h"

//************************************************************************************************************
// GET_FOLDER_LINK (id_SHGFP_TYPE, id_CSIDL) ---> Return cFolder
//************************************************************************************************************
HB_FUNC (GET_FOLDER_LINK)
{   
    TCHAR pszPath [MAX_PATH];
    DWORD id_SHGFP_TYPE = (DWORD) hb_parnl (1);
    INT   id_CSIDL      = (INT)   hb_parnl (2);
    
    if(SUCCEEDED (SHGetFolderPath (NULL, id_CSIDL, NULL, id_SHGFP_TYPE, pszPath)))
        hb_retc (pszPath);
    else
        hb_retc ("ERROR: The folder does not exist");            
}

#pragma enddump

Re: Special folders

Posted: Wed Nov 07, 2012 2:07 pm
by srvet_claudio
Hi Esgici.
See application of the GET_FOLDER_LINK function in viewtopic.php?p=10535#p10535
Search recent open projects of the HMG.
Regards,
Claudio.

Re: Special folders

Posted: Wed Nov 07, 2012 2:33 pm
by esgici
Hola Dr.

Thanks :)

You are a real treasure :arrow:

Are you sure that you are programming only as hobby ;)

Saludos and gracias cordiales :arrow:

Re: Special folders

Posted: Wed Nov 07, 2012 3:29 pm
by srvet_claudio
Hi Brother Esgici.
esgici wrote:You are a real treasure
Thank you very much, you are very kind.
esgici wrote:Are you sure that you are programming only as hobby
Yes, I'm only programming by hobby and fun (*)

(*) I did my first virus (memory-resident Trojan in C) when he was 16 years old, all I did was clear the screen every 5 seconds and display the message: "This computer is with diarrhea", was very fun to see the cries of my friends... "teacher, teacher, teacher, the computer is with diarrhea?" and the professor responded: "computer with diarrhea? you all are crazy !!!"

Best Regards,
Claudio.