winapi

Current memory usage display is always ~14MB more than task manager

耗尽温柔 提交于 2021-02-11 15:21:16
问题 I'm currently using the code in this answer, with some slight modifications as suggested in the comments. However, no matter how many objects I allocate in memory, the listed memory usage is always ~14MB more than what task manager lists. Why could this be? std::stringstream ss; PROCESS_MEMORY_COUNTERS_EX pmc; GetProcessMemoryInfo(GetCurrentProcess(), (PROCESS_MEMORY_COUNTERS*)&pmc, sizeof(pmc)); SIZE_T physMemUsedByMe = pmc.WorkingSetSize; ss << "\nMEM: " << (physMemUsedByMe / 1024 / 1024) <

Implement lens magnification to magnify the Windows Taskbar

谁说我不能喝 提交于 2021-02-11 15:19:13
问题 I want to be able to perform lens magnificaiton on top of the windows taskbar. So far I've been unsuccessful in implementing this seeing as the taskbar will always open on top of my window. Windows built-in magnifier is able to do this so I'm hoping it is indeed possible. I've attached two screenshots showing Windows built-in magnifier and how it is able to magnify the taskbar and how my application will render below the taskbar. Windows built-in Magnifier: My application: Is there any way to

Borderless Window Covers Taskbar

浪尽此生 提交于 2021-02-11 14:19:29
问题 I have a custom-made borderless window. When maximized, it covers the taskbar. This is not what I want. I have played with the WM_GETMINMAXINFO message. But, I have found that Windows 10 will then leave an extra 8-pixel gap along both the bottom and right side. It is an all-or-nothing proposition. Here is the first code that I tried: case WM_GETMINMAXINFO: PMINMAXINFO pmm; pmm = (PMINMAXINFO)lParam; pmm->ptMaxSize.x = GetSystemMetrics(SM_CXSCREEN); pmm->ptMaxSize.y = GetSystemMetrics(SM

Powershell and winapi SystemParametersInfo function

狂风中的少年 提交于 2021-02-11 14:02:28
问题 I was trying this: $f=@' [DllImport("user32.dll")]public static extern int SystemParametersInfo( int uAction, int uParam, int lpvParam, int fuWinIni ); '@ $mSpeed = Add-Type -memberDefinition $f -name "mSpeed" -namespace Win32Functions -passThru $get = 0x0070 $set = 0x0071 $srcSpeed = $mSpeed::SystemParametersInfo($get, 0, 0, 0) $newSpeed = $srcSpeed + 1 $mSpeed::SystemParametersInfo($set, 0, $newSpeed, 0) but the mouse speed does not return. How do I write this down correctly? 回答1: According

Can the Visual Studio IDE use long path names?

家住魔仙堡 提交于 2021-02-11 13:59:51
问题 I'm using VS 2017 on Windows 10 Enterprise build 1803 I ran into trouble with a project that is deeply nested in subfolders and then I remembered reading something about Windows 10 removing the limit on MAX_PATH. I found this link Naming Files, Paths, and Namespaces which suggests that a large number of Win32 API calls can optionally not be limited to MAX_PATH. I tried both toggling the value in the policy and changing the value in the registry. After a reboot Visual Studio still refuses to

Determining if the running executable has IMAGE_FILE_LARGE_ADDRESS_AWARE?

狂风中的少年 提交于 2021-02-11 13:54:30
问题 Is there some sort of Windows API or other reasonably straightforward way to determine whether or not the currently running program has IMAGE_FILE_LARGE_ADDRESS_AWARE enabled? I know that I can open up the process's exe as a file, read its header information, and parse it somewhere out of there, but if there's some cleaner way to do it, I'd like to know. To be clear: I am talking about the currently executing process - i.e. I want to write code that detects this flag (or lack thereof) for its

C++ winapi Taking Screenshot and Making It Background of Window

你说的曾经没有我的故事 提交于 2021-02-11 12:42:34
问题 I'm trying to make the snippingtool in c++. I managed to create a borderless, fullscreen window via this code; WindProc: LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { switch (message) { case WM_CHAR: //this is just for a program exit besides window's borders/taskbar if (wparam==VK_ESCAPE) { DestroyWindow(hwnd); } case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, message, wparam, lparam); } } Creating the window; WNDCLASS

WTSIsRemoteSession always returns TRUE

我们两清 提交于 2021-02-11 12:22:24
问题 I'm currently writing a Windows service, which also does something when a user logs on. There was the idea to do nothing if the logon comes from a remote computer (e.g. Remote desktop), and tried to find a way to dermine this. But following does not work - it always returns true (Windows 10 64 bit V1809) - is there something I doing wrong here? DWORD SvcHandlerEx(DWORD controlCode, DWORD eventType, ... ) { ... switch(controlCode) { case SERVICE_CONTROL_SESSIONCHANGE: { WTSSESSION_NOTIFICATION

SetWindowsHookEx - difference between VK_LSHIFT and “Search” keyboard button

折月煮酒 提交于 2021-02-11 12:20:37
问题 I use SetWindowsHookEx to catch keyboard events SetWindowsHookEx(WH_KEYBOARD_LL, HookCallback, NULL, 0) Here is HookCallback LRESULT __stdcall HookCallback(int nCode, WPARAM wParam, LPARAM lParam) { if (nCode >= 0) { // the action is valid: HC_ACTION. if (wParam == WM_KEYDOWN) { kbdStruct = *((KBDLLHOOKSTRUCT*)lParam); printf("%ld\n", kbdStruct.vkCode); } } } When press "left shift" output is 160 when press "search" button (button with loupe icon on notebooks) output is 160 91 132 How to

CreateTexture2D and CreateDepthStencilView failing

↘锁芯ラ 提交于 2021-02-11 09:50:59
问题 I am trying to learn Directx 11.0. I have encountered an error. This is the code. // include the basic windows header files and the Direct3D header files #include <windows.h> #include <windowsx.h> #include <d3d11.h> #include <d3dx11.h> #include <d3dx10.h> // include the Direct3D Library file #pragma comment (lib, "d3d11.lib") #pragma comment (lib, "d3dx11.lib") #pragma comment (lib, "d3dx10.lib") // define the screen resolution #define SCREEN_WIDTH 800 #define SCREEN_HEIGHT 600 // global