Page 1 of 1

SHGETFILEINFO - Problem

Posted: Wed Dec 08, 2004 11:02 pm
by Le Soldat Inconnu
Hello,

I make a lauchbar but my program use 4.6mo in memory

I search a solution to reduce the memory used.

And I find the function SHGETFILEINFO use 2.5 mo 8O
See this code, I write the meory used after all functions

Code: Select all

Procedure.l ExtractLargeIconFile2(IconPath.s) ; Extraire l'icône 32*32 d'un fichier 
  ; Cette procedure permet d'extraire l'ID de l'icône 32*32 associé au type de fichier ou au dossier dont l'adresse est IconPath 
  hImageList = SHGetFileInfo_(IconPath, 0, @InfosFile.SHFILEINFO, SizeOf(SHFILEINFO), #SHGFI_SYSICONINDEX | #SHGFI_ICON | #SHGFI_LARGEICON) 
; hImageList est le handle de l'ImageList 
  
  ProcedureReturn InfosFile\hIcon 
EndProcedure 


OpenWindow(0, 0, 0, 100, 100, #PB_Window_ScreenCentered | #PB_Window_SystemMenu, "Test") ; 1364 

CreateGadgetList(WindowID()) ; 1376 

Icone = ExtractLargeIconFile2("c:\") ; 3944 (+2568 Arg) 
ImageGadget(0, 0, 0, 32, 32, Icone) ; 3984 

Repeat 
  Event = WaitWindowEvent() 

Until Event = #PB_Event_CloseWindow
So, I search a solution to get icon from file which use less memory.


I think the 2.5 mo was the ImageList but when I use ImageList_Destroy, there are no result. :(

Thanks for your help

Hello,

Posted: Thu Dec 09, 2004 8:38 pm
by DominiqueB
I've got a litle part of code that i use in PowerBasic to reduce the size in memory of a prog:

Code: Select all

;Ce petit bout de procédure permet de diminuer beaucoup la taille de la mémoire utilisée.
hProcess.l = OpenProcess_(#PROCESS_ALL_ACCESS, 0, GetCurrentProcessId_())
SetProcessWorkingSetSize_(hProcess, -1, -1)
CloseHandle_(hProcess)
Put this just after the ImageGadget() func.
I hope it will help you !

Now it only occupy 1256 instead of 4352 !

Do you know that if you minimize the prog, and then set it to normal size
make it occupy even less memory ?

Dominique

Posted: Thu Dec 09, 2004 11:44 pm
by Le Soldat Inconnu
Thanks, it's marvellous :D

Posted: Fri Dec 10, 2004 4:08 am
by Flype
hi,

#PROCESS_ALL_ACCESS isn't defined at home. which the value ?

Posted: Fri Dec 10, 2004 4:13 am
by Flype
i found it ( #PROCESS_ALL_ACCESS=$1F0FFF )

great

the memory consumption of my current project down from 12mo to 1.5mo !!!

is there any sort of trouble using this trick ?

Posted: Fri Dec 10, 2004 10:40 am
by Le Soldat Inconnu

Code: Select all

#PROCESS_ALL_ACCESS = $1F0FFF
No problem, this function force windows to clear the memory of the software and force window to send not used memory in virtual memory



Flype > Dis tu veux pas poser ta question sur le forum FR, ce serait plus simple :lol:
Marrant quand même, un poste de français sur le forum anglais et il y a que des français à rèpondre :roll:


Traduction
Flype > Could you ask your question on the french forum, more simple :lol:
A question by french coder and there are only answer by french coder :roll:

:mrgreen:

Posted: Fri Dec 10, 2004 12:51 pm
by Flype
yes soldat inconnu, french solidarity :wink: