winapi

Copy-on-write file mapping on windows

≡放荡痞女 提交于 2021-02-19 04:01:46
问题 I have 3 processes communicating over named pipes: server, writer, reader. The basic idea is that the writer can store huge (~GB) binary blobs on the server , and the reader(s) can retrieve it. But instead of sending data on the named pipe, memory mapping is used. The server creates an unnamed file-backed mapping with CreateFileMapping with PAGE_READWRITE protection, then duplicates the handle into the writer . After the writer has done its job, the handle is duplicated into any number of

WndProc calling mechanism (WinAPI)

*爱你&永不变心* 提交于 2021-02-19 03:52:51
问题 I'm trying to understand how a windows application works. There is a WndProc function, wherein message processing occurs. LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_KEYDOWN: if (wParam == VK_ESCAPE) { if (MessageBox(0, L"Are you sure?", L"Exit?", MB_YESNO | MB_ICONQUESTION) == IDYES) //Release the windows allocated memory DestroyWindow(hwnd); } return 0; case WM_DESTROY: PostQuitMessage(0); return 0; } return DefWindowProc(hwnd, msg,

LoadLibraryEx ignores side-by-side manifest

亡梦爱人 提交于 2021-02-19 01:34:49
问题 Does LoadLibraryEx function use side-by-side manifests? I have bar.dll with embedded SxS manifest, and that manifest describes version of this bar.dll, other dll file foo.dll has manifest that lists bar.dll as dependency, with specified version. But when I try to load bar.dll from foo.dll with LoadLibraryEx("bar.dll", NULL, 0) I see (with enabled sls with gflags) that it ignores these manifests, and loads first version of bar.dll that it sees in searchpath, if I define ISOLATION_AWARE_ENABLED

mciSendString won't play an audio file if path is too long

人走茶凉 提交于 2021-02-19 01:30:08
问题 When the path+filename of a file is really long, I've noticed that PlaySound(fName.c_str(), NULL, SND_ASYNC); works, but not mciSendString((L"open \"" + fName + L"\" type waveaudio alias sample").c_str(), NULL, 0, NULL); mciSendString(L"play sample", NULL, 0, NULL); Example of failing command: open "C:\qisdjqldlkjsqdjqdqjslkdjqlksjlkdjqsldjlqjsdjqdksq\dajdjqjdlqjdlkjazejoizajoijoifjoifjdsfjsfszjfoijdsjfoijdsoifoidsjfojdsofjdsoijfoisjfoijoisdjfosjfqsd\Windows Critical Stop.wav" type waveaudio

Handling drag and drop files in a running Windows console application

谁说我不能喝 提交于 2021-02-19 01:06:24
问题 First, to clarify, I am not asking how to drag-and-drop a file onto an exe's icon. I want to know how to handle drag and drop onto an already running win32 console application. I'm also not asking how to handle drag and drop inside of WinMain based applications through the Windows message pump. I want to do this inside of a program with the entry point int main() that doesn't have a WndProc (yet) or anything. That said, I'm wondering if my goal is achievable (and hoping that it is). I have a

How to get the SID and User Name of the user utilising my service in C++

旧巷老猫 提交于 2021-02-18 18:14:21
问题 I am attempting to create a service that will essentially act as a local web server. In theory users will use a REST API by visiting URIs through localhost in a browser i.e. http://localhost:2017/path/to/function/call will connect to the service and execute a function. My question is how do I get the SID and User Name of the account that called the service? I have implemented a couple of solutions but they return the SID and User Name of the service and not the user using it. OJSon*

AddFontResource + SetCurrentConsoleFontEx are not changing a console font

白昼怎懂夜的黑 提交于 2021-02-18 17:53:28
问题 I'm trying to change a console font to a custom one, but this specific code piece doesn't seem to acomplish anything, even though this is what I came up while trying to find a solution around the Internet. I tested just the SetCurrentConsoleFontEx with this custom font by installing and adding it to the console with regestry by hand, and it's been functioning properly. #include <iostream> #include <Windows.h> int main() { std::cout << "Default font" << std::endl; system("pause"); HANDLE m

Draw HBITMAP onto layered window. What's wrong?

青春壹個敷衍的年華 提交于 2021-02-18 17:44:06
问题 Hello and good day to everyone, my final target is to draw a PNG file including alpha onto the screen - that means not into an own window but just somewhere on the desktop. The part to load PNG's into a HBITMAP works now (tested that in a diffrent way) but I don't manage to draw it including alpha. As far as I've heard the best way to do this would be using alyered windows. So I wroked a lot to redo a couple of examples and tiny tutorials. The following code compiles without problems and

How do I change the font of a control in WinApi C++?

烂漫一生 提交于 2021-02-18 15:03:15
问题 How do I change the font of an edit control in win32 API. I would like to be able to edit the style as well as the color of a font on a edit control. 回答1: First you should clarify that you're talking about a standard Edit control versus a Rich Edit control - the two are totally different. You can change the font by sending a WM_SETFONT message to the edit control. Setting the color is a totally different process. You can set the text color by responding to the WM_CTLCOLOREDIT message in the

Win API for changing input language programmatically

旧时模样 提交于 2021-02-18 11:31:20
问题 I want to change the input language in WinXP to Spanish, programmatically. Is there an API to support that? Thanks 回答1: LoadKeyboardLayout ActivateKeyboardLayout GetKeyboardLayout etc. 回答2: i managed to do it with keyboard events & shortcut assignment. go to "text services and input language" (that's how it's called windows 7 control panel) assign keys for the uni-directional language. e.g. "To English", and "To Hebrew". I've chosen Alt-Shift-7 and Alt-Shift-8, because they're rarely used