c++

Using managed C++ dll from C#

I've created a dll using managed C++. Now I'm trying to use it from C#. I've added the Object to project references. Object browser shows the object in the dll correcly, path to the dll in object browser corresponds to the actual path. However, when I run the C# program it complains: Unhandled Exception: System.IO.FileNotFoundException...

What is the best way to implement smart pointers in C++?

I've been evaluating various smart pointer implementations (wow, there are a LOT out there) and it seems to me that most of them can be categorized into two broad classifications: 1) This category uses inheritance on the objects referenced so that they have reference counts and usually up() and down() (or their equivalents) implemented....

timer class in linux

I need a timer to execute callbacks with relatively low resolution. What's the best way to implement such C++ timer class in Linux? Are there any libraries I could use? ...

Extract element from 2 vectors?

I have 2 vector of with one has vec1{e1,e2,e3,e4} and the other one with vec2 {e2,e4,e5,e7} How to effectively get three vector from above vectors such that 1.has elements that is available only in vec1 similarly 2 has only vec2 elements and 3.with common elements ...

Public and private access for the same member functions

I have a class (class A) that is designed to be inherited by other classes written by other people. I also have another class (class B), that also inherits from A. B has to access some A's member functions that shouldn't be accessed by other inheriting classes. So, these A's member functions should be public for B, but private for othe...

What does it mean when an array name is in parentheses with a caret pointer before it?

I have an array of unsigned numbers, called dataArray (actually in the program I am trying to figure out, they are entered as hexadecimal numbers, but I don't think that's important). I have another variable of type unsigned char, called c. What does this do? unsigned int dataArray[]={1,2,3,4,5}; unsigned char c; x=c^ (dataArray)[i]; ...

LPTSTR to int (c++)

Hi, I'm passing some numeric arguments while creating a process (in VC++) I'm stuck at casting LPTSTR to int. Thanks in advance, ...

WinAPI and UTF-8 support

Quick question regarding UTF-8 support and various Win32 API's. In a typical C++ MFC project, is it possible for MessageBox() to display a UTF-8 encoded string? Thanks, Andrew ...

Get bytes from std::string in C++

Hi I'm working in a C++ unmanaged project. I need to know how can I take a string like this "some data to encrypt" and get a byte[] array which I'm gonna use as the source for Encrypt. In C# I do for (int i = 0; i < text.Length; i++) buffer[i] = (byte)text[i]; What I need to know is how to do the same but using unmanaged C++....

Writing string (REG_SZ) values to the registry in C++

Hello, I've got most of the code for writing a value to the windows registry, however when I change the path to a dummy key and value that I've set up for testing it fails. My code is below: HKEY hKey; LPCTSTR sk = TEXT("SOFTWARE\TestSoftware"); LONG openRes = RegOpenKeyEx(HKEY_LOCAL_MACHINE, sk, 0, KEY_ALL_ACCESS , &hKey...

getting a normal ptr from shared_ptr ?

i have something like shared_ptr t(makeSomething(), mem_fun(&Type::deleteMe)) i now need to call C styled func that require a pointer to Type. How do i get it from shared_ptr? ...

CUDA + Visual Studio = suppressed output window

Normally, when I use Visual Studio to do a build, I see warnings and errors shown in the output pane, e.g. 1>------ Build started: Project: pdcuda, Configuration: Release x64 ------ Compiling... foo.cpp Linking... foo.obj : error LNK2001: unresolved external symbol "foo" ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped =...

Can you derive a Managed C++ class from an Unmanaged C++ class?

I have an unmanged C++ class I have written in an unmanged dll. I have a managed dll that references the unmanaged dll. Can a class in the managed dll derive from the unmanaged class? Using Visual Studio 2008 ...

How to create threads in VC++

I tend to use POSIX Threads, when programming in C, under Linux. Without MFC Question: How would I then create threads in VC++? Find more information on threads under win32? Edit: Brief illustrations I LOVE stackoverflow - best resource for students! Regards ...

Why does c_str() print the string twice?

So... when I go: cout<<stringName<<endl; I get: NT But when I go: cout<<stringName.c_str()<<endl; I get: NTNT Why? ...

Compiling a DLL with gcc

Sooooo I'm writing a script interpreter. And basically, I want some classes and functions stored in a DLL, but I want the DLL to look for functions within the programs that are linking to it, like, program dll ---------------------------------------------------- send code to dll-----> parse code ...

Efficiently wait for a flag state change without blocking resources?

Thread to wait infinitely in a loop until a flag state change, then call function. pseudo code illustration: while (true) { while (!flag) { sleep(1); } clean_upfunction(); } Currently: Using the multithreaded versions of the C run-time libraries only No: MFC Question: Is there a more efficient way o...

tracking after cluster group status c++

Hi, I would like to write a cluster aware application that will track after the status of a cluster group. to be more specific, I'd like to probe after the group's Owner. The application should know if the local machine is the owner of the group or not and behave accordingly. can I probe the registry for that? if yes, where? if not, d...

Interprocess communication between 32- and 64-bit apps on Windows x64

We'd like to support some hardware that has recently been discontinued. The driver for the hardware is a plain 32-bit C DLL. We don't have the source code, and (for legal reasons) are not interested in decompiling or reverse engineering the driver. The hardware sends tons of data quickly, so the communication protocol needs to be pretty...

How do I zip a directory of files using C++?

I'm working on a project using C++, Boost, and Qt. I understand how to compress single files and bytestreams using, for example, the qCompress() function in Qt. How do I zip a directory of multiple files, including subdirectories? I am looking for a cross-platform (Mac, Win, Linux) solution; I'd prefer not to fire off a bunch of new pr...