c++

register for an event in Windows

Hi I want to do something when a memory stick attached to PC. Now I use a timer and check it in every tick whether any memory stick is plugged(use DriveInfo or with querying WMI) Is there any event driven model available to do? for example i use an event in my program that raise whenever a memory stick is plugged in to computer? ...

How to cause an intentional division by zero?

For testing reasons I would like to cause a division by zero in my C++ code. I wrote this code: int x = 9; cout << "int x=" << x; int y = 10/(x-9); y += 10; I see "int =9" printed on the screen, but the application doesn't crash. Is it because of some compiler optimizations (I compile with gcc)? What could be the reason? ...

How does linker know which symbols should be resolved at runtime?

How does linker know which symbols should be resolved at runtime? Particularly I'm interested what information shared object files carry that instruct linker to resolve symbols at runtime. How does the dynamic symbol resolution work at runtime, i.e. what executable will do to find the symbol and in case multiple symbols with the same nam...

Microsoft Visual C++ code optimization

In MSVC, there are four options for code optimization: No Optimization Minimize Size Maximize Speed Full Optimization The first three are self-explanatory, but I am unsure about Full Optimization. Does this try to find a balance between size and speed, or does it do better optimization than the other two options? Please clarify what ...

How do I create a pseudo-color image in C++?

I have an array of pixels with an associated intensity (as a float between 0 and 1) that I would like to convert to a RGB image. The easiest way would be to just multiply each value by 255 and assign it to R+G+B to obtain a greyscale image, but I think it would be better to use a whole range of colors to show finer differences. As far ...

Form Grabber for Google Chrome

I want to code a form grabber for google chrome web browser to grab al POST data with IE is simple you just hook HttpSendRequestW but here i don't know wich function to hook and the code is very complicated i tryed to search it. Maybe someone can help ...

Bringing back the default context menu in RichEdit when using OLE callback

Dear StackOverflow, I have a RichEdit control that uses an implementation of the IRichEditOleCallback interface, so that it can host images and embedded objects. Part of this interface is the GetContextMenu method. If this method remains unimplemented, the context menu (obviously) will not show up. Returning E_NOTIMPL does not do the ...

On Windows, how do we convert a virtual key code to the shifted character?

I looked at MapVirtualKey() and ToAscii(). MapVirtualKey() gives me only the unshifted character. ToAscii() only works for vk codes that translate to ASCII values. I need to detect for example, "Ctrl + Shift + 3" as Ctrl active, Shift active and '#'. Any clues? ...

Using doxygen with Visual Studio 2010

Hi, I have difficulties using efficiently doxygen with Visual Studio 2010 and C++. It seems like there is no other function for commenting than "un/comment lines". For example generating comment stubs, adding /// after a new line. Also, I wonder what is needed to display those Comments within the IntelliSense feature in VS2010? ...

pass object by value to another thread

I am writing a little trial project and I need to pass and object of type QueuList by value to a thread pool thread. It is a Boost threadpool and I am using Bind to pass the args to the thread. For some reason I cannot seem to pass my item to the threadpool thread by value... Can anybody help what I'm doing wrong? void ConsumerSchedu...

extern "C" (C linkage) by default

Question Do GCC, MSVC, or Clang, or some combination support setting linkage to default to C? Background I have a large mixed C/C++ project, and while it's easy and logical to export symbols in the C++ sources with C linkage, those same sources are assuming the stuff in the rest of the project are under C++ linkage. The current situa...

Debugging multiple related dll's each in separate projects.

I have to debug multiple dlls each within their own project. There is a parent executable that loads a dll, which serves as a container for the other dlls. My question is how can I debug the whole 'component' ie: all the dll's involved, using Visual Studio 2005 for C++. ...

How does a C++ object access its member functions ?

How does a C++ object know where it's member function definitions are present? I am quite confused as the Object itself does not contain the function pointers. sizeof on the Object proves this. So how is the object to function mapping done by the Runtime environment? where is a class's member function-pointer table maintained? ...

Cross-compiler library communication

I need to develop a C++ front-end GUI using MSVC that needs to communicate with the bank-end library that is compiled with C++ Builder. How can we define our interfaces so that we don't run into CRT library problems? For example, I believe we will be unable to safely pass STL containers back and forth. Is that true? I know I can pass ...

Why wasn't yield added to C++0x?

I have been using yield in many of my Python programs, and it really clears up the code in many cases. I blogged about it and it is one of my site's popular pages. C# also offers yield – it is implemented via state-keeping in the caller side, via an automatically generated class keeps the state, local variables of the function, etc. No...

Accessing C++ classes based on list of strings

Hi, I am hoping this is possible in C++. I have a list of classes that inherit from a common base class (Base). All of these will be compiled as part of the library linked to my program. I could be adding more classes that derive from Base and will be recompiling everything after I do this. When my program starts it will gather a vec...

Setting up Netbeans to compile wxWidgets projects under Windows

I'm trying to set up my Netbeans IDE so that it is capable of compiling wxWidgets projects. There is very similar question: Setup wxWidget in Netbeans 6.1 C++ On MS Windows? but the answer is not working for me. And the mentioned versions are a bit outdated. I use the mingw package for compilation. There is no problem compiling a sma...

Turning remove_if into remove_not_if

How can I reverse a predicate's return value, and remove the elements that return false instead of true? Here is my code: headerList.remove_if(FindName(name)); (please ignore lack of erase) with FindName a simple functor: struct FindName { CString m_NameToFind; FindInspectionNames(const CString &nameToFind) { m...

Cannot make a call using PJSIP in symbian

Hi all, I can compile it and create a SIS file. I was also able to install it on the mobile phone but when I am trying to make a call I don't get the ringer sound or the sound when the call is attended at the other end. Also I am not able to make calls to the mobile numbers. (I can make calls to sip accounts only). ...

How do you write a operator() or less-than-functor neater than a trivalue-compare-function

Writing an operator< () for a struct appears to be clearer than writing the classical trivalue compare. for example, to sort the following struct S { int val; }; you can write an operator< () bool operator< ( const S &l, const S &r ) { return l.val < r.val; } or, a trivalue function (usually in the following fashion ) i...