winapi

Memory (and other resources) used by individual VirtualAlloc allocation

How much memory or other resources is used for an individual VirtualAlloc (xxxx, yyy, MEM_RESERVE, zzz)? Is there any difference in resource consumption (e.g. kernel paged/nonpaged pool) when I allocated one large block, like this: VirtualAlloc( xxxx, 1024*1024, MEM_RESERVE, PAGE_READWRITE ) or multiple smaller blocks, like this: Vi...

Can anyone decipher why these two conversions to unsigned long long give different results?

LARGE_INTEGER lpPerformanceCount, lpFrequency; QueryPerformanceCounter(&lpPerformanceCount); QueryPerformanceFrequency(&lpFrequency); (Count.QuadPart is a long long showing a CPU count) (Freq.QuadPart is a long long showing frequency of Count for a second) Attempting to print microseconds in real time. stable output: printf("%llu\...

how to show text an d icon on button in win 32 c++?

I wanted to get both icon and text, so I didn't set BM_ICON on my button. In WM_INITDIALOG (yes, the button is in a dialog) I say: SendDlgItemMessage(hwndDlg, IDC_CREATE, BM_SETIMAGE, IMAGE_ICON, reinterpret_cast<LPARAM>(create_image)); It doesn't work. The button shows text only. Now, if I do set the BS_ICON style, it works, but ther...

How do I determine the remote endpoint a UDP packet originates from?

The socket is created and bound, then the program receives data with recv(). The question is: How do I now determine from which host + port the packet originates so that I can send data back? Note: C and Winsock is used. ...

Delphi TPath.GetTempPath result is cropped

Hi all! I am using Delphi 2010 and my program wants to get the system's temp path. I am using TPath.GetTempPath and everything is working fine... at least for me and my coworkers. But on some customer machines this method returns a cropped path which is (of course) not existing. I found out that the problem seems to be the result from u...

C++\Win32 API - Difference between WC_BUTTON and "BUTTON" window classes

Is there a difference or is it as simple as #define WC_BUTTON "BUTTON"? Also, if I use InitCommonControlsEx in place of InitCommonControls, do I still need to include a manifest? ...

Use CreateWindow(Ex) to create a dummy parent control (like a panel)

So basically, I have a Tab Control (WC_TABCONTROL) and I want to place all of the controls that go with a single tab page on a single window (control, if you will, or panel). I want to create something like the panel in wxWidgets, so that when I call ShowWindow(panel, SW_HIDE), I can hide the panel and all controls inside it. I hope you ...

Suggest a good Windows API project for a system programmer.

Hello, I've been reading Windows System Programming (4th Edition) - 2010 for couple of months. I've finished it. I've referred to Windows Internals (5th Edition) when required. Now, I'm ready to do some solid real world project using purely Windows API. Kindly suggest a real world moderate sized project (which can involve processes, th...

Calls to ReadFile return ERROR_WORKING_SET_QUOTA

The program runs fine for a few minutes and then ReadFile starts failing with error code ERROR_WORKING_SET_QUOTA. I'm using ReadFile with overlapped I/O like so: while (continueReading) { BOOL bSuccess = ReadFile(deviceHandle, pReadBuf, length, &bytesRead, readOverlappedPtr); waitVal = WaitForMulti...

What are some *slick* UI libraries/frameworks/tools for, non-MFC, Win32 C++ apps?

What is a really good Windows, C++, UI library, framework, or tool that will allow me to very simply and easily add a slick look & feel to my native C++ win32 application? Also; Slick means skinnable with window background images, fancy buttons, shadows, all that jazz. This is non-MFC Supporting Windows XP and beyond Royalty free lice...

WebBrowser, IPersistStreamInit and javascript

For one of our desktop applications we use a HTML-based interface, loaded from local files into a WebBrowser control. This works fine, but now we want to load the files from a different source, and are trying to stream them in using IPersistStreamInit (like this example on MSDN). It seems to work OK, except for the referenced javascrip...

How to: Monitor progress of data in a pipe?

Have a 1MB pipe: if (0 == CreatePipe(&hRead,&hWrite,0,1024*1024)) { printf("CreatePipe failed\n"); return success; } Sending 4000 bytes at a time (bytesReq = 4000) while ((bytesReq = (FileSize - offset)) != 0) { //Send data to Decoder.cpp thread, converting to human readable CSV if ( (0 == WriteFile(hWrite, ...

Windows SuspendThread doesn't? (GetThreadContext fails)

We have an Windows32 application in which one thread can stop another to inspect its state [PC, etc.], by doing SuspendThread/GetThreadContext/ResumeThread. if (SuspendThread((HANDLE)hComputeThread[threadId])<0) // freeze thread ThreadOperationFault("SuspendThread","InterruptGranule"); CONTEXT Context, *pContext; Context.ContextFla...

How does a smaller pipe speed up data flow?

Have a 1MB pipe: if (0 == CreatePipe(&hRead,&hWrite,0,1024*1024)) { printf("CreatePipe failed\n"); return success; } Sending 4000 bytes at a time (bytesReq = 4000) while ((bytesReq = (FileSize - offset)) != 0) { //Send data to Decoder.cpp thread, converting to human readable CSV if ( (0 == WriteFile(hWrite, ...

c++ gdi animation not working

im trying to create ball animation using gdi but i can't get it working. i created a ball using this Graphics graphics(hdc); Pen pen(Color(255, 0, 0, 255)); graphics.DrawEllipse(&pen, sf , 0, 10, 10); i have while loop that loops and adds 1 to sf value basicly like this sf++; than i try to repaint the window(it doesn't work...

MultiByteToWideChar API changes on Vista

Hello, I want an option to convert a string to wide string with two different behaviors: Ignore illegal characters Abort conversion if illegal character occurs: On Windows XP I could do this: bool ignore_illegal; // input DWORD flags = ignore_illegal ? 0 : MB_ERR_INVALID_CHARS; SetLastError(0); int res = MultiByteToWideChar(CP_U...

Who is responsible for putting the null terminator when handling TB_GETBUTTONTEXT?

The documentation for TB_GETBUTTONTEXT says that the handler has to return the number of characters and optionally (if lParam is not null) copy the string into the supplied buffer. The caveat is that the length doesn't include the terminating character. I see the following problem. Say the handler stores the string precomputed (so its l...

Delphi - equivalent to C# DateTime.IsDaylightSavingTime() method needed

Hello, I need somehow to determine whether some TDateTime value is within the Daylight Saving Time range for my timezone or not (in C# the same thing does the DateTime.IsDaylightSavingTime() method). I know in Delphi there's no similar function, because Delphi TDateTime contains no information about timezone, but I suppose there's some ...

rich edit class

HWND hEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "", WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_READONLY | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL, 0, 0, width, height, hWnd, (HMENU)IDC_MAINEDIT, GetModuleHandle(NULL), NULL); Well, that's how I create an (readonly) edit (textbox) control. How can I create a RichEd...

How to fix 3rd party libraries that omit the required C runtime lib?

I'm writing an NSIS installer for a project that requires the PyOpenGL package, however installation of this package fails because my system doesn't contain mscvr71.dll (VS C runtime lib). According to KB326922, this library should have been packaged with PyOpenGL. My question is, what is the safest way to correct this so I can install ...