C/C++ Windows API

Moderators: Lundin
Number of threads: 443
Number of posts: 1215

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Derivation of the priority value in the window Posted by Abbath on 4 Jan 2011 at 11:15 AM
How can I withdraw the priority value in the window at me, he always brings to 32 for the process, and 0 for the flow of what went wrong?

TCHAR CommandLine[256] = _T("notepad ReadMe.txt");
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static STARTUPINFO tin;
static PROCESS_INFORMATION pInfo;
static DWORD exitCode;
PAINTSTRUCT ps;
HDC hdc;
TCHAR str[60], tmp[20];
int i, sum;
static LARGE_INTEGER frequency, Start, End;
static __int64 totalTime;
static DWORD thinf;
switch (message)
{
case WM_CREATE:
tin.cb = sizeof(STARTUPINFO);
tin.dwFlags = STARTF_USESHOWWINDOW;
tin.wShowWindow=SW_SHOWMINIMIZED;

break;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case ID_FILE_OPEN:
GetExitCodeProcess(pInfo.hProcess, &exitCode);
if (exitCode != STILL_ACTIVE)
{
CreateProcess(NULL, CommandLine,
NULL, NULL, FALSE, 0, NULL, NULL, &tin, &pInfo);
SetPriorityClass(GetCurrentThread(),HIGH_PRIORITY_CLASS);
// SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_ABOVE_NORMAL);
//thinf=GetThreadPriority(GetCurrentThread());

thinf=GetPriorityClass(GetCurrentProcess());
QueryPerformanceFrequency(&frequency);
QueryPerformanceCounter(&Start);

}
break;
case ID_FILE_DELETE:
GetExitCodeProcess(pInfo.hProcess, &exitCode);
if (exitCode==STILL_ACTIVE)
{
TerminateProcess(pInfo.hProcess, 0);
QueryPerformanceCounter(&End);
totalTime = (End.QuadPart - Start.QuadPart)*1000/
frequency.QuadPart;
InvalidateRect(hWnd, NULL, TRUE);
}
break;
case IDM_EXIT: DestroyWindow(hWnd); break;
default: return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
_tcscpy(str, _T("Время работы цикла в мс: "));
_i64tot(totalTime, tmp, 10);
_tcscat(str, tmp);
TextOut(hdc, 0, 0, str, _tcslen(str));

_i64tot(thinf, str, 10);
TextOut(hdc, 0, 20, str, _tcslen(str));
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default: return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.