实验环境: pc操作系统:windows xp
开发工具:Microsoft Visual C# .NET 2003
异常:未处理的“System.EntryPointNotFoundException”类型的异常出现在 ESServer.exe 中。其他信息: 无法在 DLL CoreDll.dll 中找到名为 GetSystemMemoryDivision 的入口点。
实验过程:我参照MSDN 上的方法获取设备内存 ,下面是网址
http://msdn2.microsoft.com/zh-cn/library/ms172518.aspx实现代码:
c#:
public struct MEMORYSTATUS
{
public uint dwLength;
public uint dwMemoryLoad;
public uint dwTotalPhys;
public uint dwAvailPhys;
public uint dwTotalPageFile;
public uint dwAvailPageFile;
public uint dwTotalVirtual;
public uint dwAvailVirtual;
}[DllImport("CoreDll.dll")]
public static extern void GlobalMemoryStatus
(
MEMORYSTATUS lpBuffer
);[DllImport("CoreDll.dll")]
public static extern int GetSystemMemoryDivision
(
ref uint lpdwStorePages,
ref uint lpdwRamPages,
ref uint lpdwPageSize
);public void ShowMemory()
{
uint storePages = 0;
uint ramPages = 0;
uint pageSize = 0;
int res = GetSystemMemoryDivision(ref storePages,
ref ramPages, ref pageSize); // Call the native GlobalMemoryStatus method
// with the defined structure.
MEMORYSTATUS memStatus = new MEMORYSTATUS();
GlobalMemoryStatus(memStatus); // Use a StringBuilder for the message box string.
StringBuilder MemoryInfo = new StringBuilder();
MemoryInfo.Append("Memory Load: "
+ memStatus.dwMemoryLoad.ToString() + "\n");
MemoryInfo.Append("Total Physical: "
+ memStatus.dwTotalPhys.ToString() + "\n");
MemoryInfo.Append("Avail Physical: "
+ memStatus.dwAvailPhys.ToString() + "\n");
MemoryInfo.Append("Total Page File: "
+ memStatus.dwTotalPageFile.ToString() + "\n");
MemoryInfo.Append("Avail Page File: "
+ memStatus.dwAvailPageFile.ToString() + "\n");
MemoryInfo.Append("Total Virtual: "
+ memStatus.dwTotalVirtual.ToString() + "\n");
MemoryInfo.Append("Avail Virtual: "
+ memStatus.dwAvailVirtual.ToString() + "\n"); // Show the available memory.
MessageBox.Show(MemoryInfo.ToString());
}
我的系统没有CoreDll.dll,我在网上找了一个
开发工具:Microsoft Visual C# .NET 2003
异常:未处理的“System.EntryPointNotFoundException”类型的异常出现在 ESServer.exe 中。其他信息: 无法在 DLL CoreDll.dll 中找到名为 GetSystemMemoryDivision 的入口点。
实验过程:我参照MSDN 上的方法获取设备内存 ,下面是网址
http://msdn2.microsoft.com/zh-cn/library/ms172518.aspx实现代码:
c#:
public struct MEMORYSTATUS
{
public uint dwLength;
public uint dwMemoryLoad;
public uint dwTotalPhys;
public uint dwAvailPhys;
public uint dwTotalPageFile;
public uint dwAvailPageFile;
public uint dwTotalVirtual;
public uint dwAvailVirtual;
}[DllImport("CoreDll.dll")]
public static extern void GlobalMemoryStatus
(
MEMORYSTATUS lpBuffer
);[DllImport("CoreDll.dll")]
public static extern int GetSystemMemoryDivision
(
ref uint lpdwStorePages,
ref uint lpdwRamPages,
ref uint lpdwPageSize
);public void ShowMemory()
{
uint storePages = 0;
uint ramPages = 0;
uint pageSize = 0;
int res = GetSystemMemoryDivision(ref storePages,
ref ramPages, ref pageSize); // Call the native GlobalMemoryStatus method
// with the defined structure.
MEMORYSTATUS memStatus = new MEMORYSTATUS();
GlobalMemoryStatus(memStatus); // Use a StringBuilder for the message box string.
StringBuilder MemoryInfo = new StringBuilder();
MemoryInfo.Append("Memory Load: "
+ memStatus.dwMemoryLoad.ToString() + "\n");
MemoryInfo.Append("Total Physical: "
+ memStatus.dwTotalPhys.ToString() + "\n");
MemoryInfo.Append("Avail Physical: "
+ memStatus.dwAvailPhys.ToString() + "\n");
MemoryInfo.Append("Total Page File: "
+ memStatus.dwTotalPageFile.ToString() + "\n");
MemoryInfo.Append("Avail Page File: "
+ memStatus.dwAvailPageFile.ToString() + "\n");
MemoryInfo.Append("Total Virtual: "
+ memStatus.dwTotalVirtual.ToString() + "\n");
MemoryInfo.Append("Avail Virtual: "
+ memStatus.dwAvailVirtual.ToString() + "\n"); // Show the available memory.
MessageBox.Show(MemoryInfo.ToString());
}
我的系统没有CoreDll.dll,我在网上找了一个
解决方案 »
- 数据类型转换
- Cache的问题高手请进~在线百分等待!
- 请问可在SerialPort的DataReceived触发事件程序中,写入SerialPort.Write发送资料吗?
- 初学者问题:++i和i++的值为什么是一样的?
- 100分求助~异步回调中改变主窗体值时发生错误
- 如何用C#实现键盘测试---高手请进
- 新开的Winfrom(C#)QQ群,欢迎加入讨论!
- 关于下拉框查询的简单问题
- c#端口扫描问题,谢谢……
- 1月17日微软在网上开通了Vs.net FrameWork SDK1.0的正式版,快down
- 关于数据适配器的问题请教各位!
- 窗体间传递struct型数据时,出现“****引用封送的字段,访问上面的成员可能导致异常”?????
参考资料:http://www.dll-files.com/dllindex/dll-files.shtml?coredll
谁有用:Visual C# .NET 2003 实现这个获取设备内存,可不可以共享一下!
要想试验这个项目,首先必须安装了VS 的SmartDevice 开发包,默认应该是安装的。然后新建一个Visual C# \ Smart Device \ Pocket PC 2003 \ Console Application 项目,把示例代码复制到生成的类中,并using相应的命名空间以及加入对System.Windows.Forms的reference. 源代码中有一处错误,GlobalMemoryStatus应该声明为
[DllImport("CoreDll.dll")]
public static extern void GlobalMemoryStatus
(
ref MEMORYSTATUS lpBuffer
);相应的使用它的语句应该改成:
GlobalMemoryStatus(ref memStatus);然后编译,调试运行,这时VS会打开设备模拟器(Device Emulator)窗口模拟运行Pocket PC 2003,等待几分钟后模拟器的设备会弹出消息框显示设备的内存情况。
然后新建一个Visual C# \ Smart Device \ Pocket PC 2003 \ Console Application 项目
是怎么一回事?
用Visual C#怎么建?