PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Need help! Link error and code problem

I want to find CPU load on PPC, and I have found the following post finally.

http://www.tech-archive.net/Archive/Win ... /0504.html

I can't build it successly, and I don't know how to do.I really want to know how can measure CPU load on PDA, because My school homework project is the PDA CPU monitor. Please help me, thank you very much.

Code:

#include "windows.h"
#include "Tlhelp32.h"

void SumThreadTimes()
{
HANDLE hThreads = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
int newKernel =0;
int newUser =0;
if(hThreads)
{
THREADENTRY32 entry;
entry.dwSize = sizeof(THREADENTRY32);
BOOL more = Thread32First(hThreads, &entry;);
if(!more) return;

FILETIME creation, exit, kernel, user;
// add up times from all threads
while(more)
{
if(GetThreadTimes( (HANDLE) entry.th32ThreadID , &creation;,
&exit;, &kernel;, &user;)==0)
{ // HERE THE CALL RETURNS INVALID_HANDLE
break;
}
//try we LowBytes, High Bytes keep inchangeable most of the time
newKernel += kernel.dwLowDateTime;
newUser += user.dwLowDateTime;
entry.dwSize = sizeof(THREADENTRY32);
more = Thread32Next(hThreads, &entry;);
}
CloseToolhelp32Snapshot(hThreads);
}
}


build will make some error, like this
===================================================
corelibc.lib(pegwmain.obj) : error LNK2019: unresolved external symbol WinMain referenced in function WinMainCRTStartup
===================================================

I try change Entry-point symbol to "wWinMainCRTStartup", but there is still link error
===================================================
corelibc.lib(wwinmain.obj) : error LNK2019: unresolved external symbol wWinMain referenced in function wWinMainCRTStartup
===================================================

Can help me solve this problem? Thank you very much.
Aw, man, don't u see what linker told to you? You don't have a WinMain function in your project. Every windows application starts with WinMain! Try to read book about c++ windows programming, that will help!
DaGGeR wrote:Aw, man, don't u see what linker told to you? You don't have a WinMain function in your project. Every windows application starts with WinMain! Try to read book about c++ windows programming, that will help!


Code:

HINSTANCE h_Instance;

int APIENTRY WinMain(
HINSTANCE hInstance,
HINSTANCE hPrev,
LPTSTR lpCmd,
int nShow
)
{
HWND hwnd;
if (hwnd = FindWindow(NULL, L"CPU"))
{
SetFocus (hwnd);
return (TRUE);
}
h_Instance = hInstance;
return(FALSE);
}


Is it like that? It's *just* can build correctly, but I know that is wrong. Sorry for my fool question.

I don't know how to use w32 SDK write program, because I always use MFC. :(

Thank for your reply!

I need someone tech me how to do it next, if someone nice to teach noob in programming.