You could share memory using a DLL - using visual studio you can create global variables that are shared between all instances.
The shared memory technique is a better way to do this - for a start you can share memory between more than 2 apps, or have several areas without having to rewrite your DLL.
I wrote this code some time ago as an example - run two or more copies of it at once.
sync off
sync rate 30
MemmapHandle as dword
MemmapAddress as dword
InitKernel32()
MemmapHandle = OpenSharedMemory( 256, "BOB")
if MemmapHandle <> 0
MemmapAddress = MapSharedMemory( MemmapHandle, 0, 256 )
if MemmapAddress <> 0
print "Address : "; hex$( MemmapAddress )
wait key
print "This was already there : "; PeekDword( MemmapAddress )
print "Increasing it by 1"
PokeDword( MemmapAddress, PeekDword(MemmapAddress)+1 )
print "This is now what is there : "; PeekDword( MemmapAddress )
print
print "Press any key to close the mapping and exit"
wait key
UnmapSharedMemory( MemmapAddress )
else
print "Failed to map the memory"
wait key
endif
CloseSharedMemory( MemmapHandle )
else
print "Memory mapping failed"
wait key
endif
ShutdownKernel32()
end
function PeekDword( Addr as dword )
Value as dword
Value = *Addr
endfunction Value
function PokeDword( Addr as dword, Value as dword )
*Addr = Value
endfunction
function InitKernel32()
load dll "kernel32.dll", 1
endfunction
function ShutdownKernel32()
delete dll 1
endfunction
function OpenSharedMemory(Size as dword, Name as string)
Handle as dword
Handle = call dll(1, "CreateFileMappingA", -1, 0, 0x04, 0, Size, Name)
if Handle = 0 then Handle = call dll(1, "OpenFileMappingA", 0x1F, 0, Name)
endfunction Handle
function CloseSharedMemory( Handle as dword )
Result as dword
Result = call dll(1, "CloseHandle", Handle )
endfunction Result
function MapSharedMemory( Handle as dword, Offset as dword, Size as dword )
Addr as dword
Addr = call dll(1, "MapViewOfFile", Handle, 0x1F, 0, Offset, Size)
endfunction Addr
function UnmapSharedMemory( Addr as dword )
Result as dword
Result = call dll(1, "UnmapViewOfFile", Addr)
endfunction Result
*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins, source and the Interface library for Visual C++ 6, .NET and now for Dev-C++
http://www.matrix1.demon.co.uk