winapi

What's the best way to transfer data from python to another application in windows?

I'm developing an application with a team in .Net (C++) and provide a COM interface to interact with python and other languages. What we've found is that pushing data through COM turns out to be pretty slow. I've considered several alternatives: dumping data to a file and sending the file path through com Shared Memory via mmap? Stre...

How do I build a VB6 Console App

I did some googling to try to answer this question but even after that I'm not quite clear about something. Is it possible to create a console app from VB6? I've got a VB6 app that doesn't put up a window. I always assumed that it was a console app. However, I want to be able to use the Windows API SetConsoleCtrlHandler function fr...

Executable reading itself

I need to read data added to the end of an executable from within that executable . On win32 I have a problem that I cannot open the .exe for reading. I have tried CreateFile and std::ifstream. Is there a way of specifying non-exclusive read access to a file that wasn't initially opened with sharing. EDIT- Great thing about stackoverflo...

Best resource for learning more about using winsock

I am a Software engineering student, well-versed in C++, but I am interested in programming using I/O from more varied sources than just file I/O with .txt files. For example, I have heard a bit about using winsock and win32 to get input and output over networks. Does anyone know of a good resource for this? ...

Win32: Atomic Execution of Code Block

I have two system calls GetSystemTime() and GetThreadTimes() that I need to calculate the CPU utilization by a given Win32 thread. For the sake of accuracy, I need to ensure that both GetSystemTime() and GetThreadTimes() are executed atomically; i.e. there should be no context switch in between a call to GetSystemTime() & GetThreadTimes...

Send binary to the serial port

To send a serial string character to the serial port. I would need to call WriteFile(handle, "A", strlen("A"), ...) However, what if I want to specify and send a hex or binary number? For example, I want to send WriteFile(handle, 0x41, sizeOf(0x41), ...) ? Is there a function that allow me to do this? ...

Why is SetNamedSecurityInfoW leaving out ACEs?

I've got some code that basically does: GetNamedSecurityInfoW (<some file>,dacl only) build a new ACL with the info from #1 and an additional ACE to allow local Administrators full control SetNamedSecurityInfoW (<the same file>,the new dacl) The dacl from #1 contains 4 ACEs: grant: mask(0x001F01FF), flags(0x00000010): S-1-5-18 (NT A...

Service.Controller Status / Polling

I'm having a problem with a administrative app I'm working on. I'm build an interface for stopping, starting and querying various services across 40 or so servers. I'm looking at service.controller and have been successful in stopping and starting various services with button events but now I'm trying to figure out a way to return th...

Canonical way to parse the command line into arguments in plain C Windows API

In a Windows program, what is the canonical way to parse the command line obtained from GetCommandLine into multiple arguments, similar to the argv array in Unix? It seems that CommandLineToArgvW does this for a Unicode command line, but I can't find a non-Unicode equivalent. Should I be using Unicode or not? If not, how do I parse th...

win32 select all on edit ctrl (textbox)

I am creating my textbox with these options. I can copy/cut/paste/undo, but when i hit select A it doesnt select all. I can right click and click select all but ctrl a doesnt do anything, why? wnd = CreateWindow("EDIT", 0, WS_CHILD | WS_VISIBLE | ES_MULTILINE | WS_HSCROLL | WS_VSCROLL | ES_AUTOHSCROLL | ES_AUTOVSCROLL, x, y, w, ...

Process Affinity

Is it possible to programmatically either via the win32API (python) or via a command line option set the processor affinity for a process? ...

Allow vertical scrolling in listbox, when it is disabled (VB6)

I need to allow the vertical scrollbar in a multiselect listbox (VB6) however, when the control is disabled, I can't scroll. I would think there is an API to allow this, but my favorite VB6 site (MVPS VB.NET) does not have a way. I toyed with pretending it was disabled, and ignore the clicks... but to do that with VB6 code is really ug...

How to return an error from a service?

I'm writing a service application that sometimes cannot be stopped immediately upon receiving the SERVICE_CONTROL_STOP from the Services MMC. I currently handle it like this: (in pseudo-code): DWORD HandlerEx( DWORD dwControl, DWORD dwEventType, PVOID pvEventData, PVOID pvContext ) { switch( dwControl ) { ...

Monitor process start in the system

Dear all, Is there a way to monitor processes starting in the system before they start? Example: On programs like ZoneAlarm or Antivirus programs, when you run a program it asks you if you allow running this program or not before it runs... Thanks so much, ...

Changing master volume level

How can I change the master volume level? Using this code [DllImport ("winmm.dll")] public static extern int waveOutSetVolume (IntPtr hwo, uint dwVolume); waveOutSetVolume (IntPtr.Zero, (((uint)uint.MaxValue & 0x0000ffff) | ((uint)uint.MaxValue << 16))); I can set the wave volume but if the master volume is too low this won't have an...

What are the practical differences between C compilers on Windows?

A program written in Visual C/C++ 2005/2008 might not compile with another compiler such as GNU C/C++ or vice-versa. For example when trying to reuse code, which uses windows.h, written for a particular compiler with another, what are the differences to be aware of? Is there any information about how to produce code which is compatible ...

Repcached for Win32 - has anyone built it?

Hi everybody I have finally got the green light to use Memcached in our project (after months of lobbying against a database-based caching solution - just don't ask...), however we will need to use Repcached as well to have backup copies of our data. Has anyone built this for Win32? We may end up using Linux in production, but develop...

How to provide user name and password when connecting to a network share

When connecting to a network share for which the current user (in my case, a network enabled service user) has no rights, name and password have to be provided. I know how to do this with Win32 functions (the WNet* family from mpr.dll), but would like to do it with .Net (2.0) functionality. What options are available? Maybe some more ...

Is the order in which handles are returned by EnumWindows meaningful?

From a couple of preliminary tests it seems that EnumWindows always returns windows in reverse instantiation order, i.e. most recently instantiated window first. Is that a valid observation? If so, is it true across all versions of Windows? And is this a reliable assumption, i.e. is that behaviour documented somewhere? Context: I'm de...

Win32 console processes in VISTA - 10% CPU, but VERY SLOW

I have a Win32 console application which is doing some computations, compiled in Compaq Visual Fortran (which probably doesn't matter). I need to run a lot of them simultaneously. In XP, they take around 90-100% CPU together, work very fast. In Vista, no matter how many of them I run, they take no more than 10% of CPU (together), and ...