Skip to content

Commit

Permalink
modify namespace name
Browse files Browse the repository at this point in the history
add test case
  • Loading branch information
litz-a committed Jan 18, 2016
1 parent 652887e commit ff4533d
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 31 deletions.
2 changes: 1 addition & 1 deletion GLDUserInfoUtils/GLDCpuInfoUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <windows.h>
#include <QString>

namespace GLDCpuInfo
namespace GlodonCpuInfo
{
typedef struct CpuCoreCount
{
Expand Down
23 changes: 15 additions & 8 deletions GLDUserInfoUtils/GLDCpuInfoUtils.h.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#pragma comment(lib, "Advapi32.lib")
#pragma comment(lib, "User32.lib")

namespace GLDCpuInfo
namespace GlodonCpuInfo
{
typedef BOOL(WINAPI *LPFN_GLPI)(PSYSTEM_LOGICAL_PROCESSOR_INFORMATION, PDWORD);

Expand Down Expand Up @@ -153,18 +153,25 @@ namespace GLDCpuInfo

while (byteOffset + sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION) <= returnLength)
{
switch (ptr->Relationship)
//switch (ptr->Relationship)
//{
//case RelationProcessorCore:
// processorCoreCount++;

// // A hyperthreaded core supplies more than one logical processor.
// logicalProcessorCount += countSetBits(ptr->ProcessorMask);
// break;

//default:
// _tprintf("\nError: Unsupported LOGICAL_PROCESSOR_RELATIONSHIP value.\n");
// break;
//}
if (RelationProcessorCore == ptr->Relationship)
{
case RelationProcessorCore:
processorCoreCount++;

// A hyperthreaded core supplies more than one logical processor.
logicalProcessorCount += countSetBits(ptr->ProcessorMask);
break;

default:
_tprintf("\nError: Unsupported LOGICAL_PROCESSOR_RELATIONSHIP value.\n");
break;
}

byteOffset += sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION);
Expand Down
4 changes: 3 additions & 1 deletion GLDUserInfoUtils/GLDDiskInfoUtils.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "GLDDiskInfoUtils.h"
#include <atlstr.h>

namespace GLDDISKINFO
namespace GlodonDiskInfo
{

QString GLDDiskInfo::getSystemVolumeName()
Expand Down Expand Up @@ -296,6 +296,8 @@ namespace GLDDISKINFO

bool GLDDiskInfo::getDiskSpaceInfo(qulonglong& ri64FreeBytesToCaller, qulonglong& ri64TotalBytes)
{
ri64FreeBytesToCaller = 0;
ri64TotalBytes = 0;
QVector<DiskInfomation> diskInfoVct = getAllVolumeInfo();
if (0 == diskInfoVct.size())
{
Expand Down
3 changes: 1 addition & 2 deletions GLDUserInfoUtils/GLDDiskInfoUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
#include <Winioctl.h>
#include <QVector>
#include <QString>
#include <QHash>

using namespace std;

namespace GLDDISKINFO
namespace GlodonDiskInfo
{
enum FS
{
Expand Down
2 changes: 1 addition & 1 deletion GLDUserInfoUtils/GLDMemoryInfoUtils.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "GLDMemoryInfoUtils.h"

namespace GLDMemoryInfo
namespace GlodonMemoryInfo
{
PhysMemInfo getPhysMemInfo()
{
Expand Down
2 changes: 1 addition & 1 deletion GLDUserInfoUtils/GLDMemoryInfoUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <windows.h>
#include <qglobal.h>

namespace GLDMemoryInfo
namespace GlodonMemoryInfo
{
typedef struct PhysicalMemoryInfo
{
Expand Down
2 changes: 1 addition & 1 deletion GLDUserInfoUtils/GLDProcessUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#pragma comment(lib, "Shell32.lib")
#pragma comment(lib, "Advapi32.lib")

namespace GLDProcessInfo
namespace GlodonProcessInfo
{
BOOL setPrivilege(HANDLE hProcess, LPCTSTR lpszPrivilege, BOOL bEnablePrivilege)
{
Expand Down
2 changes: 1 addition & 1 deletion GLDUserInfoUtils/GLDProcessUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <QString>
#include <QStringList>

namespace GLDProcessInfo
namespace GlodonProcessInfo
{
class GLDProcessFunc
{
Expand Down
78 changes: 63 additions & 15 deletions GLDUserInfoUtils/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,80 @@
#include "GLDCpuInfoUtils.h"
#include "GLDDiskInfoUtils.h"

using namespace GLDDISKINFO;
using namespace GlodonDiskInfo;
using namespace GlodonCpuInfo;

#include <QDebug>

int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
GLDDiskInfo disk;

QString cpuBrand = getCpuBrand();
qDebug() << "cpuBrand is" << cpuBrand;

ulong speed = getCpuSpeed();
qDebug() << "speed is" << speed;

ulong count = getCpuCount();
qDebug() << "count is" << count;

CoreCount coreCount = getCpuCoreCount();
qDebug() << "coreCount's cpuCoreCount is" << coreCount.m_cpuCoreCount;
qDebug() << "coreCount's cpuLogicalCoreCount is" << coreCount.m_cpuLogicalCoreCount;


CpuInfo cpuInfo = getCpuInfo();
qDebug() << "cpuInfo is" << cpuInfo.m_cpuBrand;
qDebug() << "cpuInfo is" << cpuInfo.m_coreCount.m_cpuCoreCount;
qDebug() << "cpuInfo is" << cpuInfo.m_coreCount.m_cpuLogicalCoreCount;
qDebug() << "cpuInfo is" << cpuInfo.m_processorPackageCount;
qDebug() << "cpuInfo is" << cpuInfo.m_processSpeed;


GLDDiskInfo disk;
DiskInfomation diskInfo;

disk.getFileSystemType("C:\\");
//disk.getAllVolumeInfo();
FS fileSystem = disk.getFileSystemType("C:\\");
qDebug() << "FS is" << fileSystem;

QString voluName = disk.getSystemVolumeName();
qDebug() << "system volume name is" << voluName;

QString currentVolName = disk.getCurrentVolumeName();
qDebug() << "current volume name is" << currentVolName;

QString serialNumber = disk.getPhysicalDriveSerialNumber();
qDebug() << "serialNumber is" << serialNumber;

ulong volNumber = disk.getVolumeNum();
qDebug() << "volNumber is" << volNumber;

QString volType = disk.getVolumeTypeItem("D:\\");
qDebug() << "volType is" << volType;

qulonglong ri64FreeBytesToCaller;
qulonglong ri64TotalBytes;
disk.getVolumeSpace("E:\\", ri64FreeBytesToCaller, ri64TotalBytes);
qDebug() << "E volume's free space is" << ri64FreeBytesToCaller;
qDebug() << "E volume's totle space is" << ri64TotalBytes;

qulonglong diskFreeBytesToCaller;
qulonglong diskTotalBytes;
disk.getDiskSpaceInfo(diskFreeBytesToCaller, diskTotalBytes);
qDebug() << "Disk free space is" << diskFreeBytesToCaller;
qDebug() << "Disk totle space is" << diskTotalBytes;

qulonglong i64TotalBytes = 0;
qulonglong i64FreeBytes = 0;
disk.getVolumeSpace("C:\\", i64FreeBytes, i64TotalBytes);
QVector<DiskInfomation> diskInfoVet = disk.getAllVolumeInfo();
foreach(DiskInfomation disk , diskInfoVet)
{
qDebug() << "disk name is" << disk.m_strDiskName;
qDebug() << "file system is " << disk.m_strFileSystem;

disk.getFileSystemType("C:\\");
QString no = disk.getPhysicalDriveSerialNumber();
qDebug() << "disk Serial Number is" << no;
QString name1 = disk.getVolumeTypeItem("C:\\");
qDebug() << "disk type name is" << disk.m_strTypeName;
qDebug() << "totle space is" << disk.m_dwTotalMBytes;
qDebug() << "free space is" << disk.m_dwFreeMBytes;
}

QString name = disk.getSystemVolumeName();
qDebug() << "system disk name is" << name;
QString diskname = disk.getCurrentVolumeName();
qDebug() << "current disk name is" << diskname;
return a.exec();
}

0 comments on commit ff4533d

Please sign in to comment.