winapi

How to set up Win32 tooltips control with dynamic unicode text?

I am having some trouble provding a Win32 tooltips control with dynamic text in unicode format. I use the following code to set up the control: INITCOMMONCONTROLSEX icc; icc.dwSize = sizeof(INITCOMMONCONTROLSEX); icc.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx( HWND hwnd_tip = CreateWindowExW(0, TOOLTIPS_CLASSW, NULL, WS_POPUP |...

What is Windows programming and where it is headed? Honestly win32 is dead, isn't it?

Duplicate: How relevant is Win32 programming to modern professionals? Does it still make sense to learn low level WinAPI programming? I recently read a blog entry about someone asking for a good book on windows programming. He was disturbed by the fact that most books he found are about 10 years old and probably outdated...

How to check if a pointer is valid?

I am well aware of the ugliness of this question, I'd still like to know if it's possible: When a program tries to read/write to an invalid pointer (NULL, unallocated block, etc') windows crashes the application with an access violation exception. The question is, is there a way to check wether this pointer will generate an exception b...

LogonUser works only for my domain

I need to impersonate a user using C#. I use the LogonUser Win32 API. This works fine when impersonating users from the same domain as the currently logged-in user. However I get "false" as response when I try to impersonate users from other domains. What can cause this? ...

What is a Windows API?

What is a Windows API? ...

What's the cost of CreateFile()?

I want to write data in a file frequently , I wonder if I call CreateFile() each time I write it, Does this way cost so much than the way that I just call it once ,then use the handle many times? ...

SEH, access violation and stack guard page

I've posted a question about validating a pointer's accessibility. The conclusion was either to use IsBadReadPtr to check the pointer, or SEH to catch the exception (and preferably to use neither, and debug the application, but that's not the issue here). IsBadReadPtr is said to be bad because, among other reasons, it would try to read ...

Determining Client Internet Connection (InternetGetConnectedState() lies)

It seems I am not the only one to have discovered this: http://forums.devx.com/showthread.php?t=72771 Actually both: InternetGetConnectedState InternetGetConnectedStateEx are not reporting correctly. When I am connected, it returns 0x12 and when I an not connected it returns 0x10 (0x10 is not defined) http://msdn.microsoft.com/en-us/...

SetWindowsHookEx - Dll Injection misses out on the first few calls

Hi, I am trying to use SetWindowsHookEx to capture calls to a API in java.dll. So I created another dll, and injected into all other processes using setwindowsHookEx g_hHook = SetWindowsHookEx(WH_CALLWNDPROC, JLoadSetFunc, g_hHookDll, 0) The problem is following: While trying to capture calls from a process, I notice that my dll ge...

What are the Win32APIs corresponding to the "Parent" and "Owner" Window values displayed by MS Spy++?

I'd like to obtain the same values via code. However I'd like to obtain the top-most or root windows in the hierarchy I seem to have got the Root Parent with HWND rootWinHandle = GetAncestor(activatedWinHandle, GA_PARENT); However I can't get the owner window correctly. Tried HWND rootOwnerWinHandle = GetAncestor(activatedWinHandle,...

LogonUser and delegation

I'm using the LogonUser win32 api: token = LogonUser(...) WindowsIdentity newId = new WindowsIdentity(token); WindowsImpersonationContext impersonatedUser = newId.Impersonate(); However when calling a WCF service after this I'm not able to use the impersonated identity. I think this is because impersonatedUser.Impersonatio...

SetPosition

Task: grabbing arbitrary frames from mpeg2 video files. Now I use custom render filter for grabbing, but problem with positioning video on required frame. I use SetPosition(), after Pause() for passing frames through graph, wait for filter receive first frame and Stop(). If I get frame by frame, first i receive exact for this time fr...

What is the easiest way to call a Windows kernel function from Java?

While searching for how to do this, I found some vague discussion about different options, like JNI vs JNA, but not much in the way of concrete examples. Context: if Java's File.renameTo() cannot do it's job (for whatever reason; it is a little problematic), I'd like to fall back to directly using this native Windows function, which is ...

How to get the handle of the topmost form in a WinForm app?

I have a WinForm app that has other child forms (not mdi). If the user presses "Esc" the topmost form should be closed even if it doesn't have the focus. I can use a keyboard hook to globally catch the Escape but I also need the handle of the form to be closed. I guess there is a way to do that using Win32 API, but is there a solution...

NotifyAddrChange keeps generating events

I've been trying to detect the arrival of a new RNDIS device (Windows Mobile phone) using NotifyAddrChange(). This works, in the sense that I can wait on the event and then call GetAdaptersAddresses(). However, the event keeps firing but nothing seems to change. I'm not sure what causes this. Speculation: Could it be that when RNDIS al...

Detecting AC Power connection in WinPE?

I'm trying to determine if a laptop is connected to AC power. The OS Im running under is WinPE. My app is written in native C++. WMI queries using Win32_Battery are not supported and the GetSystemPowerStatus API always returns '1' for ACLineStatus (running on AC power or not). Any ideas? Additonal investigation: Just tried the API '...

What line of code could I use in C++ to disable energy saver?

I want to prevent the monitor from going to sleep (the windows setting, not the monitor setting). I am using c++. What call do I make? ...

Retrieving available font sizes on Windows

When I open the Windows Common Font Dialog, it lists, for each font, a bunch of sizes. For all of the OpenType/TrueType fonts, it has the same list - 9, 10, 11, 12, 14, 16, 18... For bitmap fonts, the list varies according to the available bitmaps. "Small fonts" has 2,3,4,5,6,7, while plain old Courier has 10, 12, 15. I don't know, b...

"Lock on the Kernel Object" on windows can make the entire system unresponsive?

There's this WIN32 process, which someone says: The servide takes a lock on the kernel object and does not release. After a while the machine becomes irresponsive and has to restarted. Restanting only the service won't fix the issue. According to my knowledge applications were not supposed to be able to crash the entire sys...

Is each source line address in a detailed MAP file a valid address to insert a Int3h?

I am trying to create a code coverage tool using Delphi 2007. My general approach is to use the Win32 Debug API to insert breakpoints for each source line and then remove the breakpoints as I pass them - thus I would be able to track each executed source line. Outline of my approach: parse the detailed MAP file (as generated by Delph...