c++

How are controls put in the caption bar?

I noticed Firefox 4, Opera and Chrome, and IE 7/8 put buttons and controls in the title/caption bar, how is this done? Thanks http://img199.imageshack.us/img199/3307/slayerf.png ...

Best way to deal with COM PORT?

Hi Guys, I am writing an application which need to send data to a Serial Device attached to COM Port. I am just confuse what is the best way to deal with such device? shall i write the communication module in C++ or shall i write this in JAVA? I want to run the application on Windows as well as Linux. ...

What is the WMI call to list Storage disks on a host system?

I Need to fetch disks that are present on the host along with the LUNs/disks(which do have any file sytem on it) that are presented by the SAN to the host. Tried "Win32_volume" but this does not display LUNs/disks, which have unkwown file system on it.Can you please sugggest any WMI class which lists all the disks available on the host s...

Using bitset in place of using hand written bit manipulation code?

Is there any performance loss/gain using bitset in place where hand written? How to build the following using a bitset at runtime make all the bits between 2 and 5 as zero i.e., 11110011. ...

question about Multiply high signed.

#include <iostream> using namespace std; int mulths(int u,int v) { unsigned u0,v0,w0; int u1,v1,w1,w2,t; u0 = u & 0xFFFF; u1 = u >> 16; v0 = v & 0xFFFF; v1 = v >> 16; w0 = u0 * v0; t = u1 * v0 + (w0 >> 16); w1 = t & 0xFFFF; w2 = t >> 16; w1 = u0 * v1 + w1; return u1 * v1 + w2 + (w1 >> ...

How do I format c++ comments properly?

Could anyone please suggest a proper format of comments I should use in a C++ project? I think that there is some analog of javadoc format, but I can't find which one. Is there any de-facto standard of that kind? Thanks! ...

Local Classes in C++

I am reading "Local Classes" concept in Object-oriented programming with C++ By Balagurusamy (http://highered.mcgraw-hill.com/sites/0070593620/information_center_view0/). The last line says "Enclosing function cannot access the private members of a local class. However, we can achieve this by declaring the enclosing function as a friend...

How to add command to right-click menu of certain extension programmatically?

I have created 2 exe files: open.exe and edit.exe. and a new extension: say .newext. Now I want to open by double click on .newext file with open exe. get a menu with right click on .newext file where in bold it is written "Open" and under that it is written "Edit". And by clicking "Edit" the edit.exe opens the .newext file. do thi...

namespace same name as function

I have this in a header: double commonFunction( ... ) { /*...*/ } namespace F2 { double impactFactor( ... ) { /*...*/ } double func( ... ) { /*...*/ } double F2( ... ) { /*...*/ } } namespace FL { double impactFactor( ... ) { /*...*/ } double func( ... ) { /*...*/ } double FL( ... ) { /*.....

C++ Sockets Send() Thread-Safety

I am coding sockets server for 1000 clients maxmimum, the server is about my game, i'm using non-blocking sockets and about 10 threads that receive data simultaneously from different sockets (first thread receives from 0-100,second from 101-200 and so on..) but if thread 1 wants to send data to all 1000 clients and thread 2 also wants t...

difference between void*, const void*, volatile void*, or const volatile void*?

what is the difference between void*, const void*, volatile void*, or const volatile void*? please can u explain through the example program? ...

why doesnt this segfault

hello all I stumbled across something "interesting" and I cant put my finger why the behaviour isn't coherent. Check this code. char buf[100]; sprint(buf,"%s",bla); Simple, right. It's easy to understand what is going on when bla is a NULL pointer. This should always segfault right!? In one machine the executable segfaults, on ano...

capture a call stack and have it execute in a different thread.

I need to write a logging api which does the actual logging on a seperate thread. i.e. I have an application which wants to log some information. It calls my API and the api captures all the arguments etc and then hands that off to a seperate thread to be logged. The logger api accepts variadic arguments and therefore my initial though...

How can we use any C library inside our C++ code ?

How can we use any C library inside our C++ code? (Can we? Any tuts on that?) (I use VS10 and now talking about libs such as x264 and OpenCV) ...

CreateCompatibleBitmap failing on Windows mobile 6

I'm porting an application from Windows Mobile 2003 to Windows Mobile 6, under Visual Studio 2008. The target device has a VGA resolution screen, and I was surprised to find that the following code fails; CClientDC ClientDC(this); CRect Rect; GetClientRect(&Rect); int nWidth = Rect.Width(),nHeight = Rect.Height(); CBitmap Temp; i...

float overflow?

The following code seems to always generate wrong result. I have tested it on gcc and windows visual studio. Is it because of float overflow or something else? Thanks in advance:) #include <stdio.h> #define N 51200000 int main() { float f = 0.0f; for(int i = 0; i < N; i++) f += 1.0f; fprintf(stdout, "%f\n", f); return 0; } ...

Why are IsEqualGUID() and "operator ==" for GUID declared to return int?

Windows SDK features IsEqualGUID() function and operator==() for two GUIDs that return BOOL (equivalent to int): // Guiddef.h #ifdef __cplusplus __inline int IsEqualGUID(REFGUID rguid1, REFGUID rguid2) { return !memcmp(&rguid1, &rguid2, sizeof(GUID)); } #else // ! __cplusplus #define IsEqualGUID(rguid1, rguid2) (!memcmp(rguid1...

A way How to Compile C library into .Net dll ?

Can we compile C library as .Net dll (containing and opening access to all C libs functions) by just compiling cpp project containing code like extern "C" { #include <library.h> } with /clr:pure argument with VS? (VS10) Or we should do something more trickey? ...

How can I open the null input in SoX

In libsox, I know the null output can be opened like so: assert(out_r= sox_open_write("", &in_r->signal, NULL, "null", NULL, NULL)); But I'm not sure how to do this with the input (using sox_open_read). I'm using this to generate a sine wave using synth so right now, I have a workaround where I open a silent wave file, but this is far...

Reference as key in std::map

Suppose some data structure: typedef struct { std::string s; int i; } data; If I use the field data.s as key when adding instances of data in a map of type std::map<std::string&, data>, do the string gets copied? Is it safe to erase an element of the map because the reference will become invalid? Also do the answers to these ...