c++

How to get disk usage statistics for remote network share?

If I have a network share say \\myfileserver\documents, can I find out programmatically how much disk space it is using (used/free space) using any API of some sort? Please note it could be hosted by samba or it could be on a san storage device which means I won't be able to install anything on that machine to check the local disk usage...

how do i prevent screen-savers and sleeps during my program execution?

In a c++ program run on Win7, is there a way to fake a mouse movement or something like that, just to keep the screen saver from starting and the system from going to sleep? I'm looking for the minimal approach and I prefer not to use .NET. Thanks, -nuun ...

Question about C++ folder structure for header file

Hi all, I'm quite new in C++ after few years in Java and eclipse, I got little bit confusing using code::blocks, no autogenerate setter/getter and also implement interface :D. I wanna ask about code structure in code::blocks, I create new console application, my header will be put to Headers/include folder called Employee.h, then .cpp w...

minimal reflection in C++

hi i want to create a factory and i would like to use reflection for that. i jast need to create a object with given string and invoke only few known methods how i can do that? ...

How to find out cl.exe's builtuin macros

Does anyone know how could I find out which are cl.exe's builtin/predefined macros? For example for gcc the following command line will list all the compiler's builtin macros gcc -dM -E - </dev/null EDIT: I'm interested in a way similar to gcc's that is "ask the actual compiler". Thanks ...

Only one evaluation guaranteed for std::min/std::max

Does the C++ standard guarantee that the call c = std::min(f(x), g(x)); evaluates the functions f and g only once? ...

How to adjust \listing package width in Latex Editor (LEd)

Hi, I am trying to use the \listing package to include some .cpp files into my article. I add: \usepackage{listings} And then I use \lstinputlisting[language=c++]{File.cpp} The problem is that the width is not adjusted, so the code is cutted. Which is the solution? ...

Regsvr32 crashes on Window 7

I have an x64 (64-bit) COM dll. When trying to register it with Regsvr32 on Windows 7 - Regsvr32 crashes. Regsvr32 is run under cmd with administrative priviliges ("run as administrator"), I tried both 32 and 64bit cmd.exe and regsvr.exe, even two different PCs and it is always the same. Debugging the crashed Regsvr32 reports that buff...

what should i use with a c++ class, with or without "new"?

When should i use the pointer and when not? Whats the better Way? Must i delete the cat object of the pointer at the end of the programm? Example: cat piki; piki.miao(); cat *piki2 = new cat(); piki2->miao(); ...

How can I extract double pairs from an std::string with Boost Spirit?

I want to parse a string with a sequence of double pairs into an std::map with Boost Spirit. I adapted the example from http://svn.boost.org/svn/boost/trunk/libs/spirit/example/qi/key_value_sequence.cpp but I have a problem with difining a proper qi::rule for key and value: template <typename Iterator> struct keys_and_values : qi::gra...

How to find out where all a closed source application is writing to?

I have an application (the source for which I don't have), which can be invoked from command line like this $ ./notmyapp I want to know all the locations where the application is writing to. It outputs some files in the directory it is being called from, but I need to make sure that those are the only files that are created. So, I ne...

How do I correctly use a std::queue as a element in a template class?

I am reasonably new to C++ and have limited experience of templates. At the moment I am trying to implement a concurrent queue based on the example provided here. I am having problems compiling it and keep getting an error stating that "ISO C++ forbids declaration of ‘queue’ with no type" even after I stripped down the code to the follow...

Fibonacci extension in c++ segfaulting

I'm trying to add the extension to the Fibonacci numbers to take into account negative indexes. The extension is Fib(-n) = (-n)^(n+1) * Fib(n) I have attempted to implement this in c++ but I'm running into a problem and I'm not sure how to get around it. #include <iostream> #include <math.h> int fib(int n) { if ( n < 0 ){ ...

In WinCE, CreateFile function: File open failed

Hi, I need to do file operations in WinCE in a Windows mobile 6 project in visual studio 2008. For opening a file i did like below. HANDLE hFile = CreateFile(__TEXT("\\1.txt"), GENERIC_READ , FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); But hFile is coming as 0xffffffff. File ope...

C++ priority_queue underlying vector container capacity resize

Hi all, I'm using priority_queue with a vector as an underlying container. However I expect the size of the heap to be very large. I'm aware of problems with dynamic vector capacity resize. So I'm looking for ways to initially allocate enough space for the underlying vector in my priority_queue. Are there any suggestions out there to ac...

Image processing in languages other than c and matlab

Hey guys It seems like most image processing apps are done using matlab or OpenCV using C++. Are there any other languages providing good image processing libraries?? How do they compare to matlab and opencv? When I say languages I mean something like Java , python or even perl! ...

C++ template "deferred instantiation"

What is meant with "deferred instantiation" in C++ templates? ...

C++ Threads and Simple blocking mechanism?

I have a program in C++ that runs a bunch of threads to manipulate the same data. Each of these threads have a pointer to an object that is being manipulated, for example: thread1 and thread2 both have a pointer to object1 object1->addSomething() can be used by either thread1 or 2 and refer to the same object Now, these operations migh...

Getting Access Denied While Accessing the Named Pipe from Another System

I have a Named Pipe and It Works Fine While I access it using a Client which runs on My System The Client tries to open the File using following code: LPTSTR lpszPipename = TEXT("\\\\smyServerName\\pipe\\iPipe01"); hPipe = CreateFile( lpszPipename, // pipe name GENERIC_READ | // read and write access ...

Redirecting in C++

#include <iostream> #include <fstream> using namespace std; void foo(){ streambuf *psbuf; ofstream filestr; filestr.open ("test.txt"); psbuf = filestr.rdbuf(); cout.rdbuf(psbuf); } int main () { foo(); cout << "This is written to the file"; return 0; } Does cout write to the given file? If not, is there a way t...