winapi

Does RTLCopyMemory work in Vista?

I've noticed that RTL*Move*Memory seems to work just fine. But when I try to use RTL*Copy*Memory I get: "Can't find DLL entry point RtlCopyMemory in kernel32". Here is my declare: Private Declare Sub CopyMem Lib "kernel32" Alias "RtlCopyMemory" ( _ ByVal dest As Long, _ ByVal source As Long, _ ByVal bytLen As Long) ...

Moving the mouse without acceleration in C++ using mouse_event

Right now when I try a loop that contains something like: mouse_event(MOUSEEVENTF_MOVE,dx,dy,0,0); The mouse tends to move more than (dx,dy). Researching this online, I think it's because of the acceleration applied by the operating system. How can I move the mouse an absolute amount? MOUSEEVENTF_ABSOLUTE seems to maybe be what I'm ...

C/C++ Copy file with automatic recursive folder/directory creation

In Win32 API, there is CopyFile that literally copies a file. However, this API doesn't create folders. For example, I'd like to copy C:\Data\output.txt to D:\Temp\Data\output.txt. But, the target folders, D:\Temp and D:\Temp\Data', do not exist. In this case, this API just fails. Is there a handy API that can automatically and recursiv...

My program prevents Windows from shutting down!

My wxwidgets program does not allow the computer to shutdown when the user clicks on Shutdown. I had issues with exiting the program normally so I've been calling exit() directly instead of deleting the top window as wxwidgets says to do. The exit workaround has been working but it seems wxwidgets can't exit when it receives shutdown win...

Is the IShellItemImageFactory interface, used for getting Vista/7 shell thumbnails, broken?

I want to use IShellItemImageFactory to retrieve the shell thumbnail of files. According to the MSDN docs, if I pass in a SIZE struct of 256x256, it should populate the HBITMAP parameter with a 256x256 bitmap, and if I use the SIIGBF_RESIZETOFIT flag, it should resize smaller thumbnails to 256x256. It doesn't. Instead, the result is a 25...

C# ULONG_PTR Equivelent

Hi there, I am having to pass a ULONG_PTR in unsafe code in C#. I understand that the reason for ULONG_PTR is to allow for a single codebase for both 32bit and 64bit operating systems. Is this a case for C#'s UIntPtr? Can I be confident when passing a .Net UIntPtr as an ULONG_PTR parameter? Thanks! ...

Win32 multiline edit control loses carriage returns on SetWindowText()

In my C++ Win32 GUI application I have a dialog with an edit control created from a dialog template: EDITTEXT IDC_EDIT_Id, X, Y, W, H, ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL Whenever I manually input multiline text with carriage returns and call GetWindowText() the retrieved text is broken into lines with CR ...

Parent Window creation

I know it is a very simple question but i currently cant create a parent window... My code: LRESULT CALLBACK WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) { static HWND paste; static HWND update_list; /*HWND changeuser = CreateWindow(0, 0, 0, 0, 0, x, y, ...

Implementing windows hooks using NativeWindow properly

Hi guys I dont have much of a C++ background but have successfully hooked a window and converted its msgs into raised events that my application can consume, Ive started by inheriting from NativeWindow and overriding WndProc and have determined the msgs that im interested in, WM_VSCROLL and WM_HSCROLL for instance. Firstly are there any...

Wrapper C# for kernel32.dll API

Any helper class anywhere which wrapps kernel32 APIs, with all functions-methods and structures? Or any wrapper generator? I want ALL methods of kernel32.dll in C# like this: [DllImport("kernel32.dll",EntryPoint="RtlMoveMemory")] public static extern void RtlMoveMemory(int des, int src, int count); [DllImport("kernel3...

Notification when Windows Dialog is opened

I want to do some processing when a particular dialog is opened but I am not able to find any way to get notification when that dialog is opened. Is there any way to get notification in application for opening of a particular windows dialog? The only available information about the dialog is its title and its unique. ...

How to set toolbar button height?

When adding buttons to a toolbar (using the old Windows API) I can't seem to find a way to change the height of a button. I need to be able to increase the button's height because I'm using large icons. I'm currently painting everything myself using custom draw because I wanted to be able to have icons with different widths which is not...

How to perform security check on a given path (from web server) to serve files

Hello, I need to write a small file serving component for web server. There are lots of issues serving files. Because "as-is" serving as big security hole, like this www.somesite.com/../../../../etc/passwd There are many issues including ".." resolving and many others like under windows there are many "unusual ways to refer to some pa...

How can I host a c# control in a win32 app?

Hi, I've developed a c# control, and I can reuse this in other c# apps and that works really well. However I want to host this control in a Win32 c++ app, is there a way to do this? I was wondering if it would work with managed c++, however I can't quite figure out if this is possible. Any help would be gratefully received. Cheers R...

Stop an application from being terminated, without entering the correct password? c#

Hi guys, I was just wondering is there anyway to stop application being terminated at all without a password being entered. Is it even possible? I've seen net nanny type applications do it so that the user is unable to terminate it in the Task Manager without putting a password in. can anyone help me?? thanks MAtt ...

Win32: How to get the process/thread that owns a mutex?

I'm working an application of which only one instance must exist at any given time. There are several possibilities to accomplish this: Check running processes for one matching our EXE's name (unreliable) Find the main window (unreliable, and I don't always have a main window) Create a mutex with a unique name (GUID) The mutex option...

Win32 IO Performance Problem

Recently I ran into a "fun" problem with the Microsoft implementation of the CRTL. tmpfile places temp files in the root directory and completely ignores the temp file directory. This has issues with users who do not have privileges to the root directory (say, on our cluster). Moreover, using _tempnam would require the application to rem...

Win32 development - String related datatypes in C++

Hi, I was going to start with Win32 app development. Before I could get the first window to display i was ready to give up! I was overwhelmed by the number of datatypes you need to know about before you can write a simple WinMain and WndProc. (unless you copy-paste of course!) Especially these - LPSTR LPCSTR LPWSTR LPCWSTR Can so...

How to handle Form caption right click

I'd like a context menu on the caption bar right click any tips/samples pref in c# ? UPDATE - for various reasons, right click on the form won't work because the form is not empty and the form is composited dynamically so.... ...

Win API: Hook every window show or process execution

Hi, We're planning to build some sort of single sign-on feature inside our app. It's clear to me that I'll have to go depp with Windows API to achieve reading and writing from legacy applications controls, but as far as I've searched and tested that's not the hardest part of the job. There's a point, however, that I couldn't figure ou...