winapi

cant make sense of LARGE_INTEGER struct

Hello fellow SOers, I'm asking this mainly out of curiousity. I am not really a C(++) Coder but to widen my horizon I try to dive in other areas every now and then. When doing this with C++ and some Winapi things, I encountered this guy: #if defined(MIDL_PASS) typedef struct _LARGE_INTEGER { #else // MIDL_PASS typedef union _LARGE_INTE...

how to access defines and structs inside a .h from C#/.NET?

In accessing PDH.dll (a Win32 API) (see link) using P/Invoke, it turns out that I need access to several constants and structs. I found these are defined inside a file PDH.h. How do I access these defines and structs? Do I have to rewrite them with C#? Is there another way? ...

How correctly show hidden transparent window when contents changed

I have a layered (semi-transparent window) created with WS_EX_LAYERED and adjusted with SetLayeredWindowAttributes(... LWA_ALPHA). I have to show and hide it from time to time, but since last hide there are cases when the image is going to be changed significally. But SetWindowPos and ShowWindow at first shows the previous image (possibl...

How Windows Static Control Prevent Input Focus

We know that Static Control in Windows does not receive input focus. But since Static Control in Windows is just a child window, according to what I understand so far, any window should be given input focus when we click on it. So how does Static control achieve this effect of rejecting input focus? I suspect it has special processing ...

Launch user mode process from Admin mode process

I have a win32 process running as admin mode. I cannot change the fact it's running in admin mode. I have an executable on my system which I'd like to launch from that admin process, but have it run in user mode. How do I achieve that? ...

Why does MAKEINTRESOURCE() work?

Hi, The macro is defined as: #define MAKEINTRESOURCEA(i) ((LPSTR)((ULONG_PTR)((WORD)(i)))) #define MAKEINTRESOURCEW(i) ((LPWSTR)((ULONG_PTR)((WORD)(i)))) How come this can be used to indicate either a resource ID (a 16-bit unsigned int) or its name (a pointer to an array of char)? Doesn't this effectively limit the address space (on ...

InternetOpenUrl intermittently times out

I have some InternetOpenUrl requests that are strangely timing out. The endpoint is there and the URL is correct. This happens in a synchronous loop inside an activex control, and about the 6th time it executes, it times out without hitting the server. HINTERNET hINet = InternetOpen(TEXT("InetURL/1.0"), INTERNET_OPEN_TYPE_PRECONFIG, NUL...

What exactly is "application-defined" about UnhandledExceptionFilter?

MSDN describes UnhandledExceptionFilter as follows: "An application-defined function that passes unhandled exceptions to the debugger, if the process is being debugged." But this function is clearly supplied by the OS, in kernel32.dll according to that same page. So why do they call it an application-defined function? ...

HBRUSH to RGB value

Can you get the RGB value from HBRUSH or from brush id? for example: I'm looking for GRAY_BRUSH in RGB value. ...

Need help with WM_KEYDOWN

I need help with WM_KEYDOWN, I want to remove the "pause" between the first keypress and the repeating keypresses. If you continually hold down a button, I want the program to realize it directly. Im trying to make a game with directx. Please tell me if I should use something else than WM_KEYDOWN. ...

C++ COM design. Composition vs multiple inheritance

I'm trying to embed a browser control in my application (IWebBrowser2). I need to implement IDispatch, IDocHostShowUI, IDocHostUIHandler etc to make this work. I am doing this in pure C++/Win32 api. I'm not using ATL, MFC or any other framework. I have a main class, called TWebf, that creates a Win32 window to put the browser control in...

Prevent default click event (WinAPI)

I'm making a color dropper tool and while this tool is active, when the user clicks or taps I only want it to run my mouse event, not anything else,so while this tool is running,if the user clicks the start orb, it should not open the start menu (or if the user clicks anything else). How could I do this? Thanks ...

Read text file (Unicode) in 'C' using native Win32

I have a line-oriented text file (Unicode) that was created using CreateFile() and WriteFile(). Reading that file as a binary stream using ReadFile() is straightforward, but extra low-level processing is needed to break it into lines. Is there a Win32 function that does this for me? Again, please note that it's in 'C' (not C++) and I ...

Can you set a DDB on Static Picture Control

I have the picture control created with SS_BITMAP style and bitmap created on a memory DC. so can or how can you set the HBITMAP of a DDB for the control? It doesn't work with using: Edit: HDC hDC = GetDC(hPB); //hPB, Handle to static control. HDC hMemDC = ::CreateCompatibleDC(hDC); HBITMAP hDDB = ::CreateCompatibleBitmap(h...

Can stdcall have a variable arguments?

As far as I know, only the caller-clean-stack convention can use variable arguments. By the way, the WinApi StringCchPrintfW is declared like this.(I removed the SAL) _inline HRESULT _stdcall StringCchPrintfW( STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat, ... ); Can stdcall have a variable arguments eithe...

Custom made win32 drag-drop, can't get change invalid (slashed circle ) cursor.

Hi, I've a quite difficult problem to explain but I will try my best. I've made a custom drag-drop implementation to a win32 GUI based application. Due to limitations of the program I can't use the proper OLE drag-drop mechanism. Its okey, I made my own with mouse key tracking and it works so so. The only problem I can't solve now is t...

AccessViolationException when calling Marshal.PtrToStructure

Hi, I'm getting an AccessViolationExcpetion by calling Marshal.PtrToStructure(intPtr, typeof(Servent)). Any ideas what I have done wrong? I tried this on x64. IntPtr intPtr = NativeMethods.GetServByName(name, "tcp"); if (intPtr != IntPtr.Zero) { Servent servent = (Servent)Marshal.PtrToStructure(intPtr, typeof(Ser...

Weird Debugger Behavior

The following code snippet behaves in Debug mode (VC++ 2005) differently than in Release: HANDLE hFileRead; hFileRead = CreateFile(pszListFile, // lpFileName, GENERIC_READ, // dwDesiredAccess, FILE_SHARE_READ, // dwShareMode, NULL, ...

I get an invalid query error when I add WHERE Name =

public static void Command(string vCommand, string machineName, string username, string password) { ManagementScope Scope = null; ConnectionOptions ConnOptions = null; ObjectQuery ObjQuery = null; ManagementObjectSearcher ObjSearcher = null; try ...

I get an "Invalid Name" error when I try to use "CopyEx".

Regarding my previous problem that is now fixed, I got another problem with the //code here part :/ foreach (ManagementObject obj in ObjSearcher.Get()) { ManagementBaseObject inputArgs = obj.GetMethodParameters("CopyEx"); inputArgs["FileName"] = "\\c:\\1stuff"; inputArgs["Recursive"] = true; ManagementBaseObject outPar...