winapi

C++ Sockets - Can i only send characters?

I'm using synchronised sockets with a win32 window, and using the send() and recv() function to send data over internet TCP; what i'm wondering, how would i send some integers or even my own class/structure over the tcp socket? because the send() function only lets me send characters. Would i just have to send characters and then maybe...

c++ screen shot

umm i know this can be done but no idea how to...how to capture screen shot using c++,im gonna be working with win32. please no mfc code... thanks Rami ...

WinAPI's MessageBox in Java

I'm looking for a quick and dirty way in Java to flash up a message box to the user, to return when they click OK. It's for an application termination condition, so I'm really not interested in oh here's mah JFrame and all the rest of it. The MessageBox function in the Windows API is exactly what I want, except I'm stuck in Javaland. Any...

EnumChildWindow and receiving a duplicate HWND

I am enumerating through the children of a given window with the help of EnumChildWindow. I want to store the received window handles (via EnumChildProc) in a collection. Is it guaranteed that the received handles are unique? According to the MSDN article it sounds like they are unique during the enumeration but I am not sure if I unders...

Convert java.util.Date object into a Windows FILETIME structure

I have a Java application and I need to call into a Windows DLL using JNA. The function I need to call actually takes a __int64 (internally it splits this into low/high portions of the FILETIME structure). Given a java.util.Date object, how can I convert it to the appropriate value formatted for a FILETIME? ...

Good or evil - SetParent() win32 API between different processes

The SetParent function takes a child and new parent window handle. This also seems to work when the child window is in a different Windows process. I have seen a post that claim this is not officially supported, but the current docs don't mention this any more. Is this a flaw in the current docs, or did this behavior change? HWND WINAP...

Detect drive letter of SD card hardware

Is there a way to programatically detect the driver letter of an SD card(s) on Windows? Does the method support internal and external SD card hardware? Thank you for your time. ...

C++/STL - Program crashes when accessing class pointer instance in a std::map

Okay, I have a function which reads a xml file and creates controls using new and stores them in public member variables of a class called Window: std::map<const char*, Button*> Buttons; std::map<const char*, TextBox*> TextBoxes; std::map<const char*, CheckBox*> CheckBoxes; The Button, TextBox and CheckBox classes are homemade wrapper...

Operator precedence for "<<" and "++" in VS2008 with optimization

I'm stuck with a weird VS2008 C++ issue, that looks like operator precedence is not respected. My question is what is the output of this: int i = 0; std::cout << ((i != 0) ? "Not zero " : "zero ") << ++i << std::endl; Normally the ++ has precedence over the <<, right? Or is the << considered like a function call giving it a hi...

How to set background color of window after I have registered it?

I am not using a dialog, im using my own custom class which i have registered and then used the CreateWindow call to create it, i have preset the background color to red when registering: WNDCLASSEX wc; wc.hbrBackground = CreateSolidBrush(RGB(255, 0, 0)); but now i want to change the background color at runtime, by e.g. clicking a...

C++/Win32 API - SetFocus to button does not work

HWND button = CreateWindowEx(0, "BUTTON", ...); SetFocus(button); // Button no get focus! :( Also, I have other controls on my form that I am able to SetFocus() to. Thanks, Martin ...

How to hook api calls in another application

I am trying to hook the ExtTextOut and DrawTextExt GDI method calls of another application. I know that I need to Use GetProcAddress to find the address of those methods in gdi32.dll, and overwrite the address in the process I want to hook with the address of my function. Then in my function I do what I need, then call the original fun...

How do I check if an NTAccount object represents a Group or a User?

When working with the access rules returned by GetAccessRules(True, True, GetType(System.Security.Principal.NTAccount)) how can I tell if the NTAccount object referenced in each rule is a user account or a group? Update: I was able to solve this as follows. Note, the intent of this code is to return True if the NTAccount is a grou...

PostThreadMessage sets GetLastError to 1444

In PostThreadMessage my thread ID is correct, but I am getting the error 1444 ("Invalid thread identifier. "). Anyone know how to fix it? ...

Named pipes: Many clients. How to be prudent with thread creation? Thread Pool?

Situation: I'm am using named pipes on Windows for IPC, using C++. The server creates a named pipe instance via CreateNamedPipe, and waits for clients to connect via ConnectNamedPipe. Everytime a client calls CreateFile to access the named pipe, the server creates a thread using CreateThread to service that client. After that, the ser...

How to scroll the scrollbar in external application via WinAPI?

Description I'm trying to test application coded in Delphi (VCL components by DevEx) with TestComplete. Application is built without debug info. I need to scroll TcxTreeList component. The problem is when I set Position property for this component's scrollbars content is not scrolled but scroll bar position changes. I tried a lot of ap...

invalid cruntime parameter _itoa_s

I have experienced a strange behavior when using _itoa_s and _ultoa_s if I try to get a char array from an DWORD. The function returns zero(success) and my application continues, but I'm getting an exception window with error code 0xc0000417 (STATUS_INVALID_CRUNTIME_PARAMETER). ULONG pid = ProcessHandleToId(hProcess); int size = getIn...

Specify window painting region in WINAPI

Hello, I'm using one 3rd party SDK which get hwnd (window handle) and paints something on my window. And i want to specify window painting region (left, right, top, bottom) ? How it's possible to do it ? I'm found WINAPI function SetWindowRgn, but it's not good for me because this function specify whole window region. I need specify jus...

Get free disk space of a Windows mount point remotely

Does anyone know of a way to get the free disk space of a Windows mount point on a remote system without using WMI? For example, GetDiskFreeSpaceEx returns the following values: C:\ - 29 GB C:\MountedDir - 50 GB When run remotely on a Windows 2003 server (orig_server is 2008 R2) it reports the following: \\orig_server\C$ - 29 GB \\o...

SetWindowsHookEx WH_MOUSE freeze on breakpoint in Win7

helos, on WinXP my application has been sucessfully using a global mousehook to retrieve mouseposition and clicks even if it does not have the focus. the hook is in a separate .dll and is being initialized like this (in delphi): SetWindowsHookEx(WH_MOUSE, @MouseHookCB, HInstance , 0); now on Win7 this basically also works during runt...