winapi

App created in Visual Studio on XP 32 crashes 64 on access violation. Recompile in 64 bit environment to find bug, works fine. What?

So I've been developing on Windows XP Visual Studio 2008. I guess it is building my C++ app in 32 bit mode. When I run the program on my new Windows 7 64 bit box, it gets half way through loading a then throws an access violation error. So, I loaded all my development tool and recompiled the project on Windows 7 to find the crash site bu...

Windows keyboard accelerators and child windows

I have created a Windows GUI program using C and the Windows API, and I want the program to utilise keyboard accelerators. I have set up some accelerators, which are working correctly, but when focus goes to a child Window of my program's main window, such as a list view control or a status bar control, it appears that the keyboard accel...

Load jpg file in winapi

Hi all, I want to load a jpg file. I tried to use the LoadImage function but it returns NULL if my image is not bmp. What can I do? Here is my code: hBitmap =(HBITMAP)LoadImage(0, L"D:\\1.jpg", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE). ...

How can I handle window messages from a separate thread?

I wish to launch a separate thread for handling window messages (via a blocking GetMessage loop), but still create the windows in the initial thread, afterward. Within the separate thread, as soon as it launches, I am calling PeekMessage with PM_NOREMOVE to ensure a message queue exists (is this necessary?), followed by.. AttachThreadI...

SetCursorPos and GetCursorPos not working at login screen?

When I attempt to use SetCursorPos at the Windows Vista/7 login screen, true is returned which at first made me think it was working. However, when I call GetCursorPos it gives me: -858993460,-858993460 Any thoughts why? Is this a "security feature" or am I using it incorrectly? The code works fine on non-login (i.e. normal) desktop. ...

How to make a shell?

How does one make a shell ? -That can run console applications like FAR Manager with the colors and all... Redirecting the console output doesn't seem to be enough. -PowerShell does seem to do it without using cmd.exe. The end game would be to create a graphical shell (not using the default console). So from what I gathered, I would ne...

Where is the .emacs file in windows GNU emacs

Where is the .emacs file in windows (I'm using Emacs-23-CvsP091103-EmacsW32-1.58 ) When Emacs starts up, it attempts to load and execute the contents of a file commonly called .emacs (though it may have other names, see Where do I put my init file?) which contains any customizations you have made. You can manually add lis...

Is there a way to _get_ the UnhandledExceptionFilter?

SetUnhandledExceptionFilter() lets me install a function that gets called in case of an unhandled exception. I'm looking for a way to get the currently installed function, so I can store&restore it. I can't seem to find a Get equivalent of the SetUnhandledExceptionFilter call, and am wondering if I'm missing something or if it's just...

How can I get functionality similar to Spy++ in my C# app?

I'm interested in working on a plugin for Keepass, the open-source password manager. Right now, Keepass currently detects what password to copy/paste for you based off of the window title. This prevents Keepass from detecting the current password you need for apps that don't actively update their window title based on the current site...

Does WaitForSingleObject Serve as a Memory Barrier?

A question yesterday about doubled-checked locking started a chain of thoughts that left me unsure about a simple situation. In the following code, is it possible to hit the printf of “No longer in sync”? In this simple example, the values would likely be on the same cache line, so I think it would be less likely (assuming the possibili...

Windows 7 - Taskbar - Pin or Unpin Program Links

As in title, is there any Win32 API to do that? Thanks in advance. ...

How do I create Modal dialog in worker thread(Non-UI thread)?

I have written a sample MFC application in which there are two threads: -Main thread ( UI thread) -Worker thread ( non-UI thread) I have a specific requirement to create a Modal dialog in Non-UI ( worker thread). When I create the CDialog object and call DoModal on the same, it works. The dialog gets created and acts as Modal t...

Tcp Socket + send() error #10054

Hi, I am working on a sample application which sends file to other device. I have 2 buttons on my window, one is to send and other is to stop file transfer. Send; send the file to destination and Stop: stops the sending process. When I send the multiple files to destination, all files reach destination properly. But if I click send a...

OutlookExpress IStoreNamespace GetFirstSubFolder method fails on WinXP x64

HRESULT error code - MSOEAPI_E_INVALID_STRUCT_SIZE Works fine on WinXP x32. ...

Incorrect Battery Reading after using the GetSystemPowerStatus API

Hi, I was writing an application to read the laptop battery charge using the GetSystemPowerStatus API. This API was called every second (from a timer control) and the value of bytBatteryLifePercent in the returned data-structure was passed to a progress-bar in order to display the battery charge. The application was written in VB 2005 ...

Global KeyHook in WPF application

I need my WPF application to gain focus whenever the user press "window key + s". My solution was to hook to the keyboard event with SetWindowsHookEx. however the handle I get in return is always 0. when I call to GetLastWin32Error the value is also 0 (i.e. so it actually reports that the previous operation succeeded) _hookHandle = Set...

Function pointers for winapi functions (stdcall/cdecl)

Please could someone give me a few tips for creating function pointers for MS winapi functions? I'm trying to create a pointer for DefWindowProc (DefWindowProcA/DefWindowProcW) but getting this error: LRESULT (*dwp)(HWND, UINT, WPARAM, LPARAM) = &DefWindowProc; error C2440: 'initializing' : cannot convert from 'LRESULT (__stdcall *)(H...

Determining which visual style is used?

Is there a method to determine which visual style (Classic, "XP Style", Aero, etc') is currently used? App is native, so .net solutions are out. ...

Win API VirtualQueryEx Function,ERROR_BAD_LENGTH

Hi I try to call the VirtualQueryEx function to get some Information about Memory Protection, however my code gives me error 0x18 (ERROR_BAD_LENGTH) and i dont know whats wrong with my code; code snippet: PMEMORY_BASIC_INFORMATION alte; VirtualQueryEx(processhandle,(LPVOID) (address),alte,sizeof(PMEMORY_BASIC_INFORMATION)); thanks fo...

Help with using CreateProcessWithLogonW in C#

I am trying to execute a console app with arguments inside asp.net (C#) on Windows XP. I have tried diagnostics.Process but I just can't get it to work so I am switching to CreateProcessWithLogonW. I used the code sample from http://www.pinvoke.net/default.aspx/advapi32.createprocesswithlogonw but the console app doesn't seem to run an...