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

📄 pfwinbase.cpp

📁 PowerFish is a class library, intended to provide a broad functionality base for any application. Al
💻 CPP
字号:
/////////////////////////////////////////////////////////////////////////////////////////////////////// PowerFish core library// Copyright (C) 1997-2001 Camilla Drefvenborg <elmindreda@home.se>//// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation; either version 2 of the License, or// (at your option) any later version.//// This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the// GNU General Public License for more details.//// You should have received a copy of the GNU General Public License// along with this program; if not, write to the Free Software// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA/////////////////////////////////////////////////////////////////////////////////////////////////////#include <PfBase.h>#include <windows.h>#include <lmcons.h>#include <stdio.h>#include <stdlib.h>#include "PfWinBase.h"///////////////////////////////////////////////////////////////////////////////////////////////////const char* PfGetUserName(void){	static char szBuffer[UNLEN + 1];	DWORD dwSize = sizeof(szBuffer);	if (!GetUserName(szBuffer, &dwSize))		return "<<noname>>";	return szBuffer;}const char* PfGetComputerName(void){	static char szBuffer[MAX_COMPUTERNAME_LENGTH + 1];	DWORD dwSize = sizeof(szBuffer);	if (!GetComputerName(szBuffer, &dwSize))		return "<<noname>>";	return szBuffer;}const char* PfGetPlatformName(void){	static char szBuffer[2048];	OSVERSIONINFO osvi;	ZeroMemory(&osvi, sizeof(OSVERSIONINFO));	osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);	if (!GetVersionEx(&osvi))		return "<<noname>>";	const char* szWindowsName;	if (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)	{		if (osvi.dwMinorVersion)			szWindowsName = " 98";		else			szWindowsName = " 95";		// TODO: detect Windows ME	}	else if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT)	{		if (osvi.dwMajorVersion > 4)			szWindowsName = " 2000";		else			szWindowsName = " NT";		// TODO: detect Windows Xp	}	else		szWindowsName = "";	if (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)	{		// Windows 9x (.x.x.x.x...)		if (_snprintf(szBuffer, sizeof(szBuffer), "Windows%s %u.%u.%u.%u", szWindowsName, osvi.dwMajorVersion, osvi.dwMinorVersion, HIWORD(osvi.dwBuildNumber), LOWORD(osvi.dwBuildNumber)) < 0)			szBuffer[sizeof(szBuffer) - 1] = '\0';	}	else	{		if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT && osvi.dwMajorVersion > 4)		{			// Windows 2000 or greater			if (_snprintf(szBuffer, sizeof(szBuffer), "Windows%s build %u", szWindowsName, osvi.dwBuildNumber) < 0)				szBuffer[sizeof(szBuffer) - 1] = '\0';		}		else		{			// Windows NT			if (_snprintf(szBuffer, sizeof(szBuffer), "Windows%s %u.%u build %u", szWindowsName, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber) < 0)				szBuffer[sizeof(szBuffer) - 1] = '\0';		}	}	if (strlen(osvi.szCSDVersion))	{		strcat(szBuffer, " ");		strcat(szBuffer, osvi.szCSDVersion);	}	return szBuffer;}//-------------------------------------------------------------------------------------------------bool PfAssert(const char* szExpression, const char* szFileName, unsigned int uLine){	char szBuffer[2048];	if (_snprintf(szBuffer, sizeof(szBuffer), "Assertion failed!\r\n\r\nExpression: %s\r\nFile: %s\r\nLine: %u", szExpression, szFileName, uLine) < 0)		szBuffer[sizeof(szBuffer) - 1] = '\0';	int iResult = MessageBox(GetActiveWindow(), szBuffer, "PowerFish", MB_ICONERROR | MB_ABORTRETRYIGNORE);	if (iResult == IDABORT)		exit(0);	if (iResult == IDIGNORE)		return false;	return true;}///////////////////////////////////////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

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