forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Reduice Memory Useage!!
Goto page Previous  1, 2
 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 5 Source Code
View previous topic :: View next topic  
Author Message
GregLand
Contributor
Contributor


Joined: 15 Jun 2004
Posts: 174
Location: FRANCE

PostPosted: Wed Nov 28, 2007 3:45 am    Post subject: Reply with quote

For the path of app i can do like that :

Code:
# Get the path of runing app
list create,1
list modules,1,app.exe
%%app_path = @item(1,0)
list close,1


But I don't know how to find the Handle using GetModuleHandleA or GetModuleHandleW

Code:
# Get the Handle
loadlib "kernel32.dll"
  %t = @lib("kernel32.dll","GetModuleHandleA",INT:,NIL:%%app_path)
freelib "kernel32.dll"


I don't know how to use this (if it's right)

Can you help me ?
Back to top
View user's profile Send private message Visit poster's website
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Wed Nov 28, 2007 8:59 pm    Post subject: Reply with quote

GregLand wrote:
For the path of app i can do like that :

Code:
# Get the path of runing app
list create,1
list modules,1,app.exe
%%app_path = @item(1,0)
list close,1


But I don't know how to find the Handle using GetModuleHandleA or GetModuleHandleW

Code:
# Get the Handle
loadlib "kernel32.dll"
  %t = @lib("kernel32.dll","GetModuleHandleA",INT:,NIL:%%app_path)
freelib "kernel32.dll"


I don't know how to use this (if it's right)

Can you help me ?



Code:
# Get the Handle
loadlib kernel32.dll
  %t = @lib(kernel32,GetModuleHandleA,INT:,NIL:)
freelib kernel32


If module name is NULL (ie.. NIL: ), GetModuleHandle returns a handle of the file used to create the calling process (e.g. ... the Exe that calls GetModuleHandle).

_________________
Home of

Give VDS a new purpose!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
GregLand
Contributor
Contributor


Joined: 15 Jun 2004
Posts: 174
Location: FRANCE

PostPosted: Wed Nov 28, 2007 9:12 pm    Post subject: Reply with quote

Ok thanks for your help !

Can you tell me how can I "join" this 3 script to reduce the memory of the runing process App.exe?

Code:
# Get the path of runing app
%%app = App.exe
list create,1
list modules,1,%%app
%%app_path = @item(1,0)
list close,1

Code:
# Get the Handle
loadlib kernel32.dll
  %t = @lib(kernel32,GetModuleHandleA,INT:,NIL:)
freelib kernel32

Code:
#Reduce memory
loadlib "psapi.dll"
%t = @lib("psapi.dll","EmptyWorkingSet",INT:,%%handle)
freelib "psapi.dll"


Last edited by GregLand on Thu Nov 29, 2007 12:42 am; edited 2 times in total
Back to top
View user's profile Send private message Visit poster's website
ShinobiSoft
Professional Member
Professional Member


Joined: 06 Nov 2002
Posts: 790
Location: Knoxville, Tn

PostPosted: Wed Nov 28, 2007 11:59 pm    Post subject: Reply with quote

dragonsphere wrote:

If module name is NULL (ie.. NIL: ), GetModuleHandle returns a handle of
the file used to create the calling process (e.g. ... the Exe that calls
GetModuleHandle).



Johnny,
I think GregLand is actually wanting the HINSTANCE of a non VDS app. At
least that's what I understood from his first post in this thread, that's why
me previous post was answered the way that it was, though I prolly
should've included sample code.

_________________
Bill Weckel
ShinobiSoft Software

"The way is known to all, but not all know it."
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Thu Nov 29, 2007 9:37 pm    Post subject: Reply with quote

GregLand wrote:
Ok thanks for your help !

Can you tell me how can I "join" this 3 script to reduce the memory of the runing process App.exe?

Code:
# Get the path of runing app
%%app = App.exe
list create,1
list modules,1,%%app
%%app_path = @item(1,0)
list close,1

Code:
# Get the Handle
loadlib kernel32.dll
  %t = @lib(kernel32,GetModuleHandleA,INT:,NIL:)
freelib kernel32

Code:
#Reduce memory
loadlib "psapi.dll"
%t = @lib("psapi.dll","EmptyWorkingSet",INT:,%%handle)
freelib "psapi.dll"


Code:

# Get the path of runing app
%%app = App.exe
list create,1
list modules,1,%%app
%%app_path = @item(1,0)
list close,1
# Get the Handle
loadlib kernel32.dll
  %%handle = @lib(kernel32,GetModuleHandleA,INT:,STR:%%app_path)
freelib kernel32
#Reduce memory
loadlib psapi.dll
%t = @lib(psapi,EmptyWorkingSet,INT:,INT:%%handle)
freelib psapi

_________________
Home of

Give VDS a new purpose!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Thu Nov 29, 2007 9:45 pm    Post subject: Reply with quote

Unless your program launches that program you will not be able to change it's working set size.
_________________
Home of

Give VDS a new purpose!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
GregLand
Contributor
Contributor


Joined: 15 Jun 2004
Posts: 174
Location: FRANCE

PostPosted: Fri Nov 30, 2007 3:06 am    Post subject: Reply with quote

dragonsphere wrote:
Unless your program launches that program you will not be able to change it's working set size.


Thanks for the script... but it doesn't look to work correctly... Confused
%%handle and %t return 0 (while the app %%app is running)

Code:

# run the app
run "D:\programmes\FireFox\firefox.exe" -Profile "D:\programmes\FireFox\profil"

# Get the path of runing app
%%app = firefox.exe
list create,1
list modules,1,%%app
%%app_path = @item(1,0)
list close,1
 
# Get the Handle
loadlib kernel32.dll
  %%handle = @lib(kernel32,GetModuleHandleA,INT:,STR:%%app_path)
freelib kernel32

#Reduce memory
loadlib psapi.dll
%t = @lib(psapi,EmptyWorkingSet,INT:,INT:%%handle)
freelib psapi
Back to top
View user's profile Send private message Visit poster's website
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Fri Nov 30, 2007 4:54 pm    Post subject: Reply with quote

Gregland,
It is not going to work. The Exe that you are trying to reduce the memory usage has to be mapped to the same memory as the Exe that is calling these functions. This is not really possible. These functions are meant to be used inside a Exe or DLL to control memory usage of the Exe calling the functions. It is usually not allowed for an external Exe to control the memory of another Exe in the Windows memory model. If you were allowed to do that then you could really do some damage. Personally I would contact the developer of the Exe that you are trying to do this with and ask them to optimize their memory usage.

_________________
Home of

Give VDS a new purpose!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
GregLand
Contributor
Contributor


Joined: 15 Jun 2004
Posts: 174
Location: FRANCE

PostPosted: Fri Nov 30, 2007 5:12 pm    Post subject: Reply with quote

Ok... Crying or Very sad thanks for your help...

Not very important Wink
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 5 Source Code All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum




Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group