本文整理汇总了C++中GetSystemInfo函数的典型用法代码示例。如果您正苦于以下问题:C++ GetSystemInfo函数的具体用法?C++ GetSystemInfo怎么用?C++ GetSystemInfo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetSystemInfo函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: InitializeSystemPage
static
VOID
InitializeSystemPage(HWND hwndDlg)
{
WCHAR szTime[200];
DWORD Length;
DWORDLONG AvailableBytes, UsedBytes;
MEMORYSTATUSEX mem;
WCHAR szFormat[40];
WCHAR szDesc[50];
SYSTEM_INFO SysInfo;
/* set date/time */
szTime[0] = L'\0';
Length = GetDateFormat(LOCALE_SYSTEM_DEFAULT, DATE_LONGDATE, NULL, NULL, szTime, sizeof(szTime) / sizeof(WCHAR));
if (Length)
{
szTime[Length-1] = L',';
szTime[Length++] = L' ';
}
Length = GetTimeFormatW(LOCALE_SYSTEM_DEFAULT, TIME_FORCE24HOURFORMAT|LOCALE_NOUSEROVERRIDE, NULL, NULL, &szTime[Length], (sizeof(szTime) / sizeof(WCHAR)));
szTime[199] = L'\0';
SendDlgItemMessageW(hwndDlg, IDC_STATIC_TIME, WM_SETTEXT, 0, (LPARAM)szTime);
/* set computer name */
szTime[0] = L'\0';
Length = sizeof(szTime) / sizeof(WCHAR);
if (GetComputerNameW(szTime, &Length))
SendDlgItemMessageW(hwndDlg, IDC_STATIC_COMPUTER, WM_SETTEXT, 0, (LPARAM)szTime);
/* set product name */
if (GetOSVersion(szTime))
{
SendDlgItemMessage(hwndDlg, IDC_STATIC_OS, WM_SETTEXT, 0, (LPARAM)szTime);
}
else
{
if (LoadStringW(hInst, IDS_VERSION_UNKNOWN, szTime, sizeof(szTime) / sizeof(WCHAR)))
{
szTime[(sizeof(szTime) / sizeof(WCHAR))-1] = L'\0';
SendDlgItemMessage(hwndDlg, IDC_STATIC_VERSION, WM_SETTEXT, 0, (LPARAM)szTime);
}
}
/* FIXME set product language/local language */
if (GetLocaleInfo(LOCALE_SYSTEM_DEFAULT,LOCALE_SLANGUAGE , szTime, sizeof(szTime) / sizeof(WCHAR)))
SendDlgItemMessageW(hwndDlg, IDC_STATIC_LANG, WM_SETTEXT, 0, (LPARAM)szTime);
/* set system manufacturer */
szTime[0] = L'\0';
if (GetRegValue(HKEY_LOCAL_MACHINE, L"Hardware\\Description\\System\\BIOS", L"SystemManufacturer", REG_SZ, szTime, sizeof(szTime)))
{
szTime[199] = L'\0';
SendDlgItemMessageW(hwndDlg, IDC_STATIC_MANU, WM_SETTEXT, 0, (LPARAM)szTime);
}
/* set motherboard model */
szTime[0] = L'\0';
if (GetRegValue(HKEY_LOCAL_MACHINE, L"Hardware\\Description\\System\\BIOS", L"SystemProductName", REG_SZ, szTime, sizeof(szTime)))
{
SendDlgItemMessageW(hwndDlg, IDC_STATIC_MODEL, WM_SETTEXT, 0, (LPARAM)szTime);
}
/* set bios model */
szTime[0] = L'\0';
if (GetRegValue(HKEY_LOCAL_MACHINE, L"Hardware\\Description\\System\\BIOS", L"BIOSVendor", REG_SZ, szTime, sizeof(szTime)))
{
DWORD Index;
DWORD StrLength = (sizeof(szTime) / sizeof(WCHAR));
Index = wcslen(szTime);
StrLength -= Index;
if (GetRegValue(HKEY_LOCAL_MACHINE, L"Hardware\\Description\\System\\BIOS", L"BIOSReleaseDate", REG_SZ, &szTime[Index], StrLength))
{
if (Index + StrLength > (sizeof(szTime)/sizeof(WCHAR))- 15)
{
//FIXME retrieve BiosMajorRelease, BiosMinorRelease
//StrLength = wcslen(&szTime[Index]);
//szTime[Index+StrLength] = L' ';
//wcscpy(&szTime[Index+StrLength], L"Ver: "); //FIXME NON-NLS
//szTime[(sizeof(szTime)/sizeof(WCHAR))-1] = L'\0';
}
SendDlgItemMessageW(hwndDlg, IDC_STATIC_BIOS, WM_SETTEXT, 0, (LPARAM)szTime);
}
}
/* set processor string */
if (GetRegValue(HKEY_LOCAL_MACHINE, L"Hardware\\Description\\System\\CentralProcessor\\0", L"ProcessorNameString", REG_SZ, szDesc, sizeof(szDesc)))
{
/* FIXME retrieve current speed */
szFormat[0] = L'\0';
GetSystemInfo(&SysInfo);
if (SysInfo.dwNumberOfProcessors > 1)
LoadStringW(hInst, IDS_FORMAT_MPPROC, szFormat, sizeof(szFormat) / sizeof(WCHAR));
else
LoadStringW(hInst, IDS_FORMAT_UNIPROC, szFormat, sizeof(szFormat) / sizeof(WCHAR));
szFormat[(sizeof(szFormat)/sizeof(WCHAR))-1] = L'\0';
wsprintfW(szTime, szFormat, szDesc, SysInfo.dwNumberOfProcessors);
SendDlgItemMessageW(hwndDlg, IDC_STATIC_PROC, WM_SETTEXT, 0, (LPARAM)szTime);
//.........这里部分代码省略.........
开发者ID:HBelusca,项目名称:NasuTek-Odyssey,代码行数:101,代码来源:system.c
示例2: XBREAK
/**
@brief
@param numWorkThread 0이면 시스템 코어에 맞춰 자동
*/
void XEWinSocketSvr::Create( WORD port, int numWorkThread )
{
XBREAK( port == 0 );
if( XWinNetwork::sStartUp() == false ) {
XALERT( "WSAStartup failed" );
return;
}
//
// m_Socket = socket( AF_INET, SOCK_STREAM, 0 );
m_Socket = WSASocket( PF_INET, SOCK_STREAM, 0, NULL, 0, WSA_FLAG_OVERLAPPED );
if( m_Socket == INVALID_SOCKET ) {
XALERT( "create socket failed" );
return;
}
SOCKADDR_IN addr;
addr.sin_family = AF_INET;
addr.sin_port = htons( port );
addr.sin_addr.S_un.S_addr = htonl( INADDR_ANY );
if( bind( m_Socket, ( struct sockaddr * )&addr, sizeof( addr ) ) == SOCKET_ERROR ) {
XBREAK(1);
XALERT( "Network bind error" );
Destroy();
return;
}
//
m_Port = port;
// 클라로부터 접속을 받을 준비
if( listen( m_Socket, SOMAXCONN ) == SOCKET_ERROR ) {
XALERT( "Network::listen error" );
Destroy();
return;
}
//
m_pUserMng = CreateUserMng( m_maxConnect );
XBREAK( m_pUserMng == NULL );
// 유저 커스텀 create
OnCreate(); // virtual
// IOCP 객체 생성
m_hIOCP = CreateIoCompletionPort( INVALID_HANDLE_VALUE, NULL, 0, 0 );
// 워커 스레드 생성
SYSTEM_INFO si;
memset( &si, 0, sizeof(si));
GetSystemInfo( &si );
#if defined(_DEBUG) && !defined(_XBOT)
const int numThread = 4; // 개발중엔 편의상 스레드 적게쓴다.
#else
const int numThread = (numWorkThread == 0)?
(int)(si.dwNumberOfProcessors * 2)
: numWorkThread;
#endif
XBREAK( numThread <= 0 || numThread > 32 );
for( int i = 0; i < numThread; ++i ) {
m_aryThreadWork.push_back( CreateWorkThread() );
}
// accept( 클라이언트로부터의 접속대기 ) 스레드 생성
m_thAccept = CreateAcceptThread();
//
#if _DEV_LEVEL <= DLV_OPEN_BETA
m_timerSec.Set( 1.f );
#endif
}
开发者ID:xahgo,项目名称:tama,代码行数:65,代码来源:XWinSocketSvr.cpp
示例3: do_sysinfo
/* base::Sys.info */
SEXP do_sysinfo(SEXP call, SEXP op, SEXP args, SEXP rho)
{
SEXP ans, ansnames;
OSVERSIONINFOEX osvi;
char ver[256], buf[1000];
wchar_t name[MAX_COMPUTERNAME_LENGTH + 1], user[UNLEN+1];
DWORD namelen = MAX_COMPUTERNAME_LENGTH + 1, userlen = UNLEN+1;
checkArity(op, args);
PROTECT(ans = allocVector(STRSXP, 8));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
if(!GetVersionEx((OSVERSIONINFO *)&osvi))
error(_("unsupported version of Windows"));
SET_STRING_ELT(ans, 0, mkChar("Windows"));
/* Here for unknown future versions */
snprintf(ver, 256, "%d.%d",
(int)osvi.dwMajorVersion, (int)osvi.dwMinorVersion);
if((int)osvi.dwMajorVersion >= 5) {
PGNSI pGNSI;
SYSTEM_INFO si;
if(osvi.dwMajorVersion == 6) {
if(osvi.wProductType == VER_NT_WORKSTATION) {
if(osvi.dwMinorVersion == 0)
strcpy(ver, "Vista");
else strcpy(ver, "7");
} else
strcpy(ver, "Server 2008");
}
if(osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0)
strcpy(ver, "2000");
if(osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1)
strcpy(ver, "XP");
if(osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2) {
if(osvi.wProductType == VER_NT_WORKSTATION)
strcpy(ver, "XP Professional");
else strcpy(ver, "Server 2003");
}
/* GetNativeSystemInfo is XP or later */
pGNSI = (PGNSI)
GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")),
"GetNativeSystemInfo");
if(NULL != pGNSI) pGNSI(&si); else GetSystemInfo(&si);
if(si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
strcat(ver, " x64");
}
SET_STRING_ELT(ans, 1, mkChar(ver));
if((int)osvi.dwMajorVersion >= 5) {
if(osvi.wServicePackMajor > 0)
snprintf(ver, 256, "build %d, Service Pack %d",
LOWORD(osvi.dwBuildNumber),
(int) osvi.wServicePackMajor);
else snprintf(ver, 256, "build %d", LOWORD(osvi.dwBuildNumber));
} else
snprintf(ver, 256, "build %d, %s",
LOWORD(osvi.dwBuildNumber), osvi.szCSDVersion);
SET_STRING_ELT(ans, 2, mkChar(ver));
GetComputerNameW(name, &namelen);
wcstoutf8(buf, name, 1000);
SET_STRING_ELT(ans, 3, mkCharCE(buf, CE_UTF8));
#ifdef _WIN64
SET_STRING_ELT(ans, 4, mkChar("x86-64"));
#else
SET_STRING_ELT(ans, 4, mkChar("x86"));
#endif
GetUserNameW(user, &userlen);
wcstoutf8(buf, user, 1000);
SET_STRING_ELT(ans, 5, mkCharCE(buf, CE_UTF8));
SET_STRING_ELT(ans, 6, STRING_ELT(ans, 5));
SET_STRING_ELT(ans, 7, STRING_ELT(ans, 5));
PROTECT(ansnames = allocVector(STRSXP, 8));
SET_STRING_ELT(ansnames, 0, mkChar("sysname"));
SET_STRING_ELT(ansnames, 1, mkChar("release"));
SET_STRING_ELT(ansnames, 2, mkChar("version"));
SET_STRING_ELT(ansnames, 3, mkChar("nodename"));
SET_STRING_ELT(ansnames, 4, mkChar("machine"));
SET_STRING_ELT(ansnames, 5, mkChar("login"));
SET_STRING_ELT(ansnames, 6, mkChar("user"));
SET_STRING_ELT(ansnames, 7, mkChar("effective_user"));
setAttrib(ans, R_NamesSymbol, ansnames);
UNPROTECT(2);
return ans;
}
开发者ID:skyguy94,项目名称:R,代码行数:87,代码来源:extra.c
示例4: QString
void FeedbackDialog::GenerateSpecs()
{
// Gather some information about the system and embed it into the report
QDesktopWidget* screen = QApplication::desktop();
QString os_version = "Operating system: ";
QString qt_version = QString("Qt version: ") + QT_VERSION_STR + QString("\n");
QString total_ram = "Total RAM: ";
QString number_of_cores = "Number of cores: ";
QString compiler_bits = "Compiler architecture: ";
QString compiler_version = "Compiler version: ";
QString kernel_line = "Kernel: ";
QString screen_size = "Size of the screen(s): " +
QString::number(screen->width()) + "x" + QString::number(screen->height()) + "\n";
QString number_of_screens = "Number of screens: " + QString::number(screen->screenCount()) + "\n";
QString processor_name = "Processor: ";
// platform specific code
#ifdef Q_OS_MACX
number_of_cores += QString::number(sysconf(_SC_NPROCESSORS_ONLN)) + "\n";
uint64_t memsize;
size_t len = sizeof(memsize);
static int mib_s[2] = { CTL_HW, HW_MEMSIZE };
if (sysctl (mib_s, 2, &memsize, &len, NULL, 0) == 0)
total_ram += QString::number(memsize/1024/1024) + " MB\n";
else
total_ram += "Error getting total RAM information\n";
int mib[] = {CTL_KERN, KERN_OSRELEASE};
sysctl(mib, sizeof mib / sizeof(int), NULL, &len, NULL, 0);
char *kernelVersion = (char *)malloc(sizeof(char)*len);
sysctl(mib, sizeof mib / sizeof(int), kernelVersion, &len, NULL, 0);
QString kernelVersionStr = QString(kernelVersion);
free(kernelVersion);
int major_version = kernelVersionStr.split(".").first().toUInt() - 4;
int minor_version = kernelVersionStr.split(".").at(1).toUInt();
os_version += QString("Mac OS X 10.%1.%2").arg(major_version).arg(minor_version) + " ";
switch(major_version)
{
case 4: os_version += "\"Tiger\"\n"; break;
case 5: os_version += "\"Leopard\"\n"; break;
case 6: os_version += "\"Snow Leopard\"\n"; break;
case 7: os_version += "\"Lion\"\n"; break;
case 8: os_version += "\"Mountain Lion\"\n"; break;
default: os_version += "\"Unknown version\"\n"; break;
}
#endif
#ifdef Q_OS_WIN
SYSTEM_INFO sysinfo;
GetSystemInfo(&sysinfo);
number_of_cores += QString::number(sysinfo.dwNumberOfProcessors) + "\n";
MEMORYSTATUSEX status;
status.dwLength = sizeof(status);
GlobalMemoryStatusEx(&status);
total_ram += QString::number(status.ullTotalPhys/1024/1024) + " MB\n";
switch(QSysInfo::windowsVersion())
{
case QSysInfo::WV_NT: os_version += "Windows NT\n"; break;
case QSysInfo::WV_2000: os_version += "Windows 2000\n"; break;
case QSysInfo::WV_XP: os_version += "Windows XP\n"; break;
case QSysInfo::WV_2003: os_version += "Windows Server 2003\n"; break;
case QSysInfo::WV_VISTA: os_version += "Windows Vista\n"; break;
case QSysInfo::WV_WINDOWS7: os_version += "Windows 7\n"; break;
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
case QSysInfo::WV_WINDOWS8: os_version += "Windows 8\n"; break;
#endif
default: os_version += "Windows (Unknown version)\n"; break;
}
kernel_line += "Windows kernel\n";
#endif
#ifdef Q_OS_LINUX
number_of_cores += QString::number(sysconf(_SC_NPROCESSORS_ONLN)) + "\n";
quint32 pages = sysconf(_SC_PHYS_PAGES);
quint32 page_size = sysconf(_SC_PAGE_SIZE);
quint32 total = pages * page_size / 1024 / 1024;
total_ram += QString::number(total) + " MB\n";
os_version += "GNU/Linux or BSD\n";
#endif
// uname -a
#if defined(Q_OS_LINUX) || defined(Q_OS_MAC)
QProcess *process = new QProcess();
QStringList arguments = QStringList("-a");
process->start("uname", arguments);
if (process->waitForFinished())
kernel_line += QString(process->readAll());
delete process;
#endif
#if (defined(Q_OS_WIN) && defined(__i386__)) || defined(__x86_64__)
// cpu info
quint32 registers[4];
quint32 i;
i = 0x80000002;
asm volatile
//.........这里部分代码省略.........
开发者ID:GhostAlgorithm,项目名称:hw,代码行数:101,代码来源:feedbackdialog.cpp
示例5: getCpuNum
int getCpuNum(){
SYSTEM_INFO si;
GetSystemInfo(&si);
return (int)si.dwNumberOfProcessors;
}
开发者ID:Chansie,项目名称:host-sflow,代码行数:5,代码来源:loadAverage.c
示例6: APR_DECLARE
APR_DECLARE(apr_status_t) apr_shm_create_ex(apr_shm_t **m,
apr_size_t reqsize,
const char *file,
apr_pool_t *pool,
apr_int32_t flags)
{
static apr_size_t memblock = 0;
HANDLE hMap, hFile;
apr_status_t rv;
apr_size_t size;
apr_file_t *f;
void *base;
void *mapkey;
DWORD err, sizelo, sizehi;
reqsize += sizeof(memblock_t);
if (!memblock)
{
SYSTEM_INFO si;
GetSystemInfo(&si);
memblock = si.dwAllocationGranularity;
}
/* Compute the granualar multiple of the pagesize */
size = memblock * (1 + (reqsize - 1) / memblock);
sizelo = (DWORD)size;
#ifdef _WIN64
sizehi = (DWORD)(size >> 32);
#else
sizehi = 0;
#endif
if (!file) {
/* Do Anonymous, which must be passed as a duplicated handle */
#ifndef _WIN32_WCE
hFile = INVALID_HANDLE_VALUE;
#endif
mapkey = NULL;
}
else {
int global;
/* Do file backed, which is not an inherited handle
* While we could open APR_FOPEN_EXCL, it doesn't seem that Unix
* ever did. Ignore that error here, but fail later when
* we discover we aren't the creator of the file map object.
*/
rv = apr_file_open(&f, file,
APR_FOPEN_READ | APR_FOPEN_WRITE | APR_FOPEN_BINARY | APR_FOPEN_CREATE,
APR_FPROT_UREAD | APR_FPROT_UWRITE, pool);
if ((rv != APR_SUCCESS)
|| ((rv = apr_os_file_get(&hFile, f)) != APR_SUCCESS)) {
return rv;
}
rv = apr_file_trunc(f, size);
/* res_name_from_filename turns file into a pseudo-name
* without slashes or backslashes, and prepends the \global
* or \local prefix on Win2K and later
*/
if (flags & APR_SHM_NS_GLOBAL) {
global = 1;
}
else if (flags & APR_SHM_NS_LOCAL) {
global = 0;
}
else {
global = can_create_global_maps();
}
mapkey = res_name_from_filename(file, global, pool);
}
#if APR_HAS_UNICODE_FS
IF_WIN_OS_IS_UNICODE
{
hMap = CreateFileMappingW(hFile, NULL, PAGE_READWRITE,
sizehi, sizelo, mapkey);
}
#endif
#if APR_HAS_ANSI_FS
ELSE_WIN_OS_IS_ANSI
{
hMap = CreateFileMappingA(hFile, NULL, PAGE_READWRITE,
sizehi, sizelo, mapkey);
}
#endif
err = apr_get_os_error();
if (file) {
apr_file_close(f);
}
if (hMap && APR_STATUS_IS_EEXIST(err)) {
CloseHandle(hMap);
return APR_EEXIST;
}
if (!hMap) {
return err;
}
//.........这里部分代码省略.........
开发者ID:traviscross,项目名称:apr,代码行数:101,代码来源:shm.c
示例7: GetSystemInfo
void MarkStack::initializePagesize()
{
SYSTEM_INFO system_info;
GetSystemInfo(&system_info);
MarkStack::s_pageSize = system_info.dwPageSize;
}
开发者ID:325116067,项目名称:semc-qsd8x50,代码行数:6,代码来源:MarkStackWin.cpp
示例8: caml_ba_map_file
CAMLprim value caml_ba_map_file(value vfd, value vkind, value vlayout,
value vshared, value vdim, value vstart)
{
HANDLE fd, fmap;
int flags, major_dim, mode, perm;
intnat num_dims, i;
intnat dim[MAX_NUM_DIMS];
__int64 currpos, startpos, file_size, data_size;
uintnat array_size, page, delta;
char c;
void * addr;
LARGE_INTEGER li;
SYSTEM_INFO sysinfo;
fd = Handle_val(vfd);
flags = Int_val(vkind) | Int_val(vlayout);
startpos = Int64_val(vstart);
num_dims = Wosize_val(vdim);
major_dim = flags & BIGARRAY_FORTRAN_LAYOUT ? num_dims - 1 : 0;
/* Extract dimensions from Caml array */
num_dims = Wosize_val(vdim);
if (num_dims < 1 || num_dims > MAX_NUM_DIMS)
invalid_argument("Bigarray.mmap: bad number of dimensions");
for (i = 0; i < num_dims; i++) {
dim[i] = Long_val(Field(vdim, i));
if (dim[i] == -1 && i == major_dim) continue;
if (dim[i] < 0 || dim[i] > 0x7FFFFFFFL)
invalid_argument("Bigarray.create: negative dimension");
}
/* Determine file size */
currpos = caml_ba_set_file_pointer(fd, 0, FILE_CURRENT);
if (currpos == -1) caml_ba_sys_error();
file_size = caml_ba_set_file_pointer(fd, 0, FILE_END);
if (file_size == -1) caml_ba_sys_error();
/* Determine array size in bytes (or size of array without the major
dimension if that dimension wasn't specified) */
array_size = bigarray_element_size[flags & BIGARRAY_KIND_MASK];
for (i = 0; i < num_dims; i++)
if (dim[i] != -1) array_size *= dim[i];
/* Check if the first/last dimension is unknown */
if (dim[major_dim] == -1) {
/* Determine first/last dimension from file size */
if (file_size < startpos)
failwith("Bigarray.mmap: file position exceeds file size");
data_size = file_size - startpos;
dim[major_dim] = (uintnat) (data_size / array_size);
array_size = dim[major_dim] * array_size;
if (array_size != data_size)
failwith("Bigarray.mmap: file size doesn't match array dimensions");
}
/* Restore original file position */
caml_ba_set_file_pointer(fd, currpos, FILE_BEGIN);
/* Create the file mapping */
if (Bool_val(vshared)) {
perm = PAGE_READWRITE;
mode = FILE_MAP_WRITE;
} else {
perm = PAGE_READONLY; /* doesn't work under Win98 */
mode = FILE_MAP_COPY;
}
li.QuadPart = startpos + array_size;
fmap = CreateFileMapping(fd, NULL, perm, li.HighPart, li.LowPart, NULL);
if (fmap == NULL) caml_ba_sys_error();
/* Determine offset so that the mapping starts at the given file pos */
GetSystemInfo(&sysinfo);
delta = (uintnat) (startpos % sysinfo.dwPageSize);
/* Map the mapping in memory */
li.QuadPart = startpos - delta;
addr =
MapViewOfFile(fmap, mode, li.HighPart, li.LowPart, array_size + delta);
if (addr == NULL) caml_ba_sys_error();
addr = (void *) ((uintnat) addr + delta);
/* Close the file mapping */
CloseHandle(fmap);
/* Build and return the Caml bigarray */
return alloc_bigarray(flags | BIGARRAY_MAPPED_FILE, num_dims, addr, dim);
}
开发者ID:avsm,项目名称:ocaml-community,代码行数:77,代码来源:mmap_win32.c
示例9: TclpSetVariables
void
TclpSetVariables(
Tcl_Interp *interp) /* Interp to initialize. */
{
const char *ptr;
char buffer[TCL_INTEGER_SPACE * 2];
SYSTEM_INFO sysInfo, *sysInfoPtr = &sysInfo;
OemId *oemId;
OSVERSIONINFOA osInfo;
Tcl_DString ds;
WCHAR szUserName[UNLEN+1];
DWORD cchUserNameLen = UNLEN;
Tcl_SetVar2Ex(interp, "tclDefaultLibrary", NULL,
TclGetProcessGlobalValue(&defaultLibraryDir), TCL_GLOBAL_ONLY);
osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
GetVersionExA(&osInfo);
oemId = (OemId *) sysInfoPtr;
GetSystemInfo(&sysInfo);
/*
* Define the tcl_platform array.
*/
Tcl_SetVar2(interp, "tcl_platform", "platform", "windows",
TCL_GLOBAL_ONLY);
if (osInfo.dwPlatformId < NUMPLATFORMS) {
Tcl_SetVar2(interp, "tcl_platform", "os",
platforms[osInfo.dwPlatformId], TCL_GLOBAL_ONLY);
}
wsprintfA(buffer, "%d.%d", osInfo.dwMajorVersion, osInfo.dwMinorVersion);
Tcl_SetVar2(interp, "tcl_platform", "osVersion", buffer, TCL_GLOBAL_ONLY);
if (oemId->wProcessorArchitecture < NUMPROCESSORS) {
Tcl_SetVar2(interp, "tcl_platform", "machine",
processors[oemId->wProcessorArchitecture],
TCL_GLOBAL_ONLY);
}
#ifdef _DEBUG
/*
* The existence of the "debug" element of the tcl_platform array
* indicates that this particular Tcl shell has been compiled with debug
* information. Using "info exists tcl_platform(debug)" a Tcl script can
* direct the interpreter to load debug versions of DLLs with the load
* command.
*/
Tcl_SetVar2(interp, "tcl_platform", "debug", "1",
TCL_GLOBAL_ONLY);
#endif
/*
* Set up the HOME environment variable from the HOMEDRIVE & HOMEPATH
* environment variables, if necessary.
*/
Tcl_DStringInit(&ds);
ptr = Tcl_GetVar2(interp, "env", "HOME", TCL_GLOBAL_ONLY);
if (ptr == NULL) {
ptr = Tcl_GetVar2(interp, "env", "HOMEDRIVE", TCL_GLOBAL_ONLY);
if (ptr != NULL) {
Tcl_DStringAppend(&ds, ptr, -1);
}
ptr = Tcl_GetVar2(interp, "env", "HOMEPATH", TCL_GLOBAL_ONLY);
if (ptr != NULL) {
Tcl_DStringAppend(&ds, ptr, -1);
}
if (Tcl_DStringLength(&ds) > 0) {
Tcl_SetVar2(interp, "env", "HOME", Tcl_DStringValue(&ds),
TCL_GLOBAL_ONLY);
} else {
Tcl_SetVar2(interp, "env", "HOME", "c:\\", TCL_GLOBAL_ONLY);
}
}
/*
* Initialize the user name from the environment first, since this is much
* faster than asking the system.
* Note: cchUserNameLen is number of characters including nul terminator.
*/
Tcl_DStringInit(&ds);
if (TclGetEnv("USERNAME", &ds) == NULL) {
if (tclWinProcs->getUserName((LPTSTR)szUserName, &cchUserNameLen) != 0) {
int cbUserNameLen = cchUserNameLen - 1;
if (tclWinProcs->useWide) cbUserNameLen *= sizeof(WCHAR);
Tcl_WinTCharToUtf((LPTSTR)szUserName, cbUserNameLen, &ds);
}
}
Tcl_SetVar2(interp, "tcl_platform", "user", Tcl_DStringValue(&ds),
TCL_GLOBAL_ONLY);
Tcl_DStringFree(&ds);
/*
* Define what the platform PATH separator is. [TIP #315]
*/
Tcl_SetVar2(interp, "tcl_platform","pathSeparator", ";", TCL_GLOBAL_ONLY);
//.........这里部分代码省略.........
开发者ID:lmiadowicz,项目名称:tcl,代码行数:101,代码来源:tclWinInit.c
示例10: GetSystemInfo
// static
int Thread::GetCPUCount()
{
SYSTEM_INFO sysInfo;
GetSystemInfo(&sysInfo);
return (int) sysInfo.dwNumberOfProcessors;
}
开发者ID:8BitRick,项目名称:GearVRNative,代码行数:7,代码来源:OVR_ThreadsWinAPI.cpp
示例11: ZeroMemory
/**
* Print out the Windows version information
* @return A string with the windows version, this needs to be free'd
*/
char *GetWindowsVersion(void)
{
OSVERSIONINFOEX osvi;
BOOL bOsVersionInfoEx;
char buf[BUFSIZE];
char *extra;
char *cputype;
SYSTEM_INFO si;
ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
ZeroMemory(&si, sizeof(SYSTEM_INFO));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
if (!(bOsVersionInfoEx = GetVersionEx((OSVERSIONINFO *) & osvi))) {
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
if (!GetVersionEx((OSVERSIONINFO *) & osvi)) {
return sstrdup("");
}
}
GetSystemInfo(&si);
/* Determine CPU type 32 or 64 */
if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) {
cputype = sstrdup(" 64-bit");
} else if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL) {
cputype = sstrdup(" 32-bit");
} else if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64) {
cputype = sstrdup(" Itanium 64-bit");
} else {
cputype = sstrdup(" ");
}
switch (osvi.dwPlatformId) {
/* test for the Windows NT product family. */
case VER_PLATFORM_WIN32_NT:
/* Windows Vista or Windows Server 2008 */
if (osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0) {
if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE) {
extra = sstrdup("Enterprise Edition");
} else if (osvi.wSuiteMask & VER_SUITE_DATACENTER) {
extra = sstrdup("Datacenter Edition");
} else if (osvi.wSuiteMask & VER_SUITE_PERSONAL) {
extra = sstrdup("Home Premium/Basic");
} else {
extra = sstrdup(" ");
}
if (osvi.wProductType & VER_NT_WORKSTATION) {
ircsnprintf(buf, sizeof(buf),
"Microsoft Windows Vista %s%s", cputype,
extra);
} else {
ircsnprintf(buf, sizeof(buf),
"Microsoft Windows Server 2008 %s%s", cputype,
extra);
}
free(extra);
}
/* Windows 2003 or Windows XP Pro 64 */
if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2) {
if (osvi.wSuiteMask & VER_SUITE_DATACENTER) {
extra = sstrdup("Datacenter Edition");
} else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE) {
extra = sstrdup("Enterprise Edition");
} else if (osvi.wSuiteMask & VER_SUITE_COMPUTE_SERVER) {
extra = sstrdup("Compute Cluster Edition");
} else if (osvi.wSuiteMask == VER_SUITE_BLADE) {
extra = sstrdup("Web Edition");
} else {
extra = sstrdup("Standard Edition");
}
if (osvi.wProductType & VER_NT_WORKSTATION
&& si.wProcessorArchitecture ==
PROCESSOR_ARCHITECTURE_AMD64) {
ircsnprintf(buf, sizeof(buf),
"Windows XP Professional x64 Edition %s",
extra);
} else {
ircsnprintf(buf, sizeof(buf),
"Microsoft Windows Server 2003 Family %s%s",
cputype, extra);
}
free(extra);
}
if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1) {
if (osvi.wSuiteMask & VER_SUITE_EMBEDDEDNT) {
extra = sstrdup("Embedded");
} else if (osvi.wSuiteMask & VER_SUITE_PERSONAL) {
extra = sstrdup("Home Edition");
#ifdef SM_MEDIACENTER
} else if (GetSystemMetrics(SM_MEDIACENTER)) {
extra = sstrdup("Media Center Edition");
#endif
#ifdef SM_TABLETPC
} else if (GetSystemMetrics(SM_TABLETPC)) {
extra = sstrdup("Tablet Edition");
#endif
//.........这里部分代码省略.........
开发者ID:danopia,项目名称:denora,代码行数:101,代码来源:win32.c
示例12: hg_proc_set_size
/*---------------------------------------------------------------------------*/
hg_return_t
hg_proc_set_size(hg_proc_t proc, hg_size_t req_buf_size)
{
struct hg_proc *hg_proc = (struct hg_proc *) proc;
hg_size_t new_buf_size;
hg_size_t page_size;
ptrdiff_t current_pos;
hg_return_t ret = HG_SUCCESS;
#ifdef _WIN32
SYSTEM_INFO system_info;
GetSystemInfo(&system_info);
page_size = system_info.dwPageSize;
#else
page_size = sysconf(_SC_PAGE_SIZE);
#endif
new_buf_size = ((hg_size_t)(req_buf_size / page_size) + 1) * page_size;
if (new_buf_size <= hg_proc_get_size(proc)) {
HG_LOG_ERROR("Buffer is already of the size requested");
ret = HG_SIZE_ERROR;
goto done;
}
/* If was not using extra buffer init extra buffer */
if (!hg_proc->extra_buf.buf) {
/* Save current position */
current_pos = (char *) hg_proc->proc_buf.buf_ptr -
(char *) hg_proc->proc_buf.buf;
/* Allocate buffer */
hg_proc->extra_buf.buf = malloc(new_buf_size);
if (!hg_proc->extra_buf.buf) {
HG_LOG_ERROR("Could not allocate buffer");
ret = HG_NOMEM_ERROR;
goto done;
}
/* Copy proc_buf (should be small) */
memcpy(hg_proc->extra_buf.buf, hg_proc->proc_buf.buf, current_pos);
hg_proc->extra_buf.size = new_buf_size;
hg_proc->extra_buf.buf_ptr = (char *) hg_proc->extra_buf.buf + current_pos;
hg_proc->extra_buf.size_left = hg_proc->extra_buf.size - current_pos;
hg_proc->extra_buf.is_mine = 1;
/* Switch buffer */
hg_proc->current_buf = &hg_proc->extra_buf;
} else {
void *new_buf = NULL;
/* Save current position */
current_pos = (char *) hg_proc->extra_buf.buf_ptr - (char *) hg_proc->extra_buf.buf;
/* Reallocate buffer */
new_buf = realloc(hg_proc->extra_buf.buf, new_buf_size);
if (!new_buf) {
HG_LOG_ERROR("Could not reallocate buffer");
ret = HG_NOMEM_ERROR;
goto done;
}
hg_proc->extra_buf.buf = new_buf;
hg_proc->extra_buf.size = new_buf_size;
hg_proc->extra_buf.buf_ptr = (char *) hg_proc->extra_buf.buf + current_pos;
hg_proc->extra_buf.size_left = hg_proc->extra_buf.size - current_pos;
}
done:
return ret;
}
开发者ID:jolivier23,项目名称:mercury,代码行数:70,代码来源:mercury_proc.c
示例13: GetSystemInfo
QString DiagnosticsDialog::getProcessor() const
{
SYSTEM_INFO sysinfo;
GetSystemInfo( &sysinfo );
return QString::number( sysinfo.dwProcessorType );
}
开发者ID:Krabi,项目名称:idkaart_public,代码行数:6,代码来源:DiagnosticsDialog_win.cpp
示例14: my_getpagesize
int my_getpagesize(void)
{
SYSTEM_INFO si;
GetSystemInfo(&si);
return si.dwPageSize;
}
开发者ID:4jb,项目名称:Trinity,代码行数:6,代码来源:my_getpagesize.c
示例15: uv_cpu_info
uv_err_t uv_cpu_info(uv_cpu_info_t** cpu_infos_ptr, int* cpu_count_ptr) {
uv_cpu_info_t* cpu_infos;
SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION* sppi;
DWORD sppi_size;
SYSTEM_INFO system_info;
DWORD cpu_count, r, i;
NTSTATUS status;
ULONG result_size;
uv_err_t err;
uv_cpu_info_t* cpu_info;
cpu_infos = NULL;
cpu_count = 0;
sppi = NULL;
GetSystemInfo(&system_info);
cpu_count = system_info.dwNumberOfProcessors;
cpu_infos = calloc(cpu_count, sizeof *cpu_infos);
if (cpu_infos == NULL) {
err = 0;
goto error;
}
sppi_size = cpu_count * sizeof(*sppi);
sppi = malloc(sppi_size);
if (sppi == NULL) {
err = 0;
goto error;
}
status = pNtQuerySystemInformation(SystemProcessorPerformanceInformation,
sppi,
sppi_size,
&result_size);
if (!NT_SUCCESS(status)) {
err = 0;
goto error;
}
assert(result_size == sppi_size);
for (i = 0; i < cpu_count; i++) {
WCHAR key_name[128];
HKEY processor_key;
DWORD cpu_speed;
DWORD cpu_speed_size = sizeof(cpu_speed);
WCHAR cpu_brand[256];
DWORD cpu_brand_size = sizeof(cpu_brand);
int len;
len = _snwprintf(key_name,
ARRAY_SIZE(key_name),
L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\%d",
i);
assert(len > 0 && len < ARRAY_SIZE(key_name));
r = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
key_name,
0,
KEY_QUERY_VALUE,
&processor_key);
if (r != ERROR_SUCCESS) {
err = 0;
goto error;
}
if (RegQueryValueExW(processor_key,
L"~MHz",
NULL,
NULL,
(BYTE*) &cpu_speed,
&cpu_speed_size) != ERROR_SUCCESS) {
err = 0;
RegCloseKey(processor_key);
goto error;
}
if (RegQueryValueExW(processor_key,
L"ProcessorNameString",
NULL,
NULL,
(BYTE*) &cpu_brand,
&cpu_brand_size) != ERROR_SUCCESS) {
err = 0;
RegCloseKey(processor_key);
goto error;
}
RegCloseKey(processor_key);
cpu_info = &cpu_infos[i];
cpu_info->speed = cpu_speed;
cpu_info->cpu_times.user = sppi[i].UserTime.QuadPart / 10000;
cpu_info->cpu_times.sys = (sppi[i].KernelTime.QuadPart -
sppi[i].IdleTime.QuadPart) / 10000;
cpu_info->cpu_times.idle = sppi[i].IdleTime.QuadPart / 10000;
cpu_info->cpu_times.irq = sppi[i].InterruptTime.QuadPart / 10000;
//.........这里部分代码省略.........
开发者ID:Garfield-Chen,项目名称:tng,代码行数:101,代码来源:util.c
示例16: _tmain
int _tmain(int /*argc*/, _TCHAR* /*argv*/[])
{
#ifdef _WIN64
_tprintf( _T("Platform : 64-bit\n") );
#else
_tprintf( _T("Platform : 32-bit\n") );
#endif
#ifdef _DEBUG
_tprintf( _T("Build : Debug\n") );
#else
_tprintf( _T("Build : Release\n") );
#endif
SYSTEM_INFO si = {};
GetSystemInfo( &si );
_tprintf( _T("CPUs : %u\n"), si.dwNumberOfProcessors );
_tprintf( _T("\nHashWord() function tests:\n\n") );
_tprintf( _T("Hash test 1... %s\n"),
( HashWord( L"\x30a2\x30cb\x30e1", 0, 3, 10 ) == 46 ) ? _T("OK") : _T("FAIL") );
_tprintf( _T("Hash test 2... %s\n"),
( HashWord( L"\x58f0\x512a", 0, 2, 10 ) == 731 ) ? _T("OK") : _T("FAIL") );
_tprintf( _T("Hash test 3... %s\n"),
( HashWord( L"\x0001\x0028", 0, 2, 10 ) == 658 ) ? _T("OK") : _T("FAIL") );
_tprintf( _T("Hash test 4... %s\n"),
( HashWord( L"\xff01\x9428", 0, 2, 10 ) == 658 ) ? _T("OK") : _T("FAIL") );
_tprintf( _T("Hash test 5... %s\n"),
( HashWord( L"\x0000", 0, 1, 10 ) == 0 ) ? _T("OK") : _T("FAIL") );
_tprintf( _T("Hash test 6... %s\n"),
( HashWord( L"\x0001", 0, 1, 10 ) == 316 ) ? _T("OK") : _T("FAIL") );
_tprintf( _T("Hash test 7... %s\n"),
( HashWord( L"0123456789", 0, 10, 10 ) == 551 ) ? _T("OK") : _T("FAIL") );
// No UTF-32 support for unmanaged C++
// _tprintf( _T("Hash test 8... %s\n"),
// ( HashWord( L"\x10400", 0, 1, 10 ) == 316 ) ? _T("OK") : _T("FAIL") );
// _tprintf( _T("Hash test 9... %s\n"),
// ( HashWord( L"\x10428", 0, 1, 10 ) == 658 ) ? _T("OK") : _T("FAIL") );
_tprintf( _T("\nMeasuring performance:\n\n") );
const int nCount = 10;
const __int64 nBlock = 100 * 1024 * 1024; // 100 MB
LPVOID pBuffer = VirtualAlloc( NULL, nBlock, MEM_COMMIT, PAGE_READWRITE );
memset( pBuffer, 'A', nBlock );
SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_HIGHEST );
{
__int64 nBest = -1, nError = 0, nFast = 0, n = 0;
do
{
__int64 nWorst = 0;
_tprintf( _T("HashWord : %I64d MB by "), nBlock / 1024 / 1024 );
DWORD foo;
for ( int i = 0; i < nCount; ++i )
{
const __int64 nBegin = GetMicroCount();
foo = HashWord( (LPCTSTR)pBuffer, 0, nBlock / sizeof( TCHAR ) - 1, 20 );
__int64 nTime = GetMicroCount() - nBegin;
if ( nBest < 0 || nTime < nBest )
nBest = nTime;
if ( i == 0 || nTime > nWorst )
nWorst = nTime;
if ( foo != 901120 )
{
_tprintf( _T("FAILED! ") );
break;
}
}
nError = ( 100 * ( nWorst - nBest ) ) / nWorst;
const __int64 nSpeed = ( nBlock * 1000000 ) / nBest;
if ( nFast < nSpeed )
nFast = nSpeed;
_tprintf( _T("%3I64d ms (inaccuracy %2I64d%%), %3I64d MB/s \r"),
nBest / 1000, nError, nFast / ( 1024 * 1024 ) );
} while ( nError > 5 && n++ < 10 );
}
_tprintf( _T("\n") );
{
__int64 nBest = -1, nError = 0, nFast = 0, n = 0;
do
{
__int64 nWorst = 0;
_tprintf( _T("MD4 hash: %I64d MB by "), nBlock / 1024 / 1024 );
for ( int i = 0; i < nCount; ++i )
{
const __int64 nBegin = GetMicroCount();
CMD4 pMD4;
pMD4.Add( pBuffer, nBlock );
pMD4.Finish();
__int64 nTime = GetMicroCount() - nBegin;
if ( nBest < 0 || nTime < nBest )
nBest = nTime;
if ( i == 0 || nTime > nWorst )
nWorst = nTime;
}
nError = ( 100 * ( nWorst - nBest ) ) / nWorst;
const __int64 nSpeed = ( nBlock * 1000000 ) / nBest;
//.........这里部分代码省略.........
开发者ID:GetEnvy,项目名称:Envy,代码行数:101,代码来源:HashTest.cpp
示例17: ngx_os_init
ngx_int_t
ngx_os_init(ngx_log_t *log)
{
DWORD bytes;
SOCKET s;
WSADATA wsd;
ngx_err_t err;
ngx_uint_t n;
SYSTEM_INFO si;
/* get Windows version */
ngx_memzero(&osvi, sizeof(OSVERSIONINFOEX));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
#ifdef _MSC_VER
#pragma warning(disable:4996)
#endif
osviex = GetVersionEx((OSVERSIONINFO *) &osvi);
if (osviex == 0)
{
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
if (GetVersionEx((OSVERSIONINFO *) &osvi) == 0)
{
ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
"GetVersionEx() failed");
return NGX_ERROR;
}
}
#ifdef _MSC_VER
#pragma warning(default:4996)
#endif
/*
* Windows 3.1 Win32s 0xxxxx
*
* Windows 95 140000
* Windows 98 141000
* Windows ME 149000
* Windows NT 3.51 235100
* Windows NT 4.0 240000
* Windows NT 4.0 SP5 240050
* Windows 2000 250000
* Windows XP 250100
* Windows 2003 250200
* Windows Vista/2008 260000
*
* Windows CE x.x 3xxxxx
*/
ngx_win32_version = osvi.dwPlatformId * 100000
+ osvi.dwMajorVersion * 10000
+ osvi.dwMinorVersion * 100;
if (osviex)
{
ngx_win32_version += osvi.wServicePackMajor * 10
+ osvi.wServicePackMinor;
}
GetSystemInfo(&si);
ngx_pagesize = si.dwPageSize;
ngx_allocation_granularity = si.dwAllocationGranularity;
ngx_ncpu = si.dwNumberOfProcessors;
ngx_cacheline_size = NGX_CPU_CACHE_LINE;
for (n = ngx_pagesize; n >>= 1; ngx_pagesize_shift++)
{
/* void */
}
/* delete default "C" locale for _wcsicmp() */
setlocale(LC_ALL, "");
/* init Winsock */
if (WSAStartup(MAKEWORD(2, 2), &wsd) != 0)
{
ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
"WSAStartup() failed");
return NGX_ERROR;
}
if (ngx_win32_version < NGX_WIN_NT)
{
ngx_max_wsabufs = 16;
return NGX_OK;
}
/* STUB: ngx_uint_t max */
ngx_max_wsabufs = 1024 * 1024;
/*
* get AcceptEx(), GetAcceptExSockAddrs(), TransmitFile(),
* TransmitPackets(), ConnectEx(), and DisconnectEx() addresses
*/
s = ngx_socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
if (s == (ngx_socket_t) - 1)
{
ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
ngx
|
请发表评论