c

Get a Winstation Name from a Process ID

I am trying to get the name of the winstation (for example "winsta0") that a separate process has opened using only its Process ID. I can't find anything that does this on MSDN. They only seem to have GetProcessWindowStation() which only works for your own process. Any ideas? UPDATE: Maybe this is part of the puzzle... BOOL ProcessId...

Overhead of a switch statement in C

Hi all! I'm a fairly competent Java programmer who's very new to C. I am trying to optimize a routine that has four modes of operation. I loop over all the pixels in an image and compute a new pixel value depending on the 'mode' passed. My question regards the overhead of a switch statement within two nested for loops. I'd be interest...

Creating libraries in C/C++ - ld can't find my library.

Hi, I'm trying to learn how to create a C/C++ library in a linux environment but I'm having a problem (probably a trivial one) that online tutorials had not helped to solve. For definiteness let's say I have a foo.c file with the following code: //file: foo.c #include <stdio.h> void hello(void) { printf("hello!\n"); } a foo.h: ...

Create a new independent process from another C process

Two C executables A and B exist. A and B communicate to each other through a socket. B can be started independently or through A. If B is started first and A is started next, then A and B start properly without issues. Even if A is restarted, then there are no issues. If B is started through A, then A and B starts properly. But here ...

How to call a C library from .NET

I have a C library which I need to call from an ASP.NET / C# app, how do I go about doing this? ...

Chunked transfer decoder, code snippet for C

I'm making a http server that merely allows access to my folder, download the files in it and also uploading to a folder. So far I have already done most of it, the only thing left is the uploading of the files. Whenever I receive files from a client, they send chunked datas. Which I dont understand to decode. All I need is a function th...

Problem with performance counters on Vista

I'm running into a strange issue on Vista with the Performance monitoring API. I'm currently using code that worked fine on XP/2k, based around PdhGetFormattedCounterValue(). I start out using PdhExpandWildCardPath to expand the counters (I'm interested in overall network statistics), the counters I'm looking at are: \\Network Interf...

How to learn C and Objective-C

Hi, I am learning programming. I plan on learning C and Objective-C this summer. I bought the C for Dummies book but it is a complete waste of time. It's way to many pages! Are there any good books I should read? Or should I just learn C from websites? What would be the fastest way because I really want to learn it fast and start learnin...

Is there a painless way to build a Windows UI in C?

edit alright, I guess C is painful in nature--Just, this part, is particularly painful. Also, there isn't a real reason I'm only writing in C, other than, that's the language I want to write in, and be proficient in, for now. I know moving from C to C++ is bad, but whatever. And does anyone know a solution, to my problem with making mo...

Get size of uncompressed data in zlib?

I'm creating something that includes a file upload service of sorts, and I need to store data compressed with zlib's compress() function. I send it across the internet already compressed, but I need to know the uncompressed file size on the remote server. Is there any way I can figure out this information without uncompress()ing the data...

Embedding assembly in C with compiler finding registers for you

When embedding assembly code into a C/C++ program, you can avoid clobbering registers by saving them with a push instruction (or specify clobber list of compiler supports it). If you are including assembly inline and want to avoid the overhead of pushing and popping clobbered registers, is there a way of letting gcc choose registers for...

Library for Image Recognition in Obj-C?

Hi there, I'm looking for some library that will allow me to identify black dots on a white background. Preferably in C or objective-c. Also, what keywords can I use in my search for such algorithms? I've found a lot of stuff about image recognition but nothing that ressembles what I'm looking for. thanks! ...

Which is more readable (C++ = )

int valueToWrite = 0xFFFFFFFF; static char buffer2[256]; int* writePosition = (int* ) &buffer2[5]; *writePosition = valueToWrite; //OR * ((int*) &buffer2[10] ) = valueToWrite; Now, I ask you guys which one do you find more readable. The 2 step technique involving a temporary variable or the one step technique? Do not worry about opti...

C/C++ USB drive event

Regarding the Windows platform, is their an event I can look for to tell when a USB drive or any type of portable media us plugged in? ...

Reading from a socket 1 byte a time vs reading in large chunk

What's the difference - performance-wise - between reading from a socket 1 byte a time vs reading in large chunk? I have a C++ application that needs to pull pages from a web server and parse the received page line by line. Currently, I'm reading 1 byte at a time until I encounter a CRLF or the max of 1024 bytes is reached. If reading ...

in-place bit-reversed shuffle on an array

For a FFT function I need to permutate or shuffle the elements within an array in a bit-reversed way. That's a common task with FFTs because most power of two sized FFT functions either expect or return their data in a bit-reversed way. E.g. assume that the array has 256 elements I'd like to swap each element with it's bit-reversed patt...

Problem to define a struct

Hi, I am doing a little application in C and I want to define a struct. I have done this : typedef struct { ITEM element[TAILLE_TAMPON]; sem_t mutex, attendreVide, attendrePlein; int ptEntree, ptSortie; } TAMPON; but I have an error when I built my project with ITEM Is it due to a problem with the include ? stdio.h std...

How to programmatically move a window slowly, as if the user were doing it?

I am aware of the MoveWindow() and SetWindowPos() functions. I know how to use them correctly. However, what I am trying to accomplish is move a window slowly and smoothly as if a user is dragging it. I have yet to get this to work correctly. What I tried was getting the current coordinates with GetWindowRect() and then using the setwin...

What is the Windows equivalent to the capabilities defined in sys/select.h and termios.h

I have an application in linux, which is compiled successfully. I want to run the same program in windows. But compilation produces the following errors related to header files. Cannot find sys/select.h Cannot find termios.h How can I fix this? ...

Simulating movement of a window and have it react to collisions

I was reading this topic and I decided to give it a shot. To my astonishment it really seemed easier than what I am making it I guess. I have some confusion about the "DesiredPos" variable. Well at least in my implementation. I am trying to move a window around constantly and have it react like a ball when it hits the monitors edges. Lik...