<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[CPU-Auslastungsanzeige von Konsole in Borland Builder Form wandeln]]></title><description><![CDATA[<p>Moin moin,<br />
ich habe mit Hilfe eines fremden Quelltextes zum Ermitteln der CPU-Auslastung ein kleines Konsolenprogramm erstellt, dass die Auslastung in einer kleinen &quot;Fortschritts&quot;-Anzeige darstellt. Soweit, so gut, doch nun möchte ich das ganze gerne als richtige Windows-Anwendung mit dem Borland C++ Builder machen (sieht einfach schöner aus).<br />
Doch wenn ich den Quelltext der Konsolenversion in den eines solchen, neuen Formulars reinkopiere, bekomme ich Fehler in der &quot;dde.h&quot; in der Zeile 19 mit &quot;extern &quot;C&quot; {&quot;, nämlich &quot;Linkage specification not allowed&quot; und &quot;Declaration terminated incorrectly&quot;. Dabei habe ich an der Datei garnichts gemacht..?</p>
<p>Wo liegt da der Fehler, was muss ich ändern? Oder gibt es sonst eine andere Möglichkeit, den Wert der Auslastung (hier iProzent) in einem Formular zu nutzen?</p>
<p>Hier die Codes:<br />
<strong>CpuLoad.h</strong></p>
<pre><code class="language-cpp">//*****************************************************************************
//*
//*
//*		CpuLoad.h
//*
//*
//*****************************************************************************
#ifndef 	__CPULOAD_H__
#define 	__CPULOAD_H__

	int CpuInit();					// Initialisierung
	int CpuExit();					// Deinitialisierung
	int CpuCount();					// CPU-Anzahl abfragen
	int CpuUpdate();				// CPU-Auslastungsdaten hollen
	int CpuLoad(unsigned uCpu);		// CPU-Auslastungs für eine CPU abfragen

#endif
</code></pre>
<p><strong>und der eigentliche Code Projekt.cpp</strong></p>
<pre><code class="language-cpp">//---------------------------------------------------------------------------
#include &lt;vcl\vcl.h&gt;
#pragma hdrstop
#include [iostream.h]
#include [conio.h]
#include &quot;Unit2.h&quot;
//---------------------------------------------------------------------------
#pragma resource &quot;*.dfm&quot;
TDataModule2 *DataModule2;
//---------------------------------------------------------------------------
__fastcall TDataModule2::TDataModule2(TComponent* Owner)
	: TDataModule(Owner)
{

//*****************************************************************************
//*
//*
//*		CpuLoad.cpp
//*
//*
//*****************************************************************************
#include	&lt;windows.h&gt;
#include	&quot;CpuLoad.h&quot;

#define	PROCESSOR_IDX	238
#define CPU_USAGE_IDX	6

static	HKEY		 hWin9xKey    = 0;
static	BOOL		 bIsWinNt	  = 0;
static	DWORD		 dwDataSize   = 0;
static	DWORD		 dwWin9xUsage = 0;
static	__int64		*pCounterAct  = 0;
static	__int64		*pCounterPre  = 0;
static	__int64		 iSysTimeAct  = 1;
static	__int64		 iSysTimePre  = 0;
static	unsigned	 uCpuCount    = 0;
static	union
		{
		PERF_DATA_BLOCK			*o;
		BYTE					*b;
		}pData;

//*****************************************************************************
//*
//*		CpuUpdate
//*
//*****************************************************************************
//	Hollt die neuesten Daten für die CPU-Auslastung
//	Ergibt 1 wenn ok sonst 0
int CpuUpdate()
{
DWORD				 dwSize,dwType;
int					 iError;
unsigned			 u;
union
	{
	PERF_OBJECT_TYPE		*o;
	BYTE					*b;
	}pType;
union
	{
	PERF_COUNTER_DEFINITION	*o;
	BYTE					*b;
	}pCounter;
union
	{
	PERF_INSTANCE_DEFINITION*o;
	BYTE					*b;
	}pInstance;
union
	{
	PERF_COUNTER_BLOCK		*o;
	BYTE					*b;
	}pBlock;

//******************** Win 98 *************************************************

	if(!bIsWinNt)
		{
		if(!hWin9xKey)
			{
			HKEY	hKey;

			iError=RegOpenKeyEx(HKEY_DYN_DATA,&quot;PerfStats\\StartStat&quot;,0,KEY_ALL_ACCESS,&amp;hKey);

			if(iError!=ERROR_SUCCESS){hWin9xKey=0;return 0;}

			dwSize=sizeof(DWORD);

			RegQueryValueEx(hKey,&quot;KERNEL\\CPUUsage&quot;,0,&amp;dwType,(LPBYTE)&amp;dwWin9xUsage, &amp;dwSize);
			RegCloseKey(hKey);

			iError=RegOpenKeyEx( HKEY_DYN_DATA,&quot;PerfStats\\StatData&quot;,0,KEY_READ,&amp;hWin9xKey);

			if(iError!=ERROR_SUCCESS){hWin9xKey=0;return 0;}
			if(!uCpuCount)uCpuCount=1;
			}

		dwSize=sizeof(DWORD);
        RegQueryValueEx(hWin9xKey,&quot;KERNEL\\CPUUsage&quot;,0,&amp;dwType,(LPBYTE)&amp;dwWin9xUsage,&amp;dwSize);

		return 1;
		}

//******************** Win NT *************************************************

	while(1)
		{
		dwSize=dwDataSize;
		iError=RegQueryValueEx( HKEY_PERFORMANCE_DATA, &quot;238&quot;, 0, 0,pData.b,&amp;dwSize);
		if(iError!=ERROR_MORE_DATA)break;
		dwDataSize+=256;
		if(pData.o)delete pData.o;
		pData.b=new BYTE[dwDataSize];
		}

	if(iError!=ERROR_SUCCESS || !pData.o)
		{
		if(pData.o)delete pData.o;
		return 0;
		}

	pType.b = ((BYTE*)pData.o)+pData.o-&gt;HeaderLength;

	for(u=0;u&lt;pData.o-&gt;NumObjectTypes;u++)
		{
		if(pType.o-&gt;ObjectNameTitleIndex==PROCESSOR_IDX)break;
		pType.o += pType.o-&gt;TotalByteLength;
		}

	if(u&gt;=pData.o-&gt;NumObjectTypes)
		{
		delete pData.o;
		return 0;
		}

	if(!uCpuCount &amp;&amp; pType.o-&gt;NumInstances&gt;(int)uCpuCount)
		{
		uCpuCount = pType.o-&gt;NumInstances;
		pCounterAct  = new __int64[uCpuCount*2];
		pCounterPre = pCounterAct+uCpuCount;
		}

	pCounter.b = pType.b + pType.o-&gt;HeaderLength;

	for(u=1;u&lt;pType.o-&gt;NumCounters;u++)
		{
		if(pCounter.o-&gt;CounterNameTitleIndex == CPU_USAGE_IDX)break;
		pCounter.b += pCounter.o-&gt;ByteLength;
		}

	if(u&gt;=pType.o-&gt;NumCounters)
		{
		delete pData.o;
		return 0;
		}

	pInstance.b = pType.b + pType.o-&gt;DefinitionLength;

	for(u = 0; (int)u&lt;pType.o-&gt;NumInstances ; u++)
		{
		pBlock.b = pInstance.b + pInstance.o-&gt;ByteLength;

		pCounterPre[u]=pCounterAct[u];
		pCounterAct [u]=*(__int64*)(pBlock.b + pCounter.o-&gt;CounterOffset);
		pInstance.b = pBlock.b + pBlock.o-&gt;ByteLength;
		}

	iSysTimePre = iSysTimeAct;
	SystemTimeToFileTime(&amp;pData.o-&gt;SystemTime,(LPFILETIME)&amp;iSysTimeAct);
	if(iSysTimePre == iSysTimeAct)iSysTimeAct++;

return 1;
}

//*****************************************************************************
//*
//*		CpuInit
//*
//*****************************************************************************
//	Initialisiert die CPU-Auslastungsberechnung
//	Ergibt 1 wenn ok sonst 0
int CpuInit()
{
DWORD	dwVersion;

	dwVersion=GetVersion();
	dwVersion=((dwVersion&amp;0xFF00)&gt;&gt;8) | ((dwVersion&amp;0x00FF)&lt;&lt;8);

	if(dwVersion&gt;=0x0500 || dwVersion==0x0400 || dwVersion==0x0300)bIsWinNt=TRUE;

	if(!CpuUpdate())return 0;

return 1;
}

//*****************************************************************************
//*
//*		CpuExit
//*
//*****************************************************************************
//	Gibt alle Speicherbereiche wieder frei
//	Ergibt 1 wenn ok sonst 0
int CpuExit()
{

	dwDataSize = 0;
	uCpuCount  = 0;

	if(pCounterAct){delete pCounterAct;pCounterAct = 0;pCounterPre = 0;}
	if(pData.b    ){delete pData.b    ;pData.b     = 0;}
	if(hWin9xKey  )
		{
		int		iError;
		HKEY	hKey;
		DWORD	dwSize,dwType;

		RegCloseKey(hWin9xKey);
		hWin9xKey = 0;

	    iError=RegOpenKeyEx(HKEY_DYN_DATA,&quot;PerfStats\\StopStat&quot;,0,KEY_ALL_ACCESS,&amp;hKey);
		if(iError!=ERROR_SUCCESS)return 0;

		dwSize=sizeof(DWORD);

		RegQueryValueEx(hKey,&quot;KERNEL\\CPUUsage&quot;,0,&amp;dwType,(LPBYTE)&amp;dwWin9xUsage,&amp;dwSize);
		RegCloseKey(hKey);
		}

return 1;
}

//*****************************************************************************
//*
//*		CpuLoad
//*
//*****************************************************************************
//	Ergibt die aktuelle CPU-Auslastung (0 bis 1024)
//
//	uCpu	: Ist die Nummer der CPU
//
//	Danmit das funktioniert muss zuvor eine Zeit gewartet werden
//	und CpuUpdate aufgerufen werden
//	z.B.	Sleep(1000);
//			CpuUpdate();
//			CpuLoad(0);
//			CpuLoad(1);
//			...
int CpuLoad(unsigned uCpu)
{
__int64	iValue;
int		iLoad;

	if(uCpu&gt;=uCpuCount)return -1;

	if(!bIsWinNt)									// Windows 95/98
		{
		if(!hWin9xKey)return -1;
        iLoad = (dwWin9xUsage&lt;&lt;10) / 100;
		}
	else{											// Windows NT/2000/XP
		iValue   = pCounterAct[uCpu]-pCounterPre[uCpu];
		iValue &lt;&lt;= 10;
		iValue  /= iSysTimeAct-iSysTimePre;

		iLoad    = 1024-(int)iValue;
		}

	if(iLoad&lt;   0)iLoad=0;
	if(iLoad&gt;1024)iLoad=1024;

return iLoad;
}

//*****************************************************************************
//*
//*		CpuCount
//*
//*****************************************************************************
//	Gibt die Anzah aller CPU's
int CpuCount()
{
SYSTEM_INFO		sInfo;

	if(!uCpuCount)CpuInit();

	GetSystemInfo(&amp;sInfo);
	if(uCpuCount&lt;sInfo.dwNumberOfProcessors)return uCpuCount;

return sInfo.dwNumberOfProcessors;
}
//-------------------------------
//-------------------------------
//-------------------------------

}
int main()
{
int	i,iProzent,iCpuCount;

	CpuInit();
	iCpuCount=CpuCount();

	while(1)
		{

        char auslast[10];
            auslast[0]=32;
            auslast[1]=32;
            auslast[2]=32;
            auslast[3]=32;
            auslast[4]=32;
            auslast[5]=32;
            auslast[6]=32;
            auslast[7]=32;
            auslast[8]=32;
            auslast[9]=32;

		for(i=0;i&lt;iCpuCount;i++)		// CPU Daten ausgeben
        	{
            clrscr();
			CpuUpdate();
			iProzent=(CpuLoad(i)*100)&gt;&gt;10;

            if (iProzent&gt;-1)auslast[0]=79; else (auslast[0]=32);
            if (iProzent&gt;10)auslast[1]=79; else (auslast[1]=32);
            if (iProzent&gt;20)auslast[2]=79; else (auslast[2]=32);
            if (iProzent&gt;30)auslast[3]=79; else (auslast[3]=32);
            if (iProzent&gt;40)auslast[4]=79; else (auslast[4]=32);
            if (iProzent&gt;50)auslast[5]=79; else (auslast[5]=32);
            if (iProzent&gt;60)auslast[6]=79; else (auslast[6]=32);
            if (iProzent&gt;70)auslast[7]=79; else (auslast[7]=32);
            if (iProzent&gt;80)auslast[8]=79; else (auslast[8]=32);
            if (iProzent&gt;90)auslast[9]=79; else (auslast[9]=32);

            cout&lt;&lt;&quot; -------------------&quot; &lt;&lt;endl;
            cout&lt;&lt;&quot;|&quot;;cout&lt;&lt;auslast[0];cout&lt;&lt;&quot;|&quot;;
            cout&lt;&lt;auslast[1];cout&lt;&lt;&quot;|&quot;;
            cout&lt;&lt;auslast[2];cout&lt;&lt;&quot;|&quot;;
            cout&lt;&lt;auslast[3];cout&lt;&lt;&quot;|&quot;;
            cout&lt;&lt;auslast[4];cout&lt;&lt;&quot;|&quot;;
            cout&lt;&lt;auslast[5];cout&lt;&lt;&quot;|&quot;;
            cout&lt;&lt;auslast[6];cout&lt;&lt;&quot;|&quot;;
            cout&lt;&lt;auslast[7];cout&lt;&lt;&quot;|&quot;;
            cout&lt;&lt;auslast[8];cout&lt;&lt;&quot;|&quot;;
            cout&lt;&lt;auslast[9];cout&lt;&lt;&quot;|&quot;;cout&lt;&lt;endl;
     		cout&lt;&lt;&quot; -------------------&quot; &lt;&lt;endl;

            Sleep(150);
            }
}

	CpuExit();

return 0;
}
</code></pre>
<p>Es wär super, wenn mir da jemand die passende Antwort geben könnte!</p>
<p>Vielen Dank und mfG,<br />
Morinho</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/125161/cpu-auslastungsanzeige-von-konsole-in-borland-builder-form-wandeln</link><generator>RSS for Node</generator><lastBuildDate>Tue, 28 Jul 2026 01:28:10 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/125161.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 04 Nov 2005 00:01:22 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to CPU-Auslastungsanzeige von Konsole in Borland Builder Form wandeln on Fri, 04 Nov 2005 00:02:36 GMT]]></title><description><![CDATA[<p>Moin moin,<br />
ich habe mit Hilfe eines fremden Quelltextes zum Ermitteln der CPU-Auslastung ein kleines Konsolenprogramm erstellt, dass die Auslastung in einer kleinen &quot;Fortschritts&quot;-Anzeige darstellt. Soweit, so gut, doch nun möchte ich das ganze gerne als richtige Windows-Anwendung mit dem Borland C++ Builder machen (sieht einfach schöner aus).<br />
Doch wenn ich den Quelltext der Konsolenversion in den eines solchen, neuen Formulars reinkopiere, bekomme ich Fehler in der &quot;dde.h&quot; in der Zeile 19 mit &quot;extern &quot;C&quot; {&quot;, nämlich &quot;Linkage specification not allowed&quot; und &quot;Declaration terminated incorrectly&quot;. Dabei habe ich an der Datei garnichts gemacht..?</p>
<p>Wo liegt da der Fehler, was muss ich ändern? Oder gibt es sonst eine andere Möglichkeit, den Wert der Auslastung (hier iProzent) in einem Formular zu nutzen?</p>
<p>Hier die Codes:<br />
<strong>CpuLoad.h</strong></p>
<pre><code class="language-cpp">//*****************************************************************************
//*
//*
//*		CpuLoad.h
//*
//*
//*****************************************************************************
#ifndef 	__CPULOAD_H__
#define 	__CPULOAD_H__

	int CpuInit();					// Initialisierung
	int CpuExit();					// Deinitialisierung
	int CpuCount();					// CPU-Anzahl abfragen
	int CpuUpdate();				// CPU-Auslastungsdaten hollen
	int CpuLoad(unsigned uCpu);		// CPU-Auslastungs für eine CPU abfragen

#endif
</code></pre>
<p><strong>und der eigentliche Code Projekt.cpp</strong></p>
<pre><code class="language-cpp">//---------------------------------------------------------------------------
#include &lt;vcl\vcl.h&gt;
#pragma hdrstop
#include [iostream.h]
#include [conio.h]
#include &quot;Unit2.h&quot;
//---------------------------------------------------------------------------
#pragma resource &quot;*.dfm&quot;
TDataModule2 *DataModule2;
//---------------------------------------------------------------------------
__fastcall TDataModule2::TDataModule2(TComponent* Owner)
	: TDataModule(Owner)
{

//*****************************************************************************
//*
//*
//*		CpuLoad.cpp
//*
//*
//*****************************************************************************
#include	&lt;windows.h&gt;
#include	&quot;CpuLoad.h&quot;

#define	PROCESSOR_IDX	238
#define CPU_USAGE_IDX	6

static	HKEY		 hWin9xKey    = 0;
static	BOOL		 bIsWinNt	  = 0;
static	DWORD		 dwDataSize   = 0;
static	DWORD		 dwWin9xUsage = 0;
static	__int64		*pCounterAct  = 0;
static	__int64		*pCounterPre  = 0;
static	__int64		 iSysTimeAct  = 1;
static	__int64		 iSysTimePre  = 0;
static	unsigned	 uCpuCount    = 0;
static	union
		{
		PERF_DATA_BLOCK			*o;
		BYTE					*b;
		}pData;

//*****************************************************************************
//*
//*		CpuUpdate
//*
//*****************************************************************************
//	Hollt die neuesten Daten für die CPU-Auslastung
//	Ergibt 1 wenn ok sonst 0
int CpuUpdate()
{
DWORD				 dwSize,dwType;
int					 iError;
unsigned			 u;
union
	{
	PERF_OBJECT_TYPE		*o;
	BYTE					*b;
	}pType;
union
	{
	PERF_COUNTER_DEFINITION	*o;
	BYTE					*b;
	}pCounter;
union
	{
	PERF_INSTANCE_DEFINITION*o;
	BYTE					*b;
	}pInstance;
union
	{
	PERF_COUNTER_BLOCK		*o;
	BYTE					*b;
	}pBlock;

//******************** Win 98 *************************************************

	if(!bIsWinNt)
		{
		if(!hWin9xKey)
			{
			HKEY	hKey;

			iError=RegOpenKeyEx(HKEY_DYN_DATA,&quot;PerfStats\\StartStat&quot;,0,KEY_ALL_ACCESS,&amp;hKey);

			if(iError!=ERROR_SUCCESS){hWin9xKey=0;return 0;}

			dwSize=sizeof(DWORD);

			RegQueryValueEx(hKey,&quot;KERNEL\\CPUUsage&quot;,0,&amp;dwType,(LPBYTE)&amp;dwWin9xUsage, &amp;dwSize);
			RegCloseKey(hKey);

			iError=RegOpenKeyEx( HKEY_DYN_DATA,&quot;PerfStats\\StatData&quot;,0,KEY_READ,&amp;hWin9xKey);

			if(iError!=ERROR_SUCCESS){hWin9xKey=0;return 0;}
			if(!uCpuCount)uCpuCount=1;
			}

		dwSize=sizeof(DWORD);
        RegQueryValueEx(hWin9xKey,&quot;KERNEL\\CPUUsage&quot;,0,&amp;dwType,(LPBYTE)&amp;dwWin9xUsage,&amp;dwSize);

		return 1;
		}

//******************** Win NT *************************************************

	while(1)
		{
		dwSize=dwDataSize;
		iError=RegQueryValueEx( HKEY_PERFORMANCE_DATA, &quot;238&quot;, 0, 0,pData.b,&amp;dwSize);
		if(iError!=ERROR_MORE_DATA)break;
		dwDataSize+=256;
		if(pData.o)delete pData.o;
		pData.b=new BYTE[dwDataSize];
		}

	if(iError!=ERROR_SUCCESS || !pData.o)
		{
		if(pData.o)delete pData.o;
		return 0;
		}

	pType.b = ((BYTE*)pData.o)+pData.o-&gt;HeaderLength;

	for(u=0;u&lt;pData.o-&gt;NumObjectTypes;u++)
		{
		if(pType.o-&gt;ObjectNameTitleIndex==PROCESSOR_IDX)break;
		pType.o += pType.o-&gt;TotalByteLength;
		}

	if(u&gt;=pData.o-&gt;NumObjectTypes)
		{
		delete pData.o;
		return 0;
		}

	if(!uCpuCount &amp;&amp; pType.o-&gt;NumInstances&gt;(int)uCpuCount)
		{
		uCpuCount = pType.o-&gt;NumInstances;
		pCounterAct  = new __int64[uCpuCount*2];
		pCounterPre = pCounterAct+uCpuCount;
		}

	pCounter.b = pType.b + pType.o-&gt;HeaderLength;

	for(u=1;u&lt;pType.o-&gt;NumCounters;u++)
		{
		if(pCounter.o-&gt;CounterNameTitleIndex == CPU_USAGE_IDX)break;
		pCounter.b += pCounter.o-&gt;ByteLength;
		}

	if(u&gt;=pType.o-&gt;NumCounters)
		{
		delete pData.o;
		return 0;
		}

	pInstance.b = pType.b + pType.o-&gt;DefinitionLength;

	for(u = 0; (int)u&lt;pType.o-&gt;NumInstances ; u++)
		{
		pBlock.b = pInstance.b + pInstance.o-&gt;ByteLength;

		pCounterPre[u]=pCounterAct[u];
		pCounterAct [u]=*(__int64*)(pBlock.b + pCounter.o-&gt;CounterOffset);
		pInstance.b = pBlock.b + pBlock.o-&gt;ByteLength;
		}

	iSysTimePre = iSysTimeAct;
	SystemTimeToFileTime(&amp;pData.o-&gt;SystemTime,(LPFILETIME)&amp;iSysTimeAct);
	if(iSysTimePre == iSysTimeAct)iSysTimeAct++;

return 1;
}

//*****************************************************************************
//*
//*		CpuInit
//*
//*****************************************************************************
//	Initialisiert die CPU-Auslastungsberechnung
//	Ergibt 1 wenn ok sonst 0
int CpuInit()
{
DWORD	dwVersion;

	dwVersion=GetVersion();
	dwVersion=((dwVersion&amp;0xFF00)&gt;&gt;8) | ((dwVersion&amp;0x00FF)&lt;&lt;8);

	if(dwVersion&gt;=0x0500 || dwVersion==0x0400 || dwVersion==0x0300)bIsWinNt=TRUE;

	if(!CpuUpdate())return 0;

return 1;
}

//*****************************************************************************
//*
//*		CpuExit
//*
//*****************************************************************************
//	Gibt alle Speicherbereiche wieder frei
//	Ergibt 1 wenn ok sonst 0
int CpuExit()
{

	dwDataSize = 0;
	uCpuCount  = 0;

	if(pCounterAct){delete pCounterAct;pCounterAct = 0;pCounterPre = 0;}
	if(pData.b    ){delete pData.b    ;pData.b     = 0;}
	if(hWin9xKey  )
		{
		int		iError;
		HKEY	hKey;
		DWORD	dwSize,dwType;

		RegCloseKey(hWin9xKey);
		hWin9xKey = 0;

	    iError=RegOpenKeyEx(HKEY_DYN_DATA,&quot;PerfStats\\StopStat&quot;,0,KEY_ALL_ACCESS,&amp;hKey);
		if(iError!=ERROR_SUCCESS)return 0;

		dwSize=sizeof(DWORD);

		RegQueryValueEx(hKey,&quot;KERNEL\\CPUUsage&quot;,0,&amp;dwType,(LPBYTE)&amp;dwWin9xUsage,&amp;dwSize);
		RegCloseKey(hKey);
		}

return 1;
}

//*****************************************************************************
//*
//*		CpuLoad
//*
//*****************************************************************************
//	Ergibt die aktuelle CPU-Auslastung (0 bis 1024)
//
//	uCpu	: Ist die Nummer der CPU
//
//	Danmit das funktioniert muss zuvor eine Zeit gewartet werden
//	und CpuUpdate aufgerufen werden
//	z.B.	Sleep(1000);
//			CpuUpdate();
//			CpuLoad(0);
//			CpuLoad(1);
//			...
int CpuLoad(unsigned uCpu)
{
__int64	iValue;
int		iLoad;

	if(uCpu&gt;=uCpuCount)return -1;

	if(!bIsWinNt)									// Windows 95/98
		{
		if(!hWin9xKey)return -1;
        iLoad = (dwWin9xUsage&lt;&lt;10) / 100;
		}
	else{											// Windows NT/2000/XP
		iValue   = pCounterAct[uCpu]-pCounterPre[uCpu];
		iValue &lt;&lt;= 10;
		iValue  /= iSysTimeAct-iSysTimePre;

		iLoad    = 1024-(int)iValue;
		}

	if(iLoad&lt;   0)iLoad=0;
	if(iLoad&gt;1024)iLoad=1024;

return iLoad;
}

//*****************************************************************************
//*
//*		CpuCount
//*
//*****************************************************************************
//	Gibt die Anzah aller CPU's
int CpuCount()
{
SYSTEM_INFO		sInfo;

	if(!uCpuCount)CpuInit();

	GetSystemInfo(&amp;sInfo);
	if(uCpuCount&lt;sInfo.dwNumberOfProcessors)return uCpuCount;

return sInfo.dwNumberOfProcessors;
}
//-------------------------------
//-------------------------------
//-------------------------------

}
int main()
{
int	i,iProzent,iCpuCount;

	CpuInit();
	iCpuCount=CpuCount();

	while(1)
		{

        char auslast[10];
            auslast[0]=32;
            auslast[1]=32;
            auslast[2]=32;
            auslast[3]=32;
            auslast[4]=32;
            auslast[5]=32;
            auslast[6]=32;
            auslast[7]=32;
            auslast[8]=32;
            auslast[9]=32;

		for(i=0;i&lt;iCpuCount;i++)		// CPU Daten ausgeben
        	{
            clrscr();
			CpuUpdate();
			iProzent=(CpuLoad(i)*100)&gt;&gt;10;

            if (iProzent&gt;-1)auslast[0]=79; else (auslast[0]=32);
            if (iProzent&gt;10)auslast[1]=79; else (auslast[1]=32);
            if (iProzent&gt;20)auslast[2]=79; else (auslast[2]=32);
            if (iProzent&gt;30)auslast[3]=79; else (auslast[3]=32);
            if (iProzent&gt;40)auslast[4]=79; else (auslast[4]=32);
            if (iProzent&gt;50)auslast[5]=79; else (auslast[5]=32);
            if (iProzent&gt;60)auslast[6]=79; else (auslast[6]=32);
            if (iProzent&gt;70)auslast[7]=79; else (auslast[7]=32);
            if (iProzent&gt;80)auslast[8]=79; else (auslast[8]=32);
            if (iProzent&gt;90)auslast[9]=79; else (auslast[9]=32);

            cout&lt;&lt;&quot; -------------------&quot; &lt;&lt;endl;
            cout&lt;&lt;&quot;|&quot;;cout&lt;&lt;auslast[0];cout&lt;&lt;&quot;|&quot;;
            cout&lt;&lt;auslast[1];cout&lt;&lt;&quot;|&quot;;
            cout&lt;&lt;auslast[2];cout&lt;&lt;&quot;|&quot;;
            cout&lt;&lt;auslast[3];cout&lt;&lt;&quot;|&quot;;
            cout&lt;&lt;auslast[4];cout&lt;&lt;&quot;|&quot;;
            cout&lt;&lt;auslast[5];cout&lt;&lt;&quot;|&quot;;
            cout&lt;&lt;auslast[6];cout&lt;&lt;&quot;|&quot;;
            cout&lt;&lt;auslast[7];cout&lt;&lt;&quot;|&quot;;
            cout&lt;&lt;auslast[8];cout&lt;&lt;&quot;|&quot;;
            cout&lt;&lt;auslast[9];cout&lt;&lt;&quot;|&quot;;cout&lt;&lt;endl;
     		cout&lt;&lt;&quot; -------------------&quot; &lt;&lt;endl;

            Sleep(150);
            }
}

	CpuExit();

return 0;
}
</code></pre>
<p>Es wär super, wenn mir da jemand die passende Antwort geben könnte!</p>
<p>Vielen Dank und mfG,<br />
Morinho</p>
]]></description><link>https://www.c-plusplus.net/forum/post/907759</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/907759</guid><dc:creator><![CDATA[Morinho]]></dc:creator><pubDate>Fri, 04 Nov 2005 00:02:36 GMT</pubDate></item><item><title><![CDATA[Reply to CPU-Auslastungsanzeige von Konsole in Borland Builder Form wandeln on Fri, 04 Nov 2005 05:59:49 GMT]]></title><description><![CDATA[<p>Frag mal lieber im (WinApi) oder VCL Forum nach!!!</p>
<p>Da musst du dann mit Controlls (Buttons, Eingabefelder ...) arbeiten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/907767</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/907767</guid><dc:creator><![CDATA[Tc++H]]></dc:creator><pubDate>Fri, 04 Nov 2005 05:59:49 GMT</pubDate></item><item><title><![CDATA[Reply to CPU-Auslastungsanzeige von Konsole in Borland Builder Form wandeln on Fri, 04 Nov 2005 07:16:07 GMT]]></title><description><![CDATA[<p>Dieser Thread wurde von Moderator/in <a href="http://www.c-plusplus.net/forum/profile.php?mode=viewprofile&amp;u=403" rel="nofollow">HumeSikkins</a> aus dem Forum <a href="http://www.c-plusplus.net/forum/viewforum.php?f=15" rel="nofollow">C++</a> in das Forum <a href="http://www.c-plusplus.net/forum/viewforum.php?f=2" rel="nofollow">VCL/CLX (Borland C++ Builder)</a> verschoben.</p>
<p>Im Zweifelsfall bitte auch folgende Hinweise beachten:<br />
<a href="http://www.c-plusplus.net/forum/viewtopic.php?t=39405" rel="nofollow">C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?</a></p>
<p><em>Dieses Posting wurde automatisch erzeugt.</em></p>
]]></description><link>https://www.c-plusplus.net/forum/post/907788</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/907788</guid><dc:creator><![CDATA[C++ Forumbot]]></dc:creator><pubDate>Fri, 04 Nov 2005 07:16:07 GMT</pubDate></item><item><title><![CDATA[Reply to CPU-Auslastungsanzeige von Konsole in Borland Builder Form wandeln on Fri, 04 Nov 2005 10:56:11 GMT]]></title><description><![CDATA[<p>Hallo</p>
<blockquote>
<p>Doch wenn ich den Quelltext der Konsolenversion in den eines solchen, neuen Formulars reinkopiere, bekomme ich Fehler in der &quot;dde.h&quot; in der Zeile 19 mit &quot;extern &quot;C&quot; {&quot;, nämlich &quot;Linkage specification not allowed&quot; und &quot;Declaration terminated incorrectly&quot;. Dabei habe ich an der Datei garnichts gemacht..?</p>
</blockquote>
<p>Konsolenprogramm haben einen fundamental anderes Konzept als (VCL-) GUI-Anwendungen. Villeicht fängst du erstmal an, dich mit der VCL zu beschäftigen.</p>
<p>Mir fällt auf dem ersten Blick schonb mal das auf</p>
<pre><code class="language-cpp">#include [iostream.h]
#include [conio.h]
</code></pre>
<p>das muß auf jeden fall so aussehen</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;conio.h&gt;
</code></pre>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/908018</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/908018</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Fri, 04 Nov 2005 10:56:11 GMT</pubDate></item></channel></rss>