c++

Shell Extension: DragQueryFile returns at most 16 (in Windows 7)

I've writtten a shell extension (guided by The Complete Idiot's Guide to Writing Shell Extensions) which worked as it should until I upgraded to Windows 7(32bit). Now, the function DragQueryFile UINT uNumFiles = DragQueryFile(hDrop,0xFFFFFFFF,NULL,0); returns the right number of selected files until the number is above 16. Then alw...

serialize in .NET, deserialize in C++

Hi All. I have a .NET application which serializes an object in binary format. this object is a struct consisting of a few fields. I must deserialize and use this object in a C++ application. I have no idea if there are any serialization libraries for C++, a google search hasn't turned up much. What is the quickest way to accomplish th...

Sockets: large message performance

Hi, I have a doubt regarding the use of Berkeley Sockets under Ubuntu. In terms of performance and reliability which option is best? To send a high amount of messages but with short length or to send a low amount of messages but this ones with a large size? I do not know which is the main design rule I should follow here. Thank you all...

Fast 64 bit comparison

Hi I'm working on a GUI framework, where I want all the elements to be identified by ascii strings of up to 8 characters (or 7 would be ok). Every time an event is triggered (some are just clicks, but some are continuous), the framework would callback to the client code with the id and its value. I could use actual strings and strcm...

Executing a command from C++, What is expected in argv[0]?

I am using execv() to run commands from /bin/ such as 'ls', 'pwd', 'echo' from my c++ program, and I am wondering what value I should provide in argv[0]; const char * path = getPath(); char ** argv = getArgs(); execv(path,argv); ...

Receiving response(s) from N number of clients in reply to a broadcast request over UDP

Hi All, I am implementing a kind of IP finder for a particular type of network multimedia device. I want to find out all the alive devices of that type in the LAN, with their IP address and other details. The device has its own way of device discovery. It works as follows: A client sends a broadcast request over the LAN via UDP. Th...

For how long the iterator returned by std::set.find() lives?

I need to keep track of std::set element by saving the iterator returned by set.find(). My questions is does insertion and removing other elements invalidates the obtained iterator? From a simple test I did I can see it is not, but I'd like to ensure this feature is by design. ...

Why do I need to compile DateTime in boost if I am not using to_string or from_string?

When compiling a Visual Studio 2005 project that references a mix of c++ managed/unmanaged code, I get the following error: 1>LINK : fatal error LNK1104: cannot open file 'libboost_date_time-vc80-mt-1_42.lib' I have followed the "Getting Started Guide" at http://www.boost.org/doc/libs/1_42_0/more/getting_started/windows.html. Of relev...

Is it possible to create a static dictionary in a C++/CLI environment?

I used in my C++/CLI project static array's like: static array < array< String^>^>^ myarray= { {"StringA"}, {"StringB"} }; Is it possible to create a dictionary the same way? I was not able to create and initialize one. static Dictionary< String^, String^>^ myDic= { {"StringA", "1"}, {"StringB", "2"} }; Thx ...

Does Hinnant's unique_ptr implementation incorrectly fail to convert derived-to-base in this case?

I'm currently trying to use Howard Hinnant's unique_ptr implementation, and am running into a compile error. Here is some sample code: struct Base {}; struct Derived : public Base {}; void testfun(boost::unique_ptr<Base>); void test() { unique_ptr<Derived> testDerived; unique_ptr<Base> testBase(move(testDerived)); // ok, con...

adding string objects to an array via loop

Hello, What i'm trying to do is create a template array class that will store values of a data type into an array. I have it working fine with int values, however working with string objects things start to break down. I've taken out the block of code and tried it on it's own and I do get the same error. I'm sure I've learnt this, and ...

Socket connect() always succeeds (TCP over ActiveSync)

I'm using TCP/IP over ActiveSync to connect from Windows CE device to Windows XP desktop. The WinSock connect() function always succeeds, no matter whether desktop server application is actually running. The following simplified code demonstrates this issue: #include "stdafx.h" #include <Winsock2.h> int _tmain(int argc, _TCHAR* argv[]...

Cannot explain why std::istream_iterator set std::ios_base in error state

I am trying to conert a vector into a stream and back. While the first part works without issues, the last line of the following code put std::ios_base is an error state. Have you got any idea why it is so? Apparently myVecOut is equal to myVec after the code executes.... std::vector<double> myVec( 3 ); std::stringstream temp; ...

How would one handle bits from a file?

ifstream inStream; inStream.open(filename.c_str(), fstream::binary); if(inStream.fail()){ cout<<" Error in opening file: "<<filename; exit(1); } Let's say we just want to deal with individual bits from the file. I know we can read the file char by char, but can we read it bit by bit just as easily? ...

Can C++ projects use T4 in Visual Studio 2010?

T4 did not work for C++ projects in Visual Studio 2008 since it did not use msbuild for C++ projects. (Yes there were workarounds) In Visual Studio 2010, C++ projects uses MsBuild, so do anyone know if C++ projects can use T4 in the same way as C# or VB? ...

C++: High speed stack

As far as I assume, std::stack and all such 'handmade' stacks work much slower than stack which is applications one. Maybe there's a good low-level 'bicycle' already? (Stack realization). Or it's a good idea to create new thread and use it's own stack? And how can I work directly with application stack? (asm {} only?) ...

Qt C++ WebKit windowCloseRequested Signal

Hey All, I am trying to connect QWebpage::windowCloseRequested() to a slot that just prints out a debug message. When I call window.close(); in JavaScript it doesn't bubble the signal up or call the slot... connect(webView->page(), SIGNAL(windowCloseRequested()),this, SLOT(windowCloseRequested())); The slot is setup, it is in my wind...

Should I delete the string members of a C++ class?

If I have the following declaration: #include <iostream> #include <string> class DEMData { private: int bitFldPos; int bytFldPos; std::string byteOrder; std::string desS; std::string engUnit; std::string oTag; std::string valType; int idx; public: DEMData(); DEMData(const DEMData &d); void Se...

Run time determination of compilation options

I need to be able to determine at run time what compilation options were use to build the executable. Is there a way to do this? EDIT: I'm particularly interested in detecting optimization settings. The reason is that I'm writing commercial software that must run as fast as possible. While I am just modifying and testing the system I do...

C++: create betwen-startups relevent functor list

I create something like a list of functors (functions pointers). Then I write them in binary form into file. The problem is, that, functor - is a simple function pointer. (correct me if I'm wrong.) But the address of function is different from one run to another. So, the question - is there any way to create list of functors that will b...