Questions tagged [winapi]

The Windows API (formerly called the Win32 API) is the core set of application programming interfaces available for the Microsoft Windows operating systems. This tag is for questions about developing native Windows applications using the Windows API.

The Windows API, informally WinAPI, is Microsoft's core set of application programming interfaces (APIs) available in the Microsoft Windows operating systems. It was formerly called the Win32 API; however, the name Windows API more accurately reflects its roots in 16-bit Windows and its support on 64-bit Windows. Almost all Windows programs interact with the Windows API. You can find more help on the Windows API Documentation.

The Windows API (Win32) is primarily focused on the C programming language in that its exposed functions and data structures are described in that language in recent versions of its documentation. However, the API may be used by any programming language compiler or assembler capable of handling the (well defined) low level data structures along with the prescribed calling conventions for calls and callbacks.

38350 questions
9
votes
2 answers

How to detect a client disconnect using a named pipe client/server?

I'm learning about named pipes and was playing with the named pipe client and server examples from the MSDN doc: Named Pipe Server Named Pipe Client I modified the client so I can type in messages to the console and have them sent to the server…
Robert Groves
  • 7,114
  • 5
  • 34
  • 49
9
votes
1 answer

Can my Visual C++ program listen to its own debug output?

My program uses a ton of third party libraries that sometimes put useful error messages into debugger output (using OutputDebugString()). Can my program somehow programmatically access that output so that it can parse it and report it to me in some…
sharptooth
  • 159,303
  • 82
  • 478
  • 911
9
votes
1 answer

How to pass STDIN to child process?

void WriteToPipe(void) // Read from a file and write its contents to the pipe for the child's STDIN. // Stop when there is no more data. { DWORD dwRead, dwWritten; CHAR chBuf[BUFSIZE]; BOOL bSuccess = FALSE; char * name =…
whiteberryapps
  • 1,332
  • 4
  • 15
  • 20
9
votes
2 answers

Is it safe to initialize MS HANDLE to nullptr?

I know using nullptr is more "typed". It can distinguish pointer type and 0 and works well in function overloading and template specialization. So I am not sure whether it is safe to replace the NULL to nullptr in my old Win32 project in every…
Chen OT
  • 2,945
  • 2
  • 19
  • 38
9
votes
2 answers

What desktop does Metro stuff run in?

Just curious, from a standpoint of WinAPI developer, what desktop do Metro apps run in? This stuff:
c00000fd
  • 18,074
  • 19
  • 132
  • 318
9
votes
3 answers

Creating context menu for win32 API

I am trying to create context menu for win32 application using case WM_RBUTTONDOWN: { HMENU hPopupMenu = CreatePopupMenu(); InsertMenu(hPopupMenu, 0, MF_BYPOSITION | MF_STRING, ID_CLOSE, (LPCWSTR)"Exit"); InsertMenu(hPopupMenu, 0,…
Xinus
  • 26,861
  • 26
  • 111
  • 160
9
votes
2 answers

Correspondence between ProcMon and CreateFile disposition options

Process Monitor shows disposition option for CreateFile operation as "Open", "OpenIf", "Overwrite", "OverwriteIf" (may be something else). How does the options which contain "If" differ from those that do not? And to which CreateFile WinAPI function…
vkrzv
  • 1,574
  • 1
  • 16
  • 43
9
votes
2 answers

Common controls are not properly painted with WM_CTLCOLORSTATIC handler after I set Visual Styles on

INTRODUCTION AND RELEVANT INFORMATION: I have 2 dialog boxes created via Resource editor. Since I use Microsoft Visual Studio Express edition, I had to download free resource editor to create them. In my program, I have Visual Styles enabled like…
AlwaysLearningNewStuff
  • 2,649
  • 3
  • 21
  • 72
9
votes
1 answer

File system support for FindFirstFileEx, limit to directories

I am using the Windows API function FindFirstFileEx because it provides the capability to return just the sub-directories of a given directory (ignoring files). However when I call this function with the required flag, I still receive both files…
Ash
  • 57,515
  • 31
  • 146
  • 168
9
votes
6 answers

Timer in a win32 service

Can someone please point me to the easiest way to have a timer in a Win32 service? I suppose I could create a dummy window for this purpose or have a second thread do tick counts, but what's best? Is there a more elegant way? Thanks in advance.
dennisV
  • 1,119
  • 1
  • 18
  • 32
9
votes
3 answers

how do I do print preview in win32 c++?

I have a drawing function that just takes an HDC. But I need to show an EXACT scaled version of what will print. So currently, I use CreateCompatibleDC() with a printer HDC and CreateCompatibleBitmap() with the printer's HDC. I figure this way the…
Stephen Hazel
  • 829
  • 2
  • 10
  • 24
9
votes
1 answer

How can I detect if a hard drive is spinning (under Windows)?

How can I programatically determine if a hard drive is currently spinning or not (Windows 7 or later)? I tried GetDevicePowerState() but it always returns TRUE (always 1, not another non-zero value) for drives that I know are currently not spinning…
Not Submitted
  • 623
  • 5
  • 12
9
votes
1 answer

How to set minimum window size using WinApi

now I'm creating app with WinApi and I need to have GUI window which has to be at least 300x300 size, how can I set this low boundry. Thanks.
user3394586
  • 131
  • 1
  • 4
9
votes
5 answers

Is it safe to change this c-cast to a reinterpret_cast?

I'm trying to remove a c-style cast from some code I'm working on, and I have concerns about the only alternative. The original code was: WPARAM param = (WPARAM)(GetDlgItem(IDC_WORKFLOW).m_hWnd); this->PostMessage(WM_NEXTDLGCTL, param, TRUE); If I…
deworde
  • 2,481
  • 3
  • 28
  • 55
9
votes
1 answer

Cannot convert from uint32_t* to LPDWORD

I'm trying to call the Windows API function GetExitCodeProcess which takes a LPDWORD as its second parameter. According to MSDN, LPDWORD is a pointer to an unsigned 32-bit value. So I tried to pass a uint32_t*, but the compiler (MSVC 11.0) is not…
Robert Hegner
  • 8,196
  • 6
  • 51
  • 89
1 2 3
99
100