Alex Poon

I am writting a program for a CE5 MIPS device. The device has very limited memory but I have to run two different program at the same time. Is it possible to enlarge the program memory(reduce the storage memory) when I start my program beside manually asking user to adjust it



Re: .NET Compact Framework How can I adjust the Program memory and storage memory at runtime?

Ilya Tumanov

You could use SetSystemMemoryDivision() to do that.






Re: .NET Compact Framework How can I adjust the Program memory and storage memory at runtime?

Rik78

You can use this with SetSystemMemoryDivision() along with GetDiskFreeSpaceExW, so you know how much program memory you can assign to your program.

Here is what works on my WinCe 5.0 device.

These are the declarations:

Declare Function SetSystemMemoryDivision Lib "coredll.dll" (ByVal pages As Integer) As Integer

Declare Function GetDiskFreeSpaceExW Lib "coredll.dll" (ByVal lpRootPathName As String, _

ByRef lpFreeBytesAvailableToCaller As Long, ByRef lpTotalNumberOfBytes _

As Long, ByRef lpTotalNumberOfFreeBytes As Long) As Boolean

How to use:

' 1 Memory Page is 4K.

' To set total storage memory to 4352 KB, it is 4352 / 4 = 1088 memory pages

' 0 - memory division was changes successfully

' 1 - need reboot to accept memory division changes

' 2 - cannot change memory division because the system should be rebooted after the previous call before

' 3 - changes failed. You can call GetLastError to get more detailed information

Dim i As Integer = SetSystemMemoryDivision(1088)

Dim lResult As Boolean

Dim liAvailable As Long

Dim liTotal As Long

Dim liFree As Long

'Determine the Available Space, Total Size and Free Space of a drive

lResult = GetDiskFreeSpaceExW("\WINDOWS\", liAvailable, liTotal, liFree)






Re: .NET Compact Framework How can I adjust the Program memory and storage memory at runtime?

Alex Poon

Thx!!




Re: .NET Compact Framework How can I adjust the Program memory and storage memory at runtime?

Fivi

thx Smile