winapi

How to change the control themes in a Win32 API application?

If I create a button in the Win32 API, the default conrol theme looks like a Windows 95/98 button. I remember in the past the Microsoft forums told me how to get the XP style, but I don't recall how to do this. Is there a way to programatically or manually change the control themes in a Win32 application? Thanks. ...

Paint Win32 window to file

In a WPF application (C#), one of the elements is Win32 Window, created by overriding the HwndHost class. There are about 10 instance of this Win32 window in the WPF at any given time. One should render completely (works fine), and the other 9 should only show previews, without creating a Win32 window, just a bitmap. I've been trying ...

How can I decommit a file-mapped page?

I have a memory mapped file, and a page in a view which is currently committed. I would like to decommit it. MapViewOfFile tells me I cannot use VirtualFree on file mapped pages. Is there some other way to do it? ...

Need help wih CryptDecrypt function...

I've created this program that can encrypt a found file and then it can be decrypted later via the CryptDecrypt function. The function succeeds but instead of decrypting the file back to plain text it makes the file look even more encrypted. I've put both the CryptEncrypt function and CryptDecrypt function so you can have a more less vie...

How do I build a Win32 app with a resource file using cmake and MinGW?

In theory, it's very easy to build a Win32 app with a resource file using cmake. In an add_executable command, a resource file can be listed as easily as a C or C++ source file. There is a known bug, however, when building using MinGW tools. I found a workaround, which is to include the following in CMakeFiles.txt... if(MINGW) set(CM...

Setting program to be autorun through registry

Hi! I have the following code: http://privatepaste.com/8364a2a7b8/12345 But it only writes "c" (supposedly, conversion to LPBYTE leaves one byte only). What's the proper way to handle GetModuleFileName and registry edit? ...

Are there advantages to a crashing on a secondary thread versus the main one?

I came across this code in a large codebase DWORD WINAPI ThreadFunc (LPVOID lpParam) { int *x = 0; *x = 1234; // Access violation return 0; } void Manager::Crash () { Log("Received a remote command to crash Server."); DWORD dwThreadId, dwThrdParam = 1; HANDLE hThread = ::CreateThread(NULL, 0, ThreadFunc, &d...

c++ left mouse button down help

ok i know how to do the left mouse button down evet(WM_LBUTTONDOWN). but im having some troubles with it. when use it with vectors it seems to add 101 elemnts everytime the left mouse button is down. i think that every time the mouse button is down, it sends 101 messages to WM_LBUTTONDOWN that causes 101 elements to be added. here is the...

How Do I Properly Call GetLongPathName Using Delphi 2009 and Unicode Strings?

I need to change the old Win98 short path names to long path names. I had a routine that worked fine with Delphi 4, but when I upgraded to Delphi 2009 and Unicode, it didn't work with Unicode strings. I looked around and couldn't find a Unicode-compatible version of it. It appears that the correct routine to use is GetLongPathName from...

Trouble with CryptImportKey function...

I've created this program that can encrypt and decrypt a found file. I've got the encryption part working fine, and its seems to me that the encryption key is exported as a tmp file. The problem is when I'm importing the session key for decryption that is where the CryptImportKey fails and so does CryptDecrypt fails too. Can someone plea...

Border size of a fixed window

Hi, I need to somehow get width of a (fixed) window's border size (the vertical one). By default on WinXP its pretty thin but on Win7 with Aero on, its much more thick. I thought GetSystemMetrics would do the trick but it seems it returns the same values for both XP and Win7 systems, I checked following parameters: SM_CXBORDER SM_CXED...

How to check with WINAPI file path is disk or file or directory?

How to check with WINAPI file path is disk or file or directory? ...

C++ Win32 Window unresponsive

I have a console application from which I create a window. I can render stuff in the window just fine. But the window is unresponsive/uncontrollable by the user. As soon as you mouse over the window you get the hourglass cursor and cannot move the window. What might be causing this? EDIT: WNDCLASSEX wndClass; // Window...

Why do some applications look poor when Large fonts are enabled in Windows 7

I've noticed that some applications (eg. Visual Studio 2008, Gallio Icarus 3.1) don't look that great (eg. fonts are blurry) when I run them on my laptop which has fonts set to 120%, whereas other applications seem to render fonts crisply. I have unchecked the 'Enable Windows XP style scaling' option in the 'Custom DPI Setting' dialog i...

How do I access a raw sector of disk in XP with a c program?

I want to know that how to access a sector of the hard disk in Windows XP with a C program? ...

Delphi Loadlibrary returns 0 (LastErrorcde=3221225616) What does this mean ?

Hey, I need to use a 3rd party dll in our main app. When I staticly link to the provided DLL it works ok and I can the DLLs exported functions. But we don't want our main app dependend on this dll on startup so I tried to dynamicly load the DLL when I need it : DLLHandle := LoadLibrary('3rdparty.dll'); ret := GetLastError(); if DLLHandl...

Where is ERROR_PENDING defined?

The MSDN documentation for CommitTransactionAsync indicates it may produce an ERROR_PENDING error code. However, this error code does not seem to be defined in winerror.h, nor any other header reachable from ktmw32.h or windows.h (using the version of the Windows SDK included in Visual Studio 2010). In fact, I cannot find a single file c...

c++ can't insert values in vector

ok i when it try to insert two values in two different vectors it won't work the first one will work but the second won't be setted. // Xstrike.cpp : Defines the entry point for the application. // #include "stdafx.h" #include "Xstrike.h" #include <vector> #define MAX_LOADSTRING 100 // Global Variables: HINSTANCE hInst; ...

c++ vector problem

i have to event that should insert values in two vectors but when event get called for the first time it inserts the values successfully but when it get called again it will insert the values in the first vector but not in the second vector than when another event get called the second vector's values will be deleted. here is the full co...

when CreateDirectory returns ERROR_ACCESS_DENIED and "shouldn't"

My Win32 app A1 (actually a collection of processes) is trying to use CreateDirectory to create a directory D1 within parent directory P. The path to P is the value of the TMP environment variable, which makes P a potentially busy but generally permissive place. The vast majority of the time, everything works fine, but, rarely, CreateDir...