Cambiar icono carpeta desde codigo

Cambiar icono carpeta desde codigo

Postby leandro » Wed Nov 03, 2021 2:49 pm

Buenos días para todos

Estuve buscando en el foro pero no encontré respuesta, es que deseo cambiar el icono de la carpeta de contiene nuestra aplicación, lo hice de manera manual, pero quiero saber si es posible hacerlo desde código.

Image
Saludos
LEANDRO AREVALO
Bogotá (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Embarcadero C++ 7.60 for Win32 ] [ FiveWin 23.07 ] [ xHarbour 1.3.0 Intl. (SimpLex) (Build 20230914) ]
User avatar
leandro
 
Posts: 1688
Joined: Wed Oct 26, 2005 2:49 pm
Location: Colombia

Re: Cambiar icono carpeta desde codigo

Postby Antonio Linares » Wed Nov 03, 2021 3:37 pm

"Change Icon of EXE file through code extracting it from other EXE file | Go4Expert" https://www.go4expert.com/articles/chan ... ting-t643/

La clave es usar UpdateResource()
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42203
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Cambiar icono carpeta desde codigo

Postby nageswaragunupudi » Mon Nov 08, 2021 6:03 pm

Code: Select all  Expand view  RUN
function SetFolderIcon( cFolder, cFileIco, cInfoTip )

   local lSet  := .f.
   local oIni, cIni, cSec := ".ShellClassInfo"

   cFolder  := RemRight( cFolder, "\" )
   DEFAULT cInfoTip := "
"

   if File( cFileIco ) .and. Lower( cFileExt( cFileIco ) ) == "
ico" .and. ;
      !File( cFolder )

      if !lIsDir( cFolder )
         lMkFullPath( cFolder )
      endif

      if lIsDir( cFolder )
         SetFAttr( cFolder, 4 )
         cFileIco := cRelativePath( cFileIco, cFolder )
         cIni     := cFolder + "
\desktop.ini"
         INI oIni FILE cIni
         SET SECTION cSec ENTRY "
ConfirmFileOp" TO 0        OF oIni
         SET SECTION cSec ENTRY "
NoSharing"     TO 1        OF oIni
         SET SECTION cSec ENTRY "
IconFile"      TO cFileIco OF oIni
         SET SECTION cSec ENTRY "
IconIndex"     TO 0        OF oIni
         SET SECTION cSec ENTRY "
InfoTip"       TO cInfoTip OF oIni
         SetFAttr( cIni, 2 )
         lSet  := .t.
      endif
   endif

return lSet


This function is included in the next version of FWH

Test:
Code: Select all  Expand view  RUN
? SetFolderIcon( "c:\fwh\icofolder", "c:\fwh\icons\fivetech.ico", "FWH SetFolderIcon() function" )


Image
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Cambiar icono carpeta desde codigo

Postby leandro » Tue Nov 09, 2021 9:17 pm

Excelente Mr.Nages :D

Era lo que estaba buscando. Muchas gracias.
Saludos
LEANDRO AREVALO
Bogotá (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Embarcadero C++ 7.60 for Win32 ] [ FiveWin 23.07 ] [ xHarbour 1.3.0 Intl. (SimpLex) (Build 20230914) ]
User avatar
leandro
 
Posts: 1688
Joined: Wed Oct 26, 2005 2:49 pm
Location: Colombia

Re: Cambiar icono carpeta desde codigo

Postby acuellar » Mon Nov 15, 2021 8:23 pm

Buenas estimados

Y la función cRelativePath donde la encuentro?
Saludos,

Adhemar C.
User avatar
acuellar
 
Posts: 1645
Joined: Tue Oct 28, 2008 6:26 pm
Location: Santa Cruz-Bolivia

Re: Cambiar icono carpeta desde codigo

Postby karinha » Mon Nov 15, 2021 10:42 pm

acuellar wrote:Buenas estimados

Y la función cRelativePath donde la encuentro?


Borland shell32.lib


regards, saludos
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7872
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Cambiar icono carpeta desde codigo

Postby acuellar » Tue Nov 16, 2021 8:35 pm

Gracias estimado Joao

Pero no está en en la Lib Shell32 :(
Saludos,

Adhemar C.
User avatar
acuellar
 
Posts: 1645
Joined: Tue Oct 28, 2008 6:26 pm
Location: Santa Cruz-Bolivia

Re: Cambiar icono carpeta desde codigo

Postby karinha » Tue Nov 16, 2021 10:16 pm

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7872
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Cambiar icono carpeta desde codigo

Postby karinha » Tue Nov 16, 2021 10:37 pm

Code: Select all  Expand view  RUN

// \samples\CRELATIV.PRG

#Include "FiveWin.ch"

FUNCTION Main()

   ? SetFolderIcon( "c:\FWH1905\icofolder", "c:\FWH1905\icons\fivetech.ico", ;
      "FWH SetFolderIcon() function" )

RETURN NIL

FUNCTION SetFolderIcon( cFolder, cFileIco, cInfoTip )

   local lSet  := .f.
   local oIni, cIni, cSec := ".ShellClassInfo"

   cFolder  := RemRight( cFolder, "\" )

   DEFAULT cInfoTip := "
"

   IF FILE( cFileIco ) .AND. Lower( cFileExt( cFileIco ) ) == "
ico" .AND. ;
      .NOT. FILE( cFolder )

      IF .NOT. lIsDir( cFolder )

         lMkFullPath( cFolder )

      ENDIF

      IF lIsDir( cFolder )

         SetFAttr( cFolder, 4 )

         cFileIco := cRelativePath( cFileIco, cFolder )
         cIni     := cFolder + "
\desktop.ini"

         INI oIni FILE cIni
         SET SECTION cSec ENTRY "
ConfirmFileOp" TO 0        OF oIni
         SET SECTION cSec ENTRY "
NoSharing"     TO 1        OF oIni
         SET SECTION cSec ENTRY "
IconFile"      TO cFileIco OF oIni
         SET SECTION cSec ENTRY "
IconIndex"     TO 0        OF oIni
         SET SECTION cSec ENTRY "
InfoTip"       TO cInfoTip OF oIni

         SetFAttr( cIni, 2 )

         lSet  := .t.

      ENDIF

   ENDIF

   ? cIni // ??

RETURN( lSet )

// FIN / END


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7872
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Cambiar icono carpeta desde codigo

Postby acuellar » Tue Nov 16, 2021 10:39 pm

Gracias Estimado

Tengo FWH 18.04 :(
Saludos,

Adhemar C.
User avatar
acuellar
 
Posts: 1645
Joined: Tue Oct 28, 2008 6:26 pm
Location: Santa Cruz-Bolivia

Re: Cambiar icono carpeta desde codigo

Postby nageswaragunupudi » Wed Nov 17, 2021 2:24 pm

acuellar wrote:Buenas estimados

Y la función cRelativePath donde la encuentro?

You need to upgrade FWH
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Cambiar icono carpeta desde codigo

Postby nageswaragunupudi » Wed Nov 17, 2021 2:24 pm

acuellar wrote:Buenas estimados

Y la función cRelativePath donde la encuentro?

You need to upgrade FWH
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Cambiar icono carpeta desde codigo

Postby acuellar » Wed Nov 17, 2021 7:01 pm

Thanks Mr. Rao
Saludos,

Adhemar C.
User avatar
acuellar
 
Posts: 1645
Joined: Tue Oct 28, 2008 6:26 pm
Location: Santa Cruz-Bolivia


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 113 guests