winapi

How to create an INI file with an empty section?

I want to write a *.ini file in MFC. I know those typical methods with section names, key names and key values. I`m wondering how to write a ini file which contains only a section name, an ini file like below: ... [section] ... I tried the function WritePrivateProfileString() with two NULL parameters; I thought it would work but fail...

How to get the dimensions of an Icon from its handle?

I have a handle to the icon (HICON) and have to find out the dimensions of the icon that it represents. How do I get this information? ...

right click event in opencv

Hello all, I am developing a computer vision program using OpenCV (IDE = devcpp). I am able to get the hand contour , move cursor position according to our our hand. i want to implement right click functionality .Please help me with it . i am using event SetCursorPos(x,y) to set the cursor position on the screen. is there any simple f...

(win32) What to do when a file remains left open when a remote application crashes or forgets to close the file

Hi I have not worked so much with files: I am wondering about possible issues with accessing remote files on another computer. What if the distant application crashes and doesn't close the file ? My aim is to use this win32 function: HFILE WINAPI OpenFile(LPCSTR lpFileName, LPOFSTRUCT lpReOpenBuff, UINT uStyle); Using the flag OF_SHA...

WinAPI CIniFile::ReadFile() can't read ini file

IDE: VS2005 Is there anyway to know why ReadFile() failed? I can't find the reason some of the INI can't be read. Thanks. EDIT: CIniFile iniFile; iniFile.SetPath( "C:\\Services\\Server\\Server.INI" ); if( iniFile.ReadFile()) my code... The program never gets in the if block. And, sorry for the confusing. I use this library for ...

How to get the driver letter from dbcc name in Windows?

I want to detect USB disk insertion in a Windows Service. And I use RegisterDeviceNotification function. IN DBT_DEVTYP_DEVICEINTERFACE, I can get dbcc name. My question is: How can I know which driver is inserted according to the dbcc name? Thanks. ...

Can an out-of-process COM object determine its parent process?

From an out-of-process COM object (LocalServer32) can I determine the client process that requested the creation of the object? - to be specific I need to get hold of the client processes command line. This question arrises because (due to poor standardisation, implementation and support) the potential 3rd party clients of the object ha...

JNA: passing arguments as wParam/lParam (Java)

If I need to pass an integer it's pretty straightforward: User32.INSTANCE.PostMessage(hwnd, WM_MOUSEMOVE, new W32API.WPARAM(), new W32API.LPARAM(x | y << 16)) but how do I get WPARAM out of W32API.HDC for example? ...

how to do trig functions to data in Windows textboxes

must you convert from strings to double? if so. how? Are there functions for trig that will accept textbox string data as is? Is there a way to pull the data from the textbox as a numeric value, not as a string? ...

How can I find if an arbitrary process is running under wow64?

I need a tool which will discover whether an arbitrary process is running in x86 or x64 mode on a machine. I need to do this programatically from C++, based on a process ID. There has to be some way to do this (as you can clearly see it from the task manager). Does anyone know of a windows api that will tell you, given a process ID, w...

Real World strtod(); for use with WINAPI textbox.

ResultBox1->Text = (sin(TextBox1->Text)) * TextBox2->Text That is what i would like to work, but im dealing with Strings I cant seem to convert the strings, do the trig, and convert back to string for displaying properly... anyone with an example? ...

Linked list example using threads

I have read the following code of using CRITICAL_SECTION when working with multiple threads to grow a linked list. what would be the main() part which uses two threads to add to linked list? #include <windows.h> typedef struct _Node { struct _Node *next; int data; } Node; typedef struct _List { Node *head; CRITICAL_SEC...

Are the *A Win32 API calls still relevant?

I still see advice about using the LPTSTR/TCHAR types, etc., instead of LPWSTR/WCHAR. I believe the Unicode stuff was well introduced at Win2k, and I frankly don't write code for Windows 98 anymore. (Excepting special cases, of course.) Given that I don't care about Windows 98 (or, even less, ME) as they're decade old OS, is there any re...

Understanding a #define directive

Looking at the Windows SDK, I found this #define directive for MAKEINTRESOURCEW: #define MAKEINTRESOURCEW(i) ((LPWSTR)((ULONG_PTR)((WORD)(i)))) Can someone explain to me what the heck that means? For example, what would be the value of MAKEINTRESOURCEW(0)? (1)? (-1)? ...

python win32 simulate click

Let's say I've got a window for which I want to simulate a mouse click at a specific x, y coordinate. I already have the hwnd but I'm not sure how to construct the lParam. I've used SendMessage in the past to click on buttons, etc., but I knew their hwnds. Any help would be greatly appreciated. I also can't help but wonder if I'm going a...

What is the alternative to MilRelease api from MilCore.dll?

Hi I am trying to port my application from windows Vista to Windows 7. In my WPF application I am showing a splash screen, for which I have used WIC components. I am creating some resources using IWICImagingFactory_CreateDecoderFromStream_Proxy IWICImagingFactory_CreateFormatConverter_Proxy CreateBitmapFlipRotator And then to releas...

Not able to include ntifs.h in win32 project

I tried to use the function called NTCreateFile. When I compiled it gave me an error saying "_NTCreateFile identifier not found". I inlcuded the header winternl.h. So next I tried to use ZwCreatFile, as per MSDN I included ntifs.h, but I am not able to include that header. It says "not able to open/find the directory". I am using V@2008...

How to set a sorting mode in Open Dialog

A user can manually sort files in a standard Windows Open Dialog (in "Details" view mode) by Name, Date or Size by clicking on the corresponding column header. How to set a sorting mode in Open Dialog (TOpenDialog class in Delphi) programmatically in application so that the dialog opens with a preferred sorting? ...

Windows/C++: detect when focus has changed between windows (globally)

I'm trying to find a way to detect when focus is changed to another window (without having to poll every X ms). I've already figured out a way to detect when focus is switched between applications using WH_SHELL and HSHELL_ACTIVATESHELLWINDOW. The problem is I want to detect when focus is switched between dialog/windows within the same...

Can somebody explain this remark in the MSDN CreateMutex() documentation about the bInitialOwner flag?

The MSDN CreatMutex() documentation (http://msdn.microsoft.com/en-us/library/ms682411%28VS.85%29.aspx) contains the following remark near the end: Two or more processes can call CreateMutex to create the same named mutex. The first process actually creates the mutex, and subsequent processes with sufficient access rights simply open ...