LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1751 Location: Space and Time
|
Posted: Thu Jan 28, 2010 10:44 pm Post subject: VDS 6 Portable starter |
|
|
I use Liberkey on my USB drive for my program launcher (until I get mine finished anyway). You can copy the VDS install dir and run it on a USB drive and it works fine. Liberkey can temporarily assign extensions to open apps that are on the USB drive. VDS for some reason if it not installed will not open a file passed to the exe. I wrote this startup program so it connects to VDS via DDE and opens the passed file in VDS.
Code: |
#Define Function,TaskExists
#define command,ReduceMemory
#Check to see if VDSStart is already running
if @winexists(#VDSStart)
#if so, crete a temp dialog and connect via DDE
#to open the new file.
DIALOG CREATE,VDSStart2,-1,0,240,160,class VDSStart2
DDE LINK, VDS, System
DDE EXECUTE,[FILEOPEN(%1)]
DDE TERMINATE
stop
end
#Create a temp dialog for the DDE
DIALOG CREATE,VDSStart,-1,0,240,160,class VDSStart
#Copy the VDSPrefs.dat file so VDS can ue it if one exists.
If @file(@path(%0)VDSPREFS.DAT)
directory create,@windir(AppData)\Visual DialogScript
file copy,@path(%0)VDSPREFS.DAT,@windir(AppData)\Visual DialogScript\VDSPREFS.DAT
end
#Run VDS
Run @path(%0)vds.exe
#Wait a few to make sure it starts
wait 3
#Reduce the memory
ReduceMemory
#Create the DDE link and open the file
DDE LINK, VDS, System
DDE EXECUTE,[FILEOPEN(%1)]
DDE TERMINATE
#While VDS.exe is running
While @TaskExists(vds.exe)
wait 1
wend
#When VDS.exe is not running copy the VDSPrefs.dat back
file copy,@windir(AppData)\Visual DialogScript\VDSPREFS.DAT,@path(%0)VDSPREFS.DAT
stop
:TaskExists
if @not(%1)
Error 2
end
%l = @new(list)
list tasklist,%l
%m = @match(%l,%1)
if %m
%e = 1
end
list close,%l
exit %e
:ReduceMemory
# This subroutine will reduce the memory footprint
# of the current exe or of the specified process ID
loadlib psapi.dll
loadlib kernel32.dll
If %1
# Get a handle to the specified process
%h = @lib(kernel32,OpenProcess,INT:,INT:$1F0FFF,INT:0,INT:%1)
If @unequal(%h,0)
# reduce its current memory
%t = @lib(psapi,EmptyWorkingSet,INT:,INT:%h)
# close the handle
%h = @lib(kernel32,CloseHandle,BOOL:,INT:%h)
End
Else
# reduce the memory usage of the current process
%t = @lib(psapi,EmptyWorkingSet,INT:,INT:-1)
End
freelib psapi
freelib kernel32
exit
|
_________________ Chris
Http://theblindhouse.com |
|