winapi

Hyperlinks without underline in RichTextBox on Windows 10 1803

倖福魔咒の 提交于 2021-02-18 10:21:08
问题 I'm displaying RTF document in RichTextBox ("upgraded" to RichEdit50W ). Keywords in the document are linked to a webpage using a syntax: {\field{\*\fldinst{HYPERLINK ""https://www.example.com/"" }}{\fldrslt{\cf1 keyword\cf0 }}} I do not want to underline the keywords. Until Windows 10 version 1803 (and in all previous versions of Windows, including XP, Vista, 8), whenever a color was set on the anchor (note the \cf1 ), the anchor was not underlined. But this no longer works in Windows 10

Windows - Wait on event and socket simulatenously

烂漫一生 提交于 2021-02-18 07:47:59
问题 I'm writing Win32-API C code that needs to wait for new TCP connections and on the other side can be closed at any time by any other process/thread. Therefore, I need to somehow WaitForSingleObject on the stop event and wait for connections using WSAAccept simultaneously. I tried WaitForMultipleObjects on both socket and handle but new connection won't trigger the function (also WaitForSingleObject on the socket won't be triggered on a new connection). Any idea? 回答1: You need to use

Escalate Privilege at Runtime (Windows API C/C++)

て烟熏妆下的殇ゞ 提交于 2021-02-18 06:28:13
问题 My application does not always require "admin" privileges and most of the time would run as the current user. Is there any way, I can escalate privs by throwing up a UAC at runtime after my program is already running? This will only happen as and when I need privs. Rather than having to start with high privs. I know the "runas" technique, manifest file etc. but all these are before the process is created and not at runtime, on-demand 回答1: Congratulations, that's exactly how UAC is designed to

WASAPI: Play sine wave sound in minimum latency without glitches (exclusive-event driven mode)

穿精又带淫゛_ 提交于 2021-02-18 03:26:47
问题 I'm trying to play a simple sineous waveform using the Windows Audio Session API (WASAPI) in exclusive mode, but encountering sound glitches no matter what I do. I've been using the MSDN Exclusive-Mode Streams example as a reference point, and here's how the slightly adapted code currently looks like. Setup code: -- <variable declarations, incl. "HRESULT hr; BYTE *pData;" > -- // also, hr is checked for errors every step of the way hr = CoCreateInstance( CLSID_MMDeviceEnumerator, NULL, CLSCTX

Get user picture

一笑奈何 提交于 2021-02-17 20:51:51
问题 OS: Win7x64 (2008,2008r2). Lang: Delphi Xe2. How to receive a full path (and file name) to the image "user account picture"? How to set new picture? Example on delphi plz. Need: ...function GetCurrentUserPicture:string; ...function GetUserPicture(UserName:String):string; ...function SetUserNewPicture(UserName, ImageFileName:String):bool; 回答1: There is an undocumented function in shell32.dll. On Windows XP its ordinal is 233, on Windows Vista and 7 its ordinal is 261. Its function prototype

How can I ensure that the virtual memory address allocated by VirtualAlloc is between 2-4GB

依然范特西╮ 提交于 2021-02-17 07:14:16
问题 I tried to use while , but the effect is not very good. Is there any way to do it? bool found = false; uintptr_t memaddr = 0; int n = 0; while (!found && n < 10) { n += 1; memaddr = (uintptr_t)VirtualAlloc(0, 4, MEM_COMMIT, PAGE_EXECUTE_READWRITE); int g = memaddr / 1024 / 1024 / 1024; cout << "memaddr: " << memaddr << endl; if (g >= 2 && g <= 4) { found = true; } } cout << hex << memaddr << endl; 回答1: Use the lpAddress parameter of VirtualAlloc #include "pch.h" #include <iostream> #include

How can I ensure that the virtual memory address allocated by VirtualAlloc is between 2-4GB

与世无争的帅哥 提交于 2021-02-17 07:13:27
问题 I tried to use while , but the effect is not very good. Is there any way to do it? bool found = false; uintptr_t memaddr = 0; int n = 0; while (!found && n < 10) { n += 1; memaddr = (uintptr_t)VirtualAlloc(0, 4, MEM_COMMIT, PAGE_EXECUTE_READWRITE); int g = memaddr / 1024 / 1024 / 1024; cout << "memaddr: " << memaddr << endl; if (g >= 2 && g <= 4) { found = true; } } cout << hex << memaddr << endl; 回答1: Use the lpAddress parameter of VirtualAlloc #include "pch.h" #include <iostream> #include

Visual studio wont work with “MoveTo” (win32api)

不想你离开。 提交于 2021-02-17 07:11:23
问题 Here's the code below, VS said that on line 109 ( MoveTo(hdc, x, y); "MoveTo" is undefined . Can someone explain me what's wrong ? This is a win32api application. // Win32Project.cpp : Defines the entry point for the application. // #include "stdafx.h" #include "Win32Project4.h" #include <windows.h> #include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> LRESULT CALLBACK ChildWndProc(HWND, UINT, WPARAM, LPARAM); LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); int

CreateFile not able to share serial (COM) port

南楼画角 提交于 2021-02-17 06:46:21
问题 The CreateFile function is useful for opening files or devices for read/write access, providing a handle. The third parameter, dwShareMode , specifies if the file/device can later be accessed by others. An example, with files: void* pFileHandle1 = ::CreateFileA("C:\\test.txt", GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0); DWORD lastError = GetLastError(); // 0, ERROR_SUCCESS void* pFileHandle2 = ::CreateFileA("C:\\test.txt", GENERIC_READ|GENERIC_WRITE,

C: Fastest way to determine, if any key on the keyboard has been pressed

梦想与她 提交于 2021-02-17 05:56:38
问题 I am searching for the fastest possible way in C to determine if any key on the keyboard has been pressed. I am not looking for how to determine if a specific key is pressed (in that case, GetAsyncKeyState() would work). Also, it needs to work in the background, so without the program window having focus (the program will be running in the background). EDIT: The program will react on every keypress with a sound output. I want it to output a sound everytime I type something (like in Word and