Service_NSSM/CC_SDK/Include/Module/Window/CCSystem.h

73 lines
1.8 KiB
C
Raw Normal View History

2025-09-27 14:24:18 +08:00
#ifndef CC_SysTem_H
#define CC_SysTem_H
#include "basic/CC.h"
#include "CCFile.h"
#ifdef _WIN32
#include "Windows.h"
#include <shobjidl.h>
#include <propvarutil.h>
#include <shlguid.h>
#include <shlwapi.h>
#include <pdh.h>
#elif __linux__
#include <linux/limits.h>
#include <sys/stat.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <netinet/in.h>
#include <fstream>
#include <sstream>
#include <sys/sysinfo.h>
#endif
namespace CTL{
struct MemoryInfo {
size_t total;
size_t available;
};
enum OS {
Windows11 = 1,
Windows10 = 2,
Windows8 = 3,
Windows7 = 4,
WindowsXP = 5,
WindowsServer = 6,
Linux = 7,
OpenHarmony = 0,
Unknown = -1
};
class System{
public:
static bool SetAppAutoStart(bool F);
static bool IsAppAutoStart();
static CTL::String GetAppName();
static CTL::String ApplicationDirPath();
static void Exit(int code = 0);
static void Execute(const CTL::String& cmd);
static void Println(const char* fmt,...);
static void Println(const CTL::String& str);
static void ReleaseProcessHeap();
static unsigned int GetPhysicalCores();
static unsigned int GetLogicalCores();
static float GetCPUUsage();
static MemoryInfo GetMemoryInfo();
static String GetMac();
static CTL::String GetOSName();
static OS GetOS();
private:
static OS GetOS(const CTL::String& os);
#ifdef _WIN32
inline static void CreateShortO();
inline static bool DeleteShortO();
inline static CTL::String OpenKit_Dir = "C:/ProgramData/Microsoft/Windows/Start Menu/Programs/StartUp/";
#elif __linux__
static CTL::String GetUserName();
static bool SetFileReadPermission(const std::string& filePath);
#endif
};
}
#endif