c++

How to mute microphone in Windows 7 with C/C++?

I made a program to mute microphone using WinAPI and it seems to work perfectly in Windows XP but doesn't do a thing in Windows 7. Is it possible to control microphone volume or mute with WinAPI in Windows 7? void setVolume(DWORD volume) { HMIXER mixer; if (mixerOpen(&mixer, 0, 0, 0, 0) != MMSYSERR_NOERROR) { MessageBoxW(NULL, L"Er...

[c++/STL] Selective iterator

FYI: no boost, yes it has this, I want to reinvent the wheel ;) Is there some form of a selective iterator (possible) in C++? What I want is to seperate strings like this: some:word{or other to a form like this: some : word { or other I can do that with two loops and find_first_of(":") and ("{") but this seems (very) inefficient t...

Optional Parameters with C++ Macros

Hey there, Is there some way of getting optional parameters with C++ Macros? Some sort of overloading would be nice too. It doesnt seem as if there is? I couldnt find any method anyway. Thanks in advance! ...

Doubleton pattern in C++

I am aware of the singleton pattern in C++, but how do you get two instances of an object? Is there any such pattern where we could easily get two objects? For the logic I could think of is that I can change the singleton pattern itself to have two objects created inside the class. This works, but if the requirement grows like if I need...

#define far, #define near Windef.h

Possible Duplicate: Is there a clean way to prevent windows.h from creating a near & far macro? What's the point of these two defines in Windef.h? #define far /* nothing */ #define near /* nothing */ I know it has to do with near and far pointers and the fact they're no longer used, but, is it safe to #undef them, so...

Two seperate tm structs mirroring each other

Here is my current situation: I have two tm structs, both set to the current time I make a change to the hour in one of the structs The change is occurring in the other struct magically.... How do I prevent this from occurring? I need to be able to compare and know the number of seconds between two different times -- the current time a...

Passing Text for command line

Hi, I need to pass some text which is in richtext box to command line. This is my Button click even which start the cmd. private void button1_Click(object sender, EventArgs e) { ProcessStartInfo psi = new ProcessStartInfo { FileName = "cmd", Arguments = @"/k ""C:\Program Files\Microsoft Vi...

I'm having a problem identifying a floating point exception.

I'm using c++ in visual studio express to generate random expression trees for use in a genetic algorithm type of program. Because they are random, the trees often generate (I'll call them exceptions, I'm not sure what they are) Thanks to a suggestion by George, I turned the mask _MCW_EM on so that hardware interrupts are turned off. (...

Profiling help required

I have a profiling issue - imagine I have the following code... void main() { well_written_function(); badly_written_function(); } void well_written_function() { for (a small number) { highly_optimised_subroutine(); } } void badly_written_function() { for (a wastefully and unnecessarily large number) ...

Boost signals and passing class method

Hello, I've defined some signal: typedef boost::signals2::signal<void (int temp)> SomeSig; typedef SomeSig::slot_type SomeSigType; I have some class: class SomeClass { SomeClass() { SomeSig.connect(&SomeClass::doMethod); } void doMethod(const SomeSig &slot); }; And got a lot of errors: error: ‘BOOST_PP_ENUM_SHIFTE...

How do I benefit from argc and argv in C++, the standard way?

What is the standard way to retrive and check for the argc and argv and what is the best usage and how to do that in linux? Please provide examples. "I want to have a complex command-line options and I want to use them in my application" That what I mean. Thanks ...

I want to make a wrapped acces type for certain internals of one of classes and I have some performance questions

I am writing an abstract matrix class (and some concrete subclasses) for use on very differing hardwares/architectures, etc. and I want to write a row and column type that provides a transparent reference to the rows and columns of the matrix. However, I want to tune for performance, so I'd like this class to be essentially a compiler ...

C++ private inheritance and static members/types

I am trying to stop a class from being able to convert its 'this' pointer into a pointer of one of its interfaces. I do this by using private inheritance via a middle proxy class. The problem is that I find private inheritance makes all public static members and types of the base class inaccessible to all classes under the inheriting cla...

Flexible array member in C-structure

Quoting from the C-std section 6.7.2.1, struct s { int n; double d[]; }; This is a valid structure declaration. I am looking for some practical use of this kind of syntax. To be precise, how is this construct any more or less powerful than keeping a double* as the 2nd element? Or is this another case of 'you-can-do-it-in-multiple-way...

Object allocation in C++

char *myfunc() { char *temp = "string"; return temp; } In this piece of code, where does the allocation of the object pointed to by temp happen and what would be its scope? Is this function a valid way to return a char* pointer? ...

SQLConfigDataSource creates invalid datasource

I am using SQLConfigDataSource to create an ODBC MS Access data source programmatically. It works most of the time, but fails if the DBQ value (i.e., path to the Access database) in the lpszAttributes string contains more than 148 characters (far fewer than MAX_PATH). Has anyone ever run into this before? Any possible workarounds? ...

How to use a "vector of vector" ?

Hi! I allready searched on the web for it but I didn't get satisfying results. I want to create something like vector< vector<int*> > test_vector; How do i fill this vector of vector? How to acces it's members? Maybe someone knows some nice tutorials on the web? kind regards mikey ...

How to convert a C++ program that uses CUDA into MEX

For work, I am converting the Image Denoising program that comes with the CUDA SDK into a MATLAB program. As far as I know, I have made all the necessary changes required by MATLAB, but when I try to call mex on it, MATLAB returns a bunch of linkage errors that I have no idea how to fix. If anyone has any suggestions on what I might be d...

Visual C++ function suddenly 170 ms slower (4x longer)

For the past few months I've been working on a Visual C++ project to take images from cameras and process them. Up until today this has taken about 65 ms to update the data but now it has suddenly increased significantly. What happens is: I launch my program and for the first 30 or so iterations it performs as expected, then suddenly the...

Class Template Instantiation: any way round this circular reference?

I have two classes that I'm using to represent some hardware: A Button and an InputPin class which represent a button that will change the value of an IC's input pin when it's pressed down. A simple example of them is: template <int pinNumber> class InputPin { static bool IsHigh() { return ( (*portAddress) & (1<<pinNumber) ); ...