⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 config.h

📁 Example of using HTC sensor api to get Light sensor value and set backlight level in modern HTC phon
💻 H
字号:
#pragma once

#include <windows.h>
#include <wchar.h>
#include <stdio.h>
#include <stdlib.h>

#define NOLOG
#define _LOG_EXCLUSIVE

#ifdef _DEBUG
	#define _LOG LogEventFile
#else
	#ifdef NOLOG
		#define _LOG //
	#else
		#define _LOG LogEventFile
	#endif
#endif
#define MAX_BUF_SIZE 2048
#define LOGNAME L"LumosCPP"



class Config;
extern Config config;
extern HINSTANCE g_hInst;

class Config
{
	TCHAR* programDir;
	TCHAR* exePath;

public:
	Config();
	~Config();

	void Init();

	const TCHAR* GetProgramDir() { return this->programDir; }
	const TCHAR* GetExePath() { return this->exePath; }
	TCHAR* GetFilePath(const TCHAR* relFileName);
	FILE* OpenFile(const TCHAR* FileName, const TCHAR* mode);
	bool GetLine(FILE* fp, TCHAR* buf, int bufsizeInChars);
	bool GetUtf8FileLine(FILE* fp, TCHAR* buf, int bufsizeInChars);
	int LogLevel;
};

void LogEventFile(LPCTSTR str, ...);
void LogEventDebug(LPCTSTR str, ...);
void LogEventNull(LPCTSTR str, ...);

int wcstrlen(const TCHAR* buf, int maxlen=MAX_BUF_SIZE);
TCHAR* wcstrcpy(TCHAR* dest, const TCHAR* src);
TCHAR* wcstrcat(TCHAR* dest, const TCHAR* src);
TCHAR* wcstrdup(const TCHAR* src);
TCHAR* wcsprintf(TCHAR* dest, const TCHAR* format, ...);
TCHAR* wctrim(TCHAR* str);
TCHAR* wcstrtok(TCHAR* str, const TCHAR* delimChars);
bool wcstrbegins(const TCHAR* str, const TCHAR* begin);
int wctoi(const TCHAR* str);
float wctof(const TCHAR* str);
const TCHAR* GetForegroundWindowPath();
const TCHAR* GetProccessName(DWORD procId);
bool RegReadString(HKEY rootKey, LPCTSTR subKey, LPCTSTR valueName, TCHAR** value, const TCHAR* defValue);
bool RegWriteString(HKEY rootKey, LPCTSTR subKey, LPCTSTR valueName, const TCHAR* value);

inline bool is_spacer(TCHAR c) { return (c==0 || c==L' ' || c==L'\t' || c==L'\n' || c==L'\r');}
inline bool is_comment(TCHAR c) { return ( c==L';' || c==L'#'); }
void throwError(const TCHAR* format, ...);



class Exception
{
private:
	TCHAR* message;
public:
	Exception(const TCHAR* message) { this->message = wcsdup(message); }
	~Exception() { free(this->message); }
	const TCHAR* GetMessage() { return this->message; }
};


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -