超级博客 Win32 设备管理(1)
来源:互联网 发布:淘宝订单能保存多久 编辑:程序博客网 时间:2024/05/06 03:25
点击打开链接
一.获得物理内存参数
使用GlobalMemoryStatus函数
void CDemoDlg::OnTest()
{
CListBox* pListBox = (CListBox*)GetDlgItem(IDC_LIST);
pListBox->ResetContent();
//获得物理内存参数
MEMORYSTATUS MemoryStatus;
GlobalMemoryStatus(&MemoryStatus);
CString strText = _T("");
strText.Format(_T("物理内存使用率:%d%s"),
MemoryStatus.dwMemoryLoad, _T("%"));
pListBox->AddString(strText);
strText.Format(_T("物理内存总数: %dK"),
MemoryStatus.dwTotalPhys / 1024);
pListBox->AddString(strText);
strText.Format(_T("物理内存可用数:%dK"),
MemoryStatus.dwAvailPhys / 1024);
pListBox->AddString(strText);
strText.Format(_T("页文件总数: %dK"),
MemoryStatus.dwTotalPageFile / 1024);
pListBox->AddString(strText);
strText.Format(_T("页文件用数: %dK"),
MemoryStatus.dwAvailPageFile / 1024);
pListBox->AddString(strText);
strText.Format(_T("虚拟内存总数: %dK"),
MemoryStatus.dwTotalVirtual / 1024);
pListBox->AddString(strText);
strText.Format(_T("虚拟内存可用数:%dK"),
MemoryStatus.dwAvailVirtual / 1024);
pListBox->AddString(strText);
}
{
CListBox* pListBox = (CListBox*)GetDlgItem(IDC_LIST);
pListBox->ResetContent();
//获得物理内存参数
MEMORYSTATUS MemoryStatus;
GlobalMemoryStatus(&MemoryStatus);
CString strText = _T("");
strText.Format(_T("物理内存使用率:%d%s"),
MemoryStatus.dwMemoryLoad, _T("%"));
pListBox->AddString(strText);
strText.Format(_T("物理内存总数: %dK"),
MemoryStatus.dwTotalPhys / 1024);
pListBox->AddString(strText);
strText.Format(_T("物理内存可用数:%dK"),
MemoryStatus.dwAvailPhys / 1024);
pListBox->AddString(strText);
strText.Format(_T("页文件总数: %dK"),
MemoryStatus.dwTotalPageFile / 1024);
pListBox->AddString(strText);
strText.Format(_T("页文件用数: %dK"),
MemoryStatus.dwAvailPageFile / 1024);
pListBox->AddString(strText);
strText.Format(_T("虚拟内存总数: %dK"),
MemoryStatus.dwTotalVirtual / 1024);
pListBox->AddString(strText);
strText.Format(_T("虚拟内存可用数:%dK"),
MemoryStatus.dwAvailVirtual / 1024);
pListBox->AddString(strText);
}
二.获取驱动器
使用GetLogicalDrives方法,使用位掩码方式获得驱动器
View Code
三.获取驱动器类型
使用GetDriveType函数,输入参数如C:\,根据返回的值判别类型
View Code
四.获得驱动器卷标
使用GetVolumeInformation函数,即硬盘分区的名字(卷标)
View Code
五.设置驱动器卷标
使用SetVolumeLabel函数,需要管理员权限
View Code
六.获得驱动器序列号
还是使用GetVolumeInformation函数,第4个参数为输出结果,第一个参数是必须的
//获得驱动器序列号
DWORD dwSerialNumber = 0;
GetVolumeInformation(strDiriveName, NULL,
NULL, &dwSerialNumber, NULL, NULL, NULL, 0);
DWORD dwSerialNumber = 0;
GetVolumeInformation(strDiriveName, NULL,
NULL, &dwSerialNumber, NULL, NULL, NULL, 0);
七.获得驱动器文件系统
用GetVolumeInformation函数,最后两个参数填充,即获取装载文件系统的名称(如FAT,NTFS以及其他)
//获得驱动器文件系统
CString strFileSystemName = _T("");
GetVolumeInformation(strDiriveName, NULL, 0, NULL, NULL, NULL,
strFileSystemName.GetBuffer(1024), 1024);
strFileSystemName.ReleaseBuffer();
pList->SetItemText(n, 1, strFileSystemName);
CString strFileSystemName = _T("");
GetVolumeInformation(strDiriveName, NULL, 0, NULL, NULL, NULL,
strFileSystemName.GetBuffer(1024), 1024);
strFileSystemName.ReleaseBuffer();
pList->SetItemText(n, 1, strFileSystemName);
八.获取驱动器磁盘空间信息
使用GetDiskFreeSpaceEx函数
//获得磁盘空间信息
ULARGE_INTEGER FreeBytes;
ULARGE_INTEGER TotalBytes;
if (!GetDiskFreeSpaceEx(strDiriveName, &FreeBytes,
&TotalBytes, NULL))
{
FreeBytes.QuadPart=0;
TotalBytes.QuadPart=0;
}
UINT nFreeSize = (UINT)(FreeBytes.QuadPart / 1024 / 1024);
UINT nTotalSize = (UINT)(TotalBytes.QuadPart / 1024 / 1024);
CString strText = _T("");
strText.Format(_T("%d MB"), nFreeSize);
pList->SetItemText(n, 1, strText);
strText.Format(_T("%d MB"),nTotalSize);
pList->SetItemText(n, 2, strText);
ULARGE_INTEGER FreeBytes;
ULARGE_INTEGER TotalBytes;
if (!GetDiskFreeSpaceEx(strDiriveName, &FreeBytes,
&TotalBytes, NULL))
{
FreeBytes.QuadPart=0;
TotalBytes.QuadPart=0;
}
UINT nFreeSize = (UINT)(FreeBytes.QuadPart / 1024 / 1024);
UINT nTotalSize = (UINT)(TotalBytes.QuadPart / 1024 / 1024);
CString strText = _T("");
strText.Format(_T("%d MB"), nFreeSize);
pList->SetItemText(n, 1, strText);
strText.Format(_T("%d MB"),nTotalSize);
pList->SetItemText(n, 2, strText);
0 0
- 超级博客 Win32 设备管理(1)
- 超级博客 Win32 设备管理(2)
- 超级博客 Win32 系统部分函数
- [OS复习]设备管理1
- 设备管理
- 设备管理
- 设备管理
- 设备管理
- 设备管理
- 设备管理
- 设备管理
- 设备管理
- 设备管理
- 设备管理
- 设备管理
- 设备管理
- 设备管理
- 设备管理
- 超级博客 Win32 系统部分函数
- C#做服务器,客户端,实现局域网通信
- poj 1321 棋盘问题
- mysql数据类型和长度
- java中实例变量、类变量以及构造方法的加载顺序
- 超级博客 Win32 设备管理(1)
- 输入四川会显示right吗?
- “黑马程序员” do-while和while-do的区别
- 超级博客 Win32 设备管理(2)
- Android内存机制分析上篇:了解Android堆和栈
- 原型模式
- 做了一道POJ1001。。
- 导出javadoc以及出现的问题
- Linaro Android 4.4.2系统下载和使用(arndale octa board)