Click here to Skip to main content
15,887,676 members
Everything / WinAPI

WinAPI

WinAPI

Great Reads

by SimbirSoft
C++: love and intrigue
by Axel Rietschin
Import photos & videos directly from smart phones and digital cameras using the Windows Photo Import API, for Windows Universal Apps and Classic Win32 applications on Windows 10 and beyond.
by David MacDermot
This article describes adding checkboxes to the standard combobox and listbox control.
by Alexander Eremeev
The Windows kernel-hacking library and development framework written on C++17

Latest Articles

by ColleagueRiley
A multi-platform single-header very simple-to-use framework library for creating GUI Libraries or simple GUI programs.
by AbdulRahman A. Badry
Alter your display gamma-ramp to correct & calibrate it
by David MacDermot
This article describes adding checkboxes to the standard combobox and listbox control.
by honey the codewitch
Diving into some of the core plumbing behind the Windows operating system

All Articles

Sort by Title

WinAPI 

20 Nov 2018 by Sagar R. Kapadia
I have a C# Application, which is launched from a C++ DLL using CreateProcessAsUserW api. The process is launched successfully, but terminates immediately. It works properly on Windows 10 [both as 32 bit and 64 bit] and 32 bit on Windows 7. Please help. Thanks, Sagar The method is as follows ...
6 Nov 2018 by KarstenK
You havent written about the user rights which gets the process. It should be a valid user on the machine who has all needed rights on the machine. Check with manual start of the app, when logged on as this user. When the error only is on Windows 7 x64 it can be a bug somewhere in the...
20 Nov 2018 by Sagar R. Kapadia
I got the answer on https://social.msdn.microsoft.com/Forums/vstudio/en-US/fb9d15fb-dc9f-488e-92c4-e0bb438442e1/64-bit-dot-net-process-created-with-createprocessasuserw-exits-immediately-with-exception-code?forum=vcgeneral [RLWA32 answered it] There was a problem with the way in which the...
8 Oct 2022 by reverser69
hi all i want to do an inline asm and i want to see if a given location of memory is non-writable-executable code or its writable data; if its data, skip the overwrite. i want to do it in pure asm + win api. i partially achieved it by checking...
8 Oct 2022 by merano99
Access to main memory is usually realized with an MMU. Since the MMU is a critical resource, the operating system takes care of it. Access to the MMU requires operating system rights and good hardware knowledge. If you had access to the MMU, you...
29 Aug 2015 by OriginalGriff
That isn't how it works here: we aren't a debugging service for random people.But you almost certainly have the greatest tool for doing it yourself on the planet open right now: Visual Studio.Debugging is a skill, and it's one you only improve by practicing it - you certainly won't develop...
28 Dec 2014 by AlwaysLearningNewStuff
I want to create tab control that has button inside it's tab. Something like this[^] image.Tab has close button added and I need something like this. I also have to enable Visual Styles.English is not my native, so I was not able to formulate efficient search criteria for Google. I found...
28 Dec 2014 by Maciej Los
I'm sure you can find what you need on CP KnowledgeBase[^].Here you've got two articles:TabCtrl[^]Custom Tab Controls, Tabbed Frame and Tabbed MDI[^]
27 Mar 2024 by Rick York
Firstly, there are no limits to DLL sizes or capacities. Secondly, it is important to note what is emitting that error message. It could be the compiler or the linker. If it is from the compiler then you have not defined a prototype for the...
27 Mar 2024 by samtoad
Currently, I'm trying to add another "C" routine into a DLL file. I've made the routine inside a DLL source file. I've declared the routine, and also indicated the intentions as it will be exported. The function name is also included in a DEF...
28 Mar 2024 by KarstenK
Verify that your new dll function has the same export macro signature as the other dll function. Mostly some DLL_EXPORT or similar macro stuff. Another common issue is that, your new dll isnt used by the calling program but a stale version in...
31 Oct 2016 by MyOldAccount
INTRODUCTION:I am writing small app that monitors certain directory for newly added files.I would like to put monitoring code in a separate thread, so I can leave main thread free for other stuff, and cancel monitoring thread when I need to.RELEVANT INFORMATION:I am using...
31 Oct 2016 by Jochen Arndt
I have not used ReadDirectoryChanges so far but it should be sufficient to call it only once outside the loop. That should solve the problem.If not, you have to wait for both events using a single call. But I recommend to do that anyway:HANDLE ahWait[2] = { p.hEvent, ovl.hEvent };BOOL...
17 Nov 2014 by Sergey Alexandrovich Kryukov
Short answer: you may need to use Windows Hooks.The problem with this question is that you apparently refuse to collaborate. You should understand that using P/Invoke and direct use of Windows messages is unusual in most reasonable application and only used in some special cases. We need to...
6 Jan 2015 by MasterCodeon
hello everyone!i want to know how to:A. start a process on a remote machine directly without using a client app.B. send WinAPI messages from the local workstation to the process i just on the remote pci know how to send messages to an app on the local machine but i don't know how to send...
5 Jan 2015 by Jeremy Falcon
Assuming you're not trying to write a virus...What you're asking for is impossible without a receiver program on the remote machine. Nowhere does Windows automatically process sockets and execute them as a Windows API call. You'd need a program to receive the packets and them process...
5 Jan 2015 by Dave Kreskowiak
1) You can launch a remote process using WMI, but it can NOT be an interactive process. This means that the user logged into the console will NOT see it running at all. For example, you can launch Notepad, but it'll sit there waiting for input it'll never get and the user will not see it.2)...
30 Dec 2014 by Zoltán Zörgő
1) Your P/Invoke looks incorrect. 2) If you want to send cutom message, use WM_USER+X[^], which start from 0x0400 and not 40 decimal.3) ParentFormHanlde??? It looks not an other window's handle to me... 4) Look here for a working sample (even the message is other):...
31 Dec 2014 by MasterCodeon
All right i did it yeah!some background info on this question:i was trying to setup an options box for my form and i wanted to pass string values betweenmy main app and the options app. so i tried the properties approach but it wouldn't work, this was due to the fact that i was declaring...
17 May 2023 by MasterCodeon
hello everyone!i am trying to send a string to another application.the way i am trying to do this is by using the SendMessage function in the windows api, and i am setting the WParam parameter to a string value(when i imported the function i did use a string type for this parameter).now in...
20 Apr 2023 by huguidesr
I've been trying to draw a bitmap int array using glTexImage2D, but it only outputs white nothingness. It outputs jumbled messy pixels from out of bounds memory if I initialize the int aray as a char array instead, but it only renders whiteness...
20 Apr 2023 by Rick York
I don't have an answer for you but here are a few sample projects you might get a hint from : 50 OpenGL Win32 Projects in One[^] 50 OpenGL MFC Projects in One[^] Your Own Quadrics in OpenGL MFC[^]
25 Mar 2023 by OriginalGriff
You can use GetDC on the NULL window to get a device context for the whole screen, and can follow that up with a call to GetPixel: HDC dc = GetDC(NULL); COLORREF cr = GetPixel(dc, x, y); ReleaseDC(NULL, dc);
26 Mar 2023 by Saleh 2023
I am trying to get the pixel color of a specified coordinate point outside my application window. So, since hwnd specifies my window to be targeted, then all i should do is use getdc function and pass my hwnd as parameter. But what if I want a...
11 Jun 2017 by User 11061201
Hallo, i am not sure where to start my code in C++ using winforms. There is no main() procedure, instead there is a WinMain() procedure, so where exactly to put my code and where not. Where is the loop? I want to add; while(1) {... call another method;} int WINAPI WinMain (HINSTANCE...
11 Jun 2017 by OriginalGriff
Winforms isn't like a console app, there is a "main" proc, but it's not where you put most of your code (if any). And there isn't a loop in the sense you mean! Instead it's job it to process Windows messages, and call the appropriate function when a particular message is received - and it...
11 Jun 2017 by Richard MacCutchan
See EFNet #Winprog[^] and Win32 Programming - FunctionX[^] for some useful tutorials.
11 Jun 2017 by User 11061201
I ended up creating some events, im not sure if is the way to use in C++ but good for some testing. bool onLoad; void on_Load(); bool onClosing; void on_Closing(); LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { if(onLoad == false) { ...
6 Dec 2016 by Jon Campbell
Using "thunk" technique to add this pointer as fifth parameter to WndProc call for x32 and x64
28 Jun 2014 by AlwaysLearningNewStuff
I have printing code that draws grid on the paper.Grid has 4 columns, and they have equal horizontal length. Height of the cell is tenth of the paper size. Total number of rows is unknown but I know for a fact that there will be at least one row.Each cell has same physical size-> width...
29 Jun 2014 by CPallini
Quote:The only thing that crossed my mind was to create "dummy font", see if the example text can fit into cell, and then adjust it's size if the test failsThat's a feasible approach indeed. But what do you mean with 'dummy' font? You need to know in advance the exact font you are going to use,...
15 Dec 2016 by Farhad Reza
This tip describes how we can design application interface using Win32 API in Rust Programming language.
1 Feb 2022 by Avtem
So for my Win32 app I use one .chm file as a manual and another .chm for representing "Version History." I use a HtmlHelpW() function for opening them. The problem is, if I open both of them, the second .chm file hangs up, starts to consume all...
1 Feb 2022 by CHill60
If you want spaces in a path then you must surround the entire path with double quotation marks - see Long paths with spaces require quotation marks - Windows Server | Microsoft Docs[^] E.g. HtmlHelpW(mainWnd,...
15 May 2014 by Tony Hallett
Hi, I have been writing some Pinvoke code for lower level WinAPI Access Control functions. I have a pointer to Privileges associated with my access token from the TOKEN_ACCESS_INFORMATION and I am looking at the privileges. I have working code but decided to refactor part of it to a...
28 Nov 2014 by AlwaysLearningNewStuff
I have dialog box which should act as tab page. My application uses Visual Styles.I ran into background painting problem when tried to properly center child dialog box into tab's display area. Asking for help, I got an advice to resize the child dialog box to fit the tab control's entire...
14 May 2023 by Mitchell J.
ffmpeg should be able to do this. Not sure if it supports directly embedding itself within your C++ code, but you should at least be able to run an instance of the binary from your code (with the correct flags) and then parse the output it produces.
14 May 2023 by OriginalGriff
This isn't necessarily a C++ solution - I haven't played with C++ for over a decade - but there is a .NET way to get some video info direct from the OS provided a suitable codec is installed - I use it to get video duration and resolution, using...
14 May 2023 by KarstenK
So Derell wrote the ffmpeg is a solution. You have to learn to handle the code, but it has a lot of features and it is some "workhorse" library. Your tasks are challengig so it is also challenging to get some library to do the job. tip: the...
15 May 2023 by RickZeeland
Maybe you can use one of these GitHub projects: video-metadata · GitHub Topics · GitHub[^] And if you are not afraid of a bit C# coding: GitHub - drewnoakes/metadata-extractor-dotnet: Extracts Exif, IPTC, XMP, ICC and other metadata from image,...
16 May 2023 by virtualnik
Try MediaInfo: MediaInfo - Download MediaInfo for Microsoft Windows[^] It ships with a simple to use Dll interface that can be used to gather information about nearly all video and audio files. In the Zip-File you will find a directory called...
17 May 2023 by Derell Licht
I have a command-line utility that I wrote (C++, MinGW32, Windows 10), that displays information for images and videos... I recently found an excellent free library (ZPlay) that handles some of the more complex images such as OGG, MP3, FLAC... ...
17 May 2023 by cute_friend7077
crystalhd gstreamermm libmatroska libVLC mjpegtools OpenH264
12 Nov 2014 by AlwaysLearningNewStuff
I am trying to insert dialog boxes, as separate pages, into tab control.I have created the dialog boxes successfully in resource editor, with all necessary styles.Since my application uses visual styles, I ran into problem with transparency of the dialog's child controls ( radio button,...
12 Nov 2014 by barneyman
from some distant memory of this, try doing the adjustRect and child movewindow AFTER the insertion ... the tab control changes size ISTRBTW, you'll have to do an adjustRect, movewindow for all children after each insert (or once after a block insert), because the tabControl header resizes...
24 May 2015 by Evgeny Pereguda
Simple lib for capturing live-video from web-camera by using Media Foundation
8 Jul 2020 by MyOldAccount
I have created a small demo app which window looks as below: https://i.stack.imgur.com/iW05q.png[^] When I run this demo app, and press any key, I want to capture the part of the screen bitmap. The part of the screen I am interested in, is the...
8 Jul 2020 by Dave Kreskowiak
It's capturing exactly what your code is telling it to capture. You have no choice but to run this code under the debugger, examining variables to make sure the values are what they are supposed to be. The code isn't doing what you think it's...
8 Jul 2020 by Richard MacCutchan
See GetScaleFactorForMonitor function (shellscalingapi.h) - Win32 apps | Microsoft Docs[^].
8 Jul 2020 by KarstenK
You should respect the scaling how Richard wrote and also deal with multi monitor system. Some years ago I wrote an Repositioning Windows on Multiple Monitor Systems article which deals with that issue. But nevertheless your foo function looks...
22 Mar 2016 by Ashiru Ali
Hi all I am working with a CHtmlEditCtrl in MFC. I want to draw some random rectangles and lines inside a function handling right click event.What I have tried:The ChtmlEditCtrl control is created from static using this snippet: bool CHtmlEditCtrlEx::CreateFromStatic( UINT nID,...
22 Mar 2016 by KarstenK
Your drawing code belongs in the OnPaint() function. At first make the default call and than your stuff.void CHtmlEditCtrlEx::OnPaint(){ CWnd::OnPaint(); //here comes your drawing code DrawSquigly(...);}For controlling the drawing you should use a member variable activated...
25 Jan 2015 by AlwaysLearningNewStuff
I am trying to change the style and date format of the DateTimePicker control on combobox' CBS_SELCHANGE notification.When user selects one option, datetime picker should have spin control and show only year. If user selects other options, style should be reset to short date style and date...
25 Jan 2015 by KarstenK
Richard is right, that some style in controls cant be changed in runtime, but must initialized in creation time.You can work around it with a) dynamically recreating such control behavior, or b) create 2 controls in the same place and only one is visible and the other is hidden. It...
26 Nov 2014 by Member 11142020
What API can I use to change the access-rights of a handle I have opened?I want to change the access rights of it on the run, I heared it's possible without creating a new handle, so how?
26 Nov 2014 by barneyman
SetSecurityInfo[^] possibly?
23 Dec 2021 by David MacDermot
This article describes adding checkboxes to the standard combobox and listbox control.
22 Aug 2016 by MyOldAccount
INTRODUCTION:I have studied the MSDN examples for blocking TCP server[^] and blocking TCP client[^].I wanted to try something simple, in view of modifying those examples to create simple chat application.I have tried to implement the following, for a start:send message from...
22 Aug 2016 by Jochen Arndt
You are using blocking sockets. When receiving and there are no more data, the recv function will block (not return) until new data are received or the connection is closed (as triggered with your third try).The simplest method to avoid this is using some kind of indication that all current...
26 Oct 2014 by time-killer-games
I am creating a process whose main window is then embedded in the calling process' main window by removing the window border, MoveWindow, and SetParent.I can use TerminateProcess to close the process of the embedded window when the calling process is closed properly, but if the calling...
26 Oct 2014 by enhzflep
Something you could consider doing, is to implement a regular checking mechanism. The child process would check if the HWND of its parent is a valid HWND. You could set a timer that fired as often as required.You could use something like the following: case WM_TIMER: ...
23 Nov 2014 by AlwaysLearningNewStuff
INTRODUCTION:I am creating tab control with child dialog boxes as pages.I have Visual Styles enabled via #pragma comment. I have also called InitCommonControlsEx and #pragma comment( lib, "comctl32.lib" ) as well.Initially, when window loads, dialog and its common controls have...
23 Nov 2014 by Richard MacCutchan
InvalidateRect( hwnd, NULL, FALSE );You should use TRUE in the bErase (third) parameter, to ensure the background is erased and completely repainted.
7 Nov 2018 by Apriorit Inc, gamapat
Take a look at how to intercept HTTP traffic in order to inject custom code into Windows HTML markup
2 Aug 2020 by Amit Saini
Hello Everyone ,My motive is to control visual studio by voice commands by using microsoft speech services. I want to control visual studio from my another window form app in c#. I have a little bit success but there is some problem in SendKeys...
1 Jul 2015 by George Netu
I have a USB HID touchpad that collects input. By default, when I press on the touchpad it generates carriage return (Enter) and when I try to use it as a mouse it actually enters a dragging state.What I want to do is to convert the carriage return into a mouse click event and the dragging...
14 Jun 2014 by AlwaysLearningNewStuff
I am learning to use print property sheet so I can start learning printing by drawing a rectangle on the paper.My problem is that I do not have a printer, and am testing the results by printing to XPS file and MS Office OneNote 2007. I am drawing the rectangle with this code snippet ://...
16 Jun 2014 by Richard MacCutchan
Take a look at GDI Drawing and Printing[^].
16 Jun 2014 by Richard MacCutchan
I have discovered that the issue is to do with the default unit settings in the Graphics class, as described in http://msdn.microsoft.com/en-us/library/ms535812(v=vs.85).aspx[^]You need to use the following line of code to set it to pixels.g.SetPageUnit(UnitPixel);That now works in XPS...
18 Feb 2019 by lbernstein123
User is facing problem copying text from my application grid into another application text editor (to be specific - app on the receiving site is Bloomberg IB Chat) - text columns not aligned properly. You can see my code - this works on plain text editors such as notepad, notepad++. I think it...
18 Feb 2019 by Gerry Schmitz
Text is text. The "font" (e.g. mono, size, weight, etc.) is controlled by the receiver / document / "container" / email client / browser / font availability. Unless there are features to allow for pasting "as is" (like for mono), the stuff gets which ever font the OS "thinks" is closest for a...
18 Feb 2019 by lbernstein123
Gerry thanks. I understand your point. However, posting a question I thought maybe there are some people in the community who are done something like: 1. Set global hook to paste function. 2. Detect the font family of the window that receives paste result. 3. Figure out how to align data based...
30 Sep 2019 by Member 11803607
I SubClassed The Edit Box In Window Class #32770 And Want To Change The Cursor But Cannot do SetCursor LoadCursor(0,IDC_HAND) What I have tried: Just Put Api function that mentioned in WM_SETCURSOR
26 Dec 2016 by Member 12890174
Hello and Good Morning to everyone Studied about screen capture / mouse capture so i wanted to ask how do i create a Remote desktop application in WINAPI with these api ?Any ideas?What I have tried:screen capture + mouse capture
23 Dec 2016 by barneyman
Writing a Desktop Sharing Application – Enterprise Mobility and Security Blog[^]
26 Dec 2016 by zeki yugnak
Hi, you may want to look existing applications such as tight vnc etc. It has been implemented with pure Win32Api/C++, and you can review it's open source codes just downloading their website. Writing remote application is a very long road, and you need learn a lot of thing on this road, good...
10 Dec 2014 by AlwaysLearningNewStuff
I need to create a window that acts like "normal" one, but without maximize button, and sizing border.Searching through Internet, and studying MSDN, I have learned that natively achieving both is impossible.There is no window style that does both ( I can disable maximize button, but that...
10 Dec 2014 by Richard MacCutchan
Searching through Internet, and studying MSDN, I have learned that natively achieving both is impossible.Not true at all, just use WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_DLGFRAME | WS_MINIMIZEBOX styles in your CreateWindow or CreateWindowEx call.
15 Aug 2019 by SimbirSoft
C++: love and intrigue
13 Feb 2015 by AlwaysLearningNewStuff
I have enabled Visual styles for my application:#pragma comment( linker, "/manifestdependency:\"type='win32' \ name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \ processorArchitecture='*' publicKeyToken='6595b64144ccf1df' \ language='*'\"")I can set font for the...
2 Feb 2015 by AlwaysLearningNewStuff
I have dialog box made in resource editor that behaves as a child control of the main window.In normal mode, when behaving as a popup, dialog can receive WM_SETTINGCHANGE[^] message that notifies dialog box about user changing locale settings, but as a child it does not seem to receive this...
11 Feb 2015 by KarstenK
You must forward the message in your app. Post it with the same parameters to your actual window and handle it in a message handler.
2 Mar 2015 by AlwaysLearningNewStuff
INTRODUCTION:I am implementing rearranging of listview items without using OLE drag and drop.PROBLEM:I have successfully solved most of this task, except scrolling up/down when user wants to drop items at the position that is not currently visible.QUESTION:I am able to scroll...
2 Mar 2015 by Jochen Arndt
CView derived classes are prepared for drag & drop.To register a window as a drop target, add a COleDropTarget member to your class and call the Register() function passing the CWnd pointer to the window. The common place to do this is OnInitialUpdate() with view windows:void...
7 Apr 2020 by Coder969
I want to understand which hook is used for what purpose. What I have tried: I have googled and only difference I understood is WH_KEYBOAD will inject the dll into the processes but for the WH_KEYBOAD_LL windows will make a direct call to call back function without injecting the dll. So...
16 Sep 2019 by Richard MacCutchan
It is all described at Hooks Overview - Windows applications | Microsoft Docs[^].
7 Apr 2020 by Member 10779791
how i can trace application name or browser url where typing something?? Example if i a\m typing on word then it will return word if it will a exe file then exe file name?? Any suggestion Thankls in Advance
25 Dec 2016 by Member 10852608
Helloso let's say i wrote simple win32 api application with simple GUI .. does it work in the following version of windows {XP ,Vista,7, 8/8.1,10 (32bit & 64bit)} ? i had little problem running it in xp version but i set it to Visual Studio 2015 - Windows XP (v140_xp)does this option...
25 Dec 2016 by Jochen Arndt
There is theoretically no difference. But this assumes that all systems use identical hardware.There may be differences when changing the project CPU settings (minimum supported CPU) and there are differences between 32 and 64-bit builds. But these are negligible.Setting the minimum...
25 Dec 2016 by KarstenK
Normally the problem point of actual Windows versions is Windows XP (32 bit). If it works on that, everything should be fine. The speed isnt a real issue because the difference are very small. The best optimization is to minize the drawing process, reloading app resource (like bitmaps) and the...
13 May 2014 by Viacheslav Kukhta
Hi, prompt please how i can create dump heap? What functions should be used to receive the dump heap?
13 May 2014 by Code-o-mat
This is probably what you are looking for: MiniDumpWriteDump[^], good luck.Please note that creating full memory dumps might take a longer time and it might create quite a large file, so handle with care.
13 May 2014 by Viacheslav Kukhta
I try.. but nothing is written to the filecase IDC_BUTTON2:hFile = CreateFile( TEXT("minidump.dmp"), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL ); if( hFile!=NULL && hFile!=INVALID_HANDLE_VALUE ) { MINIDUMP_EXCEPTION_INFORMATION eInfo; ...
8 Dec 2014 by AlwaysLearningNewStuff
I am using a combobox control to show names stored in a database ( I need to preserve space, that is why I use it instead of a listview, for example ).My problem is that sometimes text is longer than the combobox so part of it can not be seen.Is there a way to resize combobox' listbox so...
8 Dec 2014 by nirav raval
Adjust combo box drop down list width to longest string width[^]Please check the above link.Tip : Always search before posting a question. It will help you a lot.Regards,
29 May 2014 by AlwaysLearningNewStuff
I have made simple edit control. After I change keyboard layout from English to other one, characters are not shown properly. They are represented with a pipe ( | ).If I copy the content of the edit control and paste it into Notepad they are displayed properly.I have tried to register...
31 May 2014 by AlwaysLearningNewStuff
After adding the following code snippet into my WM_CREATE handler I found out that edit control uses System font :HFONT hf = (HFONT)SendMessage( hEdit, WM_GETFONT, 0, 0 );HDC eDC = GetDC( hEdit );wchar_t txt[50];GetTextFace( eDC, 50, txt );SetWindowText( hEdit, txt...
28 Jul 2014 by Muhammad Muddasar Yamin
The article is about launching elevated processes through command line
6 Oct 2020 by curiousward
I have retrieved and duplicated a token (via OpenProcessToken() and DuplicateTokenEx() ) from a process running under the context of a Standard User. Is it possible to provide this token alone with administrative privileges so that such user...