winapi

LogonUser returns true for a wrong password

时光怂恿深爱的人放手 提交于 2021-02-20 19:02:29
问题 bool bRet=LogonUser(strUserName, L"", strPassword, LOGON32_LOGON_TYPE_NEW_CREDENTIALS, LOGON32_PROVIDER_WINNT50, &phToken) bRet always returns true even if I enter a wrong password when there is no domain. Is there any work around like if I enter a valid password it returns true and false for a wrong password when there is no domain. 回答1: I assume that by LOGON32_LOGON_TYPE_NEW_CREDENTIALS you actually mean LOGON32_LOGON_NEW_CREDENTIALS . In which case the behaviour is exactly as would be

How to prevent GetOpenFileName from changing the current directory while the dialog is shown?

为君一笑 提交于 2021-02-20 04:26:06
问题 GetOpenFileName (for questionable reasons) changes the current directory of an application while the dialog is shown. This can be reset on dialog closure by specifying OFN_NOCHANGEDIR as dialog initialization flag: OFN_NOCHANGEDIR Restores the current directory to its original value if the user changed the directory while searching for files. Setting this flag, however, doesn't prevent the function from changing the current directory while the explorer dialog is shown . This is an issue in

How to get token of logged-in user from within windows service with C++?

我是研究僧i 提交于 2021-02-20 03:55:30
问题 on windows vista & above, currently, I am enumerating all windows sessions, then once I find an active session, WTSQueryUserToken() is called which gives me the token of current user. This token is used to launch a process with his privileges / inside his desktop. Problem I am facing is that there is not reliable way to get the active session / interactive session. I have to wait (check its presence every few millsecs) until explorer.exe is spawned. I am not preferring notifications like

How would my program listen to OutputDebugString output and allow launch of multiple instances?

馋奶兔 提交于 2021-02-19 23:41:26
问题 Here's my scenario: I have a program which produces debug output with OutputDebugString() which maybe contains messages indicating bugs. I want to run this program inside daily build and automatically listen to debug output, parse it and report suspicious output. There're several examples of such listener implementations, for example this one. They all do the same - listen to a system-wide event and then read data from a file mapping. The problem is this protocol allows for only one instance

Is it safe to use LPCTSTR in a structure with the WM_COPYDATA message?

谁说我不能喝 提交于 2021-02-19 08:37:05
问题 I have this structure: typedef struct tagCOPY_PACKET { TCHAR szFile[_MAX_PATH]; GUID guidSignature; } S_COPY_PACKET; I prepare to send data with WM_COPYDATA like this: CString strFile = GetFileToOpenFromFileExplorerPath(); S_COPY_PACKET sCopyDataPacket; _tcscpy_s(sCopyDataPacket.szFile, _MAX_PATH, strFile); sCopyDataPacket.guidSignature = CopyData_Signature; COPYDATASTRUCT cds; cds.dwData = COPYDATA_TYPE_MSA; cds.cbData = sizeof(sCopyDataPacket); cds.lpData = &sCopyDataPacket; DWORD_PTR

SetCursor while dragging files into a window

时光毁灭记忆、已成空白 提交于 2021-02-19 08:01:28
问题 I'm using windows API to create an application with a window only, so everything inside this window is drawn using Direct2D. Now I want to drop some files in specific parts of my window's client area, and I'm handling the message WM_DROPFILES . No problem here, when the files are dropped in those specific areas, I can treat them correctly and everything is working properly. BTW, my window is DragAcceptFiles(hWnd, true) , it always accepts drag/drops. I want the mouse cursor to be different

QueryWorkingSet includes invalid pages in its result

若如初见. 提交于 2021-02-19 06:35:22
问题 I'm currently using a 64-bit Windows 7 with I'm using Windows 7. I'm playing around with some PSAPI (Process Status API) functions to learn a bit more about how Windows manages memory. I noticed, however, that QueryWorkingSet included entries from which I couldn't read (e.g. page 0, and you can't read 0x00000000 ). When trying it on 64-bit, it became apparent why this was the case: QueryWorkingSet is bugged on 32-bit, as the addresses are truncated (hence the multiple page 0 entries). Still,

Win32 Console Disable System Menu Buttons

拟墨画扇 提交于 2021-02-19 06:30:48
问题 I want to disable/grey a system menu button on the console window, particularly the minimize button. I've tried functions mentioned on another thread, but even after using them, the console window still doesn't have the minimize button grayed out. I have also looked into the DeleteMenu() function, but it doesn't seem to have the option to grey out buttons. Here's the test code: #include <Windows.h> using namespace std; int main() { //SetConsoleTitle(L"CPU Information"); HWND consoleWindow =

create transparent image from png, winapi

*爱你&永不变心* 提交于 2021-02-19 05:45:12
问题 I created a simple form to test in winapi: I uploaded here: http://pastebin.com/7dNjE1Tb I would like to put a simple png file to my hwnd, for example this picture: http://www.ledavi-network.com/includes/images/bg_shadow_png.png I know I should use this: http://msdn.microsoft.com/en-us/library/windows/desktop/dd145141(v=vs.85).aspx but I am very new in winapi and I dont find any example how to use this TransparentBlt function. Someone could help me to create a very simple example? EDIT: But

How do I convert a stdole.StdPicture to a different Type?

有些话、适合烂在心里 提交于 2021-02-19 05:02:48
问题 To receive the bounty, please provide an answer with working code. Thanks. I have a stdole.StdPicture Object of the Type vbPicTypeIcon. I need to convert it to Type vbPicTypeBitmap. Due to project contraints, I need to be able to do this using Win32 or VBA. I am trying to load a file's icon to a command bar button. Here is what I have so far. It produces a lovely black square:) I am really new to graphics land so pardon me if it's a basic question. Option Explicit Private Const