winapi

How do I poke the flag in a win32 PE that controls console window display

I have an executable which is part of a batch process. This one executable opens a console window, which is annoying since it's useless to the end user and steals focus away from their active task. We can't compile a new version from of this EXE from source (easily). Is there an easy way to twiddle this setting in the PE? ...

How to show printer properties/preferences dialog and save changes?

EDIT: My fault! I expected the changes to be written back to the default printer settings when in fact only the local instance of the PrinterSettings are changed. - The below code seems to work as intended I am trying to show the custom printer properties of a given printer. I need this as part of a custom PrintDialog which I am trying ...

Windows API - Beginner help

I try to create a very simple app using windows API. I've done some small apps in console. This is the first time I do with Win32 apps. I've searched and found a document from forgers which is recommended in this site. But I try to write very first line: #include <stdafx.h> #include <windows.h> int WINAPI WinMain(HINSTANCE hInstan...

Programmatically allow write access for a Registry key

Hi everybody, I need to programmatically modify the Access Descriptors on a known Registry key during product installation. The way I want it to work is: The installer is run in Administrative mode. A Registry key is created. A function (the one I need) queries the ACL from the key. If this function finds that the group 'Users' alread...

Displaying text on dialog box

How to display text on dialog-box? for example - I want to display a countdown timer, should I go with static text control? ...

Check if window is losing focus

which notification message do you receive if any window is losing focus? ...

Giving dialogbox focus

I'm creating a dialogbox with a picture control and whenever I initialize the dialog it sets the focus to that picture control, is there any way to give dialog the default without resetting the focus from picture control? ...

Keyboard Input & the Win32 message loop

How do I handle key presses and key up events in the windows message loop? I need to be able to call two functions OnKeyUp(char c); and OnKeyDown(char c);. Current literature I've found from googling has lead me to confusion over WM_CHAR or WM_KEYUP and WM_KEYDOWN, and is normally targeted at PDA or Managed code, whereas I'm using C++. ...

Resource.h in Windows API simple app

there'are these lines in the sample Win32 app created default by VS. Can you explain why they're just numbers, and it's meaning :) //{{NO_DEPENDENCIES}} // Microsoft Visual C++ generated include file. // Used by Testing Project.rc // #define IDS_APP_TITLE 103 #define IDR_MAINFRAME 128 #define IDD_TESTINGPROJECT_DIA...

How to retreive SID's byte array

Hello experts, How can I convert a PSID type into a byte array that contains the byte value of the SID? Something like: PSID pSid; byte sidBytes[68];//Max. length of SID in bytes is 68 if(GetAccountSid( NULL, // default lookup logic AccountName,// account to obtain SID &pSid // buffer to allocate to...

How to set exe icon using AssemblyBuilder?

Given that I am generating an exe application with AssemblyBuilder, how do I set an icon to it? I think I should be using System.Reflection.Emit.AssemblyBuilder.DefineUnmanagedResource Is there an example how to do it? http://msdn.microsoft.com/en-us/library/aa380599(VS.85).aspx ...

RegCreateKeyEx - does it update the returned handle on failure?

MSDN documentation seems silent on whether RegCreateKeyEx ever updates the value of the handle referred to by its second-last parameter when it fails. My tests have only shown it not to update this - i.e., I set h = 0 before the call, pass &h to a call to RegCreateKeyEx to open a non-existent key, and see h = 0 after the call. Does anyon...

How can I load my own window instead of default window with win32 API

I've created a simple dialog box in my .rc file . How can I view this box instead of the default one of VS 2008. ...

Multilangual Unicode rendering in opengl

Hi Folks, I have to extend an OpenGL-Rendering System to support international characters (especially Hebrew, Arabic and cyrillic). Development Platform is Windows(XP|Vista|7), Alas using Embercardero Delphi 2010. I currently use wglOutLineFont(...) to build my font's display list and glCallLists(length(m_Text), UNSIGNED_SHORT, PWcha...

Safely remove window subclassing?

I am trying to subclass the currently focused window on a Windows system using a global CBT hook. This is related to what happens in this question, but the bug is different. What happens when this subclassing is in effect, is that Opera's (version 10.50) main window is prevented from displaying. Opera has a "splash screen" where you are...

How can i use a C# dll in a Win32 C++ project ?

I am working on a solution, most of its core engine is developed as Win32 C++ (and is Platform independent and is also used on OS X), some time ago we needed to call C++ dll's of core engine from C# and I was able to Load main solution's DLL in C# (by the help of some threads here on SO). but now we have certain things implemented in Man...

getting window screenshot windows API

Hi, I am trying to make a program to work on top of an existing GUI to annotate it and provide extra calculations and statistical information. I want to do this using image recognition, as I have learned a fair amount about this in University using Matlab and similar things. I can get a handle to the window I want to perform image reco...

P/Invoke on 32 bit and 64 bit systems

Let us pick the following Win API call as an example: BOOL MessageBeep(UINT uType); // from User32.dll The input parameter is UINT to specify the beep type, which is can be both 32bit and 64bit integer, depending on which Windows version we call it on (or am I wrong?). If I want to P/Invoke message beep from C#, so I apply the DllImp...

How to force a window to maintain a certain width/height ratio when resized

I want my window to always maintain a certain ratio of let's say 1.33333333. So, if the window is width = 800, height = 600 and the user changes the width to 600, I want to change the height to 450 automatically. I'm already intercepting WM_SIZE but I don't know if it's enough; also I don't know how to change the width or height to main...

Chaining multiple ShellExecute calls

Consider the following code and its executable - runner.exe: #include <iostream> #include <string> #include <windows.h> using namespace std; int main(int argc, char *argv[]) { SHELLEXECUTEINFO shExecInfo; shExecInfo.cbSize = sizeof(SHELLEXECUTEINFO); shExecInfo.fMask = NULL; shExecInfo.hwnd = NULL; shExecInfo.lpV...