winapi

How to tell if current thread is impersonating?

I have a c++ application in which threads could impersonate using LogonUser/ImpersonateLoggedOnUser, and then revert impersonation using RevertToSelf. I ran across the bug which caused thread to impersonate this way twice. I want to prevent this by testing if current thread is already impersonating and throw exception if it is. Is there ...

Windows 7 NotifyIcon GUID spoof-protection

I am currently working on learning some different aspects of WINAPI, including features introduced in windows 7.. One of those is using a GUID as identifier for a Notification icon. As can be read on the MSDN, the GUID is bound to the executable by path, the first time the notification icon is added. This page in question promises furth...

Custom FileDialog in WinCE 6.0

I am newbie in WinCE Programming, i want to Create Custom File Dialog for our application, which has totally diffrent look and feel than the default windows file dialog.... I looked into many Flag value bt they won't worth it ... Any pointers will be helpful Thnks... Mukesh ...

Custom FileDialog in MFC or File Dialog in Expolorer mode

I am newbie in MFC Programming, i want to Create Custom File Dialog for our application, which has totally diffrent look and feel than the default windows file dialog.... I looked into many Flag value bt they won't worth it ... Any pointers will be helpful Thnks... Mukesh ...

Retrieve a user's First and Last Name, given its login name, inside a windows server domain.

Hi Given that I am on a workstation, that is inside a Windows Server domain. In my data, I have the login name of the operator who has created the data. When I print a presentation of this data, I want to display the first and last name of this operator, which may be logged on another workstation of the domain... or even could even not...

Could there be encoding-related problems when storing unicode strings in ini files?

There are already questions regarding unicode and ini files, but many of them are rather domain-specific. So I am not sure if the answer can be applied to the general case. Motivation: I want to use ini files for storing simple data like some numbers and some strings. The strings are provided by users (input via GUI). The software could...

asp.net SHGetFileInfo[winapi call]

Hello. I need tree file at my asp.net site. For getting icons I try use SHGetFileInfo api function. At non asp.net application it works well, returns corrects Icon. When I conusme it at asp.net context I got: Attempted to read or write protected memory. What's wrong? Can I get fiel icon at asp.net context? Code: public class Extra...

Big problems with MFC/WinAPI

I need to create a SDI form with a formview that has two tabs, which encapsulate multiple dialogs as the tab content. But the form has to have a colored background. And things like these makes me hate programming. First, I tried CTabControl, via resource editor, tried different things, but the undocumented behavior and the quirks with ...

call to LoadLibrary from ATL COM plug-in

Hi I have an ATL based COM plugin and there is another 3rd party library that I want to use. It's not COM dll and implemented in C++. details on 3rd party dll as follows: Configuration type = Dynamic Library(.dll) Use of MFC = Use MFC in a static library Use of ATL = not using ATL Character set = use multi-btye char set CRL support...

Windows Driver Installation Notification

My library performs a sequence of actions which result in a new (virtual) device node being added to the system. Assuming that everything is correctly configured the Windows PnP manager will respond by loading my function driver. This function driver will then proceed to create a device interface file which my library can open and inte...

Performance of Win32 memory mapped files vs. CRT fopen/fread

I need to read (scan) a file sequentially and process its content. File size can be anything from very small (some KB) to very large (some GB). I tried two techniques using VC10/VS2010 on Windows 7 64-bit: Win32 memory mapped files (i.e. CreateFile, CreateFileMapping, MapViewOfFile, etc.) fopen and fread from CRT. I thought that mem...

Win32 C++ ReadDirectoryChangesW "creation" and "modification" of file difference detect?

Here is the problem: I monitor a directory using Win32 API ReadDirectoryChangesW function. And I need to distinguish between newly created files and modified files. But there are problems... as always :( Cases: I monitor directory for new/modify (FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_SIZE). Problem: After file creation, ne...

Malloc only once for ALL adapters when using GetAdaptersInfo()?

I looked at the GetAdaptersInfo() sample in MSDN: http://msdn.microsoft.com/en-us/library/aa365917%28VS.85%29.aspx and noticed that while the sample attempts to iterate through ALL adapters, it only allocates memory for the first one. Is this a bug? If not, why not? Do all adapters have the same info size? To further clarify my ques...

Way to pass argv[] to CreateProcess()

My C Win32 application should allow passing a full command line for another program to start, e.g. myapp.exe /foo /bar "C:\Program Files\Some\App.exe" arg1 "arg 2" myapp.exe may look something like int main(int argc, char**argv) { int i; for (i=1; i<argc; ++i) { if (!strcmp(argv[i], "/foo") { // handle /foo } e...

Win32 API: ReadFile not timing out

I'm writing some code to interface with a piece of hardware. The hardware connects to the PC via a USB with a USB-to-Serial converter inside the device (it shows up as a COM port device in Windows). I'm having issues with the Win32 API ReadFile system call. I can't seem to get it to work as advertised. I've setup the COMMTIMEOUTS str...

Windows API Wrapper for .Net?

Windows API So i know that the WinForms touches on the Windows API a little, but frankly its horrible. ESPECIALLY with the layered windows and flickering. So i was wondering if anyone has wrote partial, or full wrappers for the Windows API.Im particularly interested in the Layered Window aspect, but really any part of the API is a goo...

Is it possible to use midiOutLongMsg to play a chord? (Win32 API)

This guys says yes: http://web.tiscalinet.it/giordy/midi-tech/lowmidi.htm Same with a really old book from 1998 (Maximum MIDI). MSDN doesn't mention it. I'm not getting any sound. I fill a char buffer with status|note|velocity|status|note|velocity... Set lpData, dwBufferLength, and dwFlags of a MIDIHDR struct call midiOutPrepareHeader ...

Playing Stereo PCM with DirectSound

Hey, I have simple 16-bit PCM player that I made using DirectSound. But when it plays, it seems that it plays only one speaker instead of both. I don't know what code to post exactly, so you'll have to tell me if you need any. I can say that I create the sound buffer using, and lock the stream using: WAVEFORMATEX wfx; ZeroMemory(&wfx...

How to set input focus to an application which is not in foreground in Windows?

I want my application to capture input focus, whenever the mouse hovers over it. How do I do it in Windows? Basically I dont want users to explicitly click on the application, or the taskbar icon before entering any text, when the application is not in foreground. I tried the SetForegroundWindow API in the mouse hover notification, but...

Get an IP_ADDRESS_STRING from GetAdaptersAddresses()?

GetAdaptersAddresses() will get you addresses in IP_ADAPTER_UNICAST_ADDRESS format, which is defined as: typedef struct _IP_ADAPTER_UNICAST_ADDRESS { union { struct { ULONG Length; DWORD Flags; } ; } ; struct _IP_ADAPTER_UNICAST_ADDRESS *Next; SOCKET_ADDRESS Address; IP_PREFIX_ORIGIN ...