System.MissingMethodException - Public Declare Sub GlobalMemoryStatus Lib "kernel32" (ByRef lpBuffe

A

A_PK

Public Declare Sub GlobalMemoryStatus Lib "kernel32" (ByRef lpBuffer As
MEMORYSTATUS)...

Is this valid for Vb.net for Compact Framework Platform....

I am having this error message System.MissingMethodException.......

the following are my coding
----------------------------------------------------------------------------------------------------------------------

Public Structure MEMORYSTATUS
Dim dwLength As Integer ' Size of MEMORYSTATUS
End Structure

Public Declare Sub GlobalMemoryStatus Lib "kernel32" (ByRef lpBuffer As
MEMORYSTATUS)



Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim MS As MEMORYSTATUS

GlobalMemoryStatus(MS)
MsgBox("Total memory: " & CStr(MS.dwLength))

End Sub
 
P

Pete Vickers [MVP]

Hi,
try
Declare Function GlobalMemoryStatus Lib "coredll.dll" (ByVal StrBuffer As
String) As Long

Pete
 
G

Guest

kernel32.dll is a desktop DLL. It doesn't exist in CE. Did you do a Google
search on this? I'm certasin there are several places in the archives and
on the web where this is defined.

-Chris
 
P

Paul G. Tobey [eMVP]

I think that you want "As Int", not "As Long", right? Long = 64-bit?

Paul T.
 
A

A_PK

YES>...i got it...
but the value i got is based on Bit or what ?

how can I covert that number to MB or Kbyte

thank you
 
G

Guest

Read the Help. It explicitly says the numbers are bytes. Then it becomes
4th grade math. There are 1024 bytes in 1kb. There are 1024kb in 1 MB
(actually in 1 MiB if you want to be totally correct). Divide the number by
1024*1024 and you get MB.

-Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top