winapi

Delete End of File

For instance if I called WriteFile to the end of a file, and later I wanted to delete the written bytes, how could I do this? Do I have to read the file's contents into a buffer, re-create the file, and write the desired bytes, or is there an easier way? ...

Find System Hard Disk Drive from Python?

I am working on a software installer for my current application. It needs to be installed to the System HDD. How owuld I detect the system drive and return the letter from Python? Would the win32 extensions be useful? How about the os module pre packaged with Python? ...

Mutlithreading an OpenGL/WinAPI application

NOTE: Please read the whole thing before posting, you'll see why. So I have an OpenGL/WinAPI application. I'm doing what you would expect, by doing cycles of handling messages, then rendering a frame, handling messages, rendering frame... The trouble is, when I resize or move a window, the screen freezes, and it can look quite ugly. I ...

How to read a multi-session DVD disk size in Windows?

Hi, Trying to read the sizes of disks that were created in multiple sessions using GetDiskFreeSpaceEx() gives the size of the last session only. How do I read correctly the number and sizes of all sessions in C/C++? Thanks. ...

Windows Visual Themes: Gallery of Parts and States?

Microsoft Windows lets programmers draw GUI elements using the look and feel of the current theme using functions like DrawThemeBackground and DrawThemeText. The elements are specified by Class, Part, and State, as described at the Parts and States page at MSDN. Unfortunately, the page is not very informative (at all!). So the question ...

RegisterClass fails with Error Code 2

I am creating a splash for a program that I'm making but RegisterClass keeps on failing (2: The system cannot find the file specified.) My code is this: WNDCLASS wc = {0}; wc.lpfnWndProc = DefWindowProc; wc.hInstance = g_hinstance; wc.hCursor = LoadCursor(NULL, IDC_ARROW); if (wc.hCursor == NULL) { #ifdef DEBUG log_debug("ShowSplas...

ReadFile Win32 API

i want to read a file.. but.. when i debug my program it runs but a pop up appears and says system programming has stopped working and in the console, it`s written that Press enter to close the program. my code is :: // System Programming.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include "iostre...

Problem with monochrome windows bitmap scanlines...

I am trying to figure out the format of a Windows bitmap file that is monochrome. From what I can tell, the scanlines are padded on the end to maintain DWORD alignment. However, any data I save is garbled like it's interleaved when viewed from mspaint. However, if the width and height of the image are the same, the data is not garbled wh...

How to create a sparse file on NTFS?

I'm testing a sparse file. But my test code doesn't work well. HANDLE h = CreateFileW(L"D:\\sparse.test", GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_SPARSE_FILE, 0); DWORD d = GetFileAttributes(L"...

about asynchronous draw method

Please teach the method to draw in 2D image by the asynchronous (each method of Windows API and DirectX). ...

C# application postpones Win7 switch user

Hello all, I have a C# application, I want my application postponing the Windows Switch User by a MessageBox and wait for a response from the MessageBox. If my application is not ready for Switch User then I cancel the Windows Switch User. I have tried WTSRegisterSessionNotification() and receive WM_WTSSESSION_CHANGE message in method ...

How can I generate system wide events on Windows?

I would like to know how I can generate system wide events programatically on Windows. I am thinking of generating system wide events such as key presses, touch events and mouse clicks mainly. Is it possible to generate these events with an user mode application or I need to write drivers for this? Any samples or links would be usefull...

MSI Interop using MSIEnumRelatedProducts and MSIGetProductInfo

Hi, Whilst working with the MSI Interop API I have come across some unusual behaviour which is causing my application to crash. It is simple enough to 'handle' the problem but I would like to know more about 'why' this is happening. My first call to MSIEnumRelatedProducts returns an value of 0 and correctly sets my string buffer to a ...

How to compile Unsafe code in C#

Hi guys I've imported an API function like [DllImport("gdi32.dll")] private unsafe static extern bool SetDeviceGammaRamp(Int32 hdc, void* ramp); while compiling its showing an error like Unsafe code may only appear if compiling with /unsafe how to compile with /unsafe . i'm using Microsoft Visual Studio 2008 can any one help me w...

How to detect when window content has changed

I need to write a screencast, and need to detect when window content has changed, even only text was selected. This window is third party control. ...

RegisterClassEx in Assembly

Hi guys, I'm trying to manually call RegisterClassEx Windows API without using a WNDCLASS structure on .data section, I need to create this structure only using push instruction. Could someone help me on that please? Thanks a lot ...

How do DateTime.ToBinary() and DateTime.ToFileTime() differ?

Can anyone help explain the difference between DateTime.ToBinary() and DateTime.ToFileTime()? As far as I can tell they seem to always return the same value (when dealing with UTC times at least). The same applies to DateTime.FromBinary() and DateTime.FromFileTime(). I've tried using Reflector and I can see some differences, I just don'...

Overlapped WSARecv() Callback Not Being Called in MFC App

I have a COM component, implemented in C++ with ATL, that uses overlapped socket I/O. Right after the connection is made to the server, it starts an overlapped read on the socket, with code like this: // Pass pointer to this instance as hEvent parameter, for use by callback m_recvOverlapped.hEvent = reinterpret_cast<HANDLE>(this); int...

Win32 GetOpenFileName prevents app from exiting

Hi, I'm using Win32 with C++ to make an app that can load the contents of files through a dialog with the GetOpenFileName function. Everything works fine, except when I close the main window and the app quits and prints this to the console: The thread 'Win32 Thread' (0xa50) has exited with code 0 (0x0). But the main process keeps runn...

How to know if someone else handled OnContextMenu

I have a CWnd derived class that has a WM_CONTEXTMENU handler (OnContextMenu), which has my default context menu. This class is being used at several places in my application. Some of the places where it's being used also handle the WM_CONTEXTMENU at the parent level (the window parent). They basically override the default context ...