c++

How do I use PostThreadMessage to close internet explore from c++

Hi Im trying to start iexplore.exe let it run for 5 seconds and then close it again. iexplore opens just fine however it doest close when i call the PostThreadMessage can any one see what im doing wrong here is the code: CString IEPath = "C:\\Program Files\\Internet Explorer\\IEXPLORE.EXE";//GetIEPath(); //IEPath += ' ' + url; std::st...

How to convert Unicode string into a utf-8 or utf-16 string?

How to convert Unicode string into a utf-8 or utf-16 string? My VS2005 project is using Unicode char set, while sqlite in cpp provide int sqlite3_open( const char *filename, /* Database filename (UTF-8) */ sqlite3 **ppDb /* OUT: SQLite db handle */ ); int sqlite3_open16( const void *filename, /* Database filename (UT...

_CRT_DEBUGGER_HOOK throws exception

Hi, I'm having a problem converting my program from VS2005 to VS2008. When I run the program in VS2008, the application starts up fine but when start playing around with the application it crashes giving me this error: "Microsoft Visual Studio C Runtime Library has detected a fatal error" And then the debugger points me to this functi...

Which is faster - C# unsafe code or raw C++

I'm writing an image processing program to perform real time processing of video frames. It's in C# using the Emgu.CV library (C#) that wraps the OpenCV library dll (unmanaged C++). Now I have to write my own special algorithm and it needs to be as fast as possible. Which will be a faster implementation of the algorithm? Writing an '...

Why can't I store boost::function in std::list?

Why does the following code have the error "error: expected `;' before 'it'"? #include <boost/function.hpp> #include <list> template< class T > void example() { std::list< boost::function<T ()> >::iterator it; } ...

parasoft C++ unit test question

I work on a project that was just told we had to incorporate Parasoft C++ unit testing tool into any code changes going forward. The problem I face is that we have methods with very small changes and now it seems we are forced to unit test the whole method. Many of these methods are hundreds or thousands of lines of code. I know for cert...

Do class/struct members always get created in memory in the order they were declared?

This is a question that was sparked by Rob Walker's answer here. Suppose I declare a class/struct like so: struct { char A; int B; char C; int D; }; Is it safe to assume that these members will be declared in exactly that order in memory, or is this a compiler dependent thing? I'm asking because I had always assumed...

Win32 WriteProcessMemory() magical offset value

I'm trying to read the data in a Win32 ListView owned by another process. Unfortunately, my WriteProcessMemory() call fails with the error "This function is not supported on this system." when I specify "NULL" for the base address in my VirtualAlloc() call. If, however, I offset that VirtualAlloc() address by some "magic" value that I go...

MySQL And C applications

When building a application that accesses a MySQL database on linux using C/C++ i have to dynamically link into the mysql client library. Is there a way in which i can statically link the application so that the mysql client libraries are no longer required? What is the best practice, with regards to C\C++ development, to include rathe...

Creating an object in shared memory inside a Shared Lib (so) in C++

Is it possible to share a single 'god' instance among everyone that links to this code, to be placed in a shared object? god* _god = NULL; extern "C" { int set_log_level(int level) { if(_god == NULL) return -1; _stb->log_level(level); return 0; } int god_init(){ if(_god == NULL){ _god = new god(); //Magic happ...

RGB back buffer in Win32

I have an array of RGB values, whose size I can guarantee to match the client area of a window on screen. Using the Win32 API, what are the easiest and fastest ways to get the contents of my array on the screen in response to a WM_PAINT message? If it makes it simpler/faster, we can assume it's a 32-bit display and each element of the ...

Best way to merge multiple STL containers, removing duplicate elements?

I have two STL containers that I want to merge, removing any elements that appear more than once. For example: typedef std::list<int> container; container c1; container c2; c1.push_back(1); c1.push_back(2); c1.push_back(3); c2.push_back(2); c2.push_back(3); c2.push_back(4); container c3 = unique_merge(c1, c2); // c3 now contains the...

Does myVector.erase(myPtr) delete the object pointed by myPtr ?

If I have the following code Foo *f = new Foo(); vector<Foo*> vect; vect.push_back(f); // do stuff vect.erase(f); Did I create a memory leak ? I guess so, but the word erase gives the feeling that it is deleting it. Writing this, I am wondering if it is not a mistake to put a pointer in a STL vector. What do you think ? ...

Namespacing (static) member variables

I would like to be able to achieve something like this: class Zot { namespace A { static int x; static int y; } } I am working with a legacy system that uses code generation heavily off a DB schema, and certain fields are exposed as methods/variables in the class definition. I need to add a few extra static ...

What is wrong with this inheritance?

I just don't get it. Tried on VC++ 2008 and G++ 4.3.2 #include <map> class A : public std::multimap<int, bool> { public: size_type erase(int k, bool v) { return erase(k); // <- this fails; had to change to __super::erase(k) } }; int main() { A a; a.erase(0, false); a.erase(0); // <- fails. can't find base class' function?! ...

Template specialization based on inherit class

I want to make this specialized w/o changing main. Is it possible to specialize something based on its base class? i hope so. -edit- I'll have several classes inheriting SomeTag. I dont want to write the same specialization for each of them. class SomeTag {}; class InheritSomeTag : public SomeTag {}; template <class T, class Tag=T> s...

Building a VST plugin on Mac OS X without Xcode

How do I build a VST plugin on Mac without using Xcode? (I'm using Code::Blocks). ...

Best way to take a snapshot of an object to a file.

What's the best way to output the public contents of an object to a human-readable file? I'm looking for a way to do this that would not require me to know of all the members of the class, but rather use the compiler to tell me what members exist, and what their names are. There have to be macros or something like that, right? Contrived...

Unmangling the result of std::type_info::name

I'm currently working on some logging code that supposed to - among other things - print information about the calling function. This should be relatively easy, standard C++ has a type_info class. This contains the name of the typeid'd class/function/etc. but it's mangled. It's not very usefull. I.e. typeid(std::vector).name() returns "S...

How to Disable Wireless Network Connection Notification Balloon?

I want to programmatically disable the notification I get when I connect to a wireless network. I know there is a way to disable ALL notifications (see here) but is there a way to only disable the one issued by Windows wireless Manager (i.e. wlanapi.dll). Many thanks! ...