SHGETFILEINFO - Problem

Windows specific forum
User avatar
Le Soldat Inconnu
Enthusiast
Enthusiast
Posts: 306
Joined: Wed Jul 09, 2003 11:33 am
Location: France

SHGETFILEINFO - Problem

Post 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
LSI
DominiqueB
Enthusiast
Enthusiast
Posts: 103
Joined: Fri Apr 25, 2003 4:00 pm
Location: France

Hello,

Post 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
Dominique

Windows 10 64bits. Pure basic 32bits
User avatar
Le Soldat Inconnu
Enthusiast
Enthusiast
Posts: 306
Joined: Wed Jul 09, 2003 11:33 am
Location: France

Post by Le Soldat Inconnu »

Thanks, it's marvellous :D
LSI
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

hi,

#PROCESS_ALL_ACCESS isn't defined at home. which the value ?
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post 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 ?
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
User avatar
Le Soldat Inconnu
Enthusiast
Enthusiast
Posts: 306
Joined: Wed Jul 09, 2003 11:33 am
Location: France

Post 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:
Last edited by Le Soldat Inconnu on Fri Dec 10, 2004 3:31 pm, edited 1 time in total.
LSI
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

yes soldat inconnu, french solidarity :wink:
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
Post Reply