Getting started with Cross-platform development

They say if you do not eat, drink, sleep C/C++ – then the chances are you are not a real developer. Is it? May be, may be not. But certainly if you have not done cross-platform development or design, you cannot claim to be a good architect or developer. Is cross-platform development really so special?…

3

How to check if my code is executing inside a Managed App or Native App?

If you check the CRT source code (inside VC\crt\src\crt0.c) you can find an interesting function check_managed_app() that returns 1 if managed app, 0 if not based on the COM Runtime Descriptor in the Image Data Directory of the PE or PE+ header. You can generalize it to test if you are running as part of…

1

Well-designed libraries

It is very rare that we come across a well-designed library every day, and even rare that we get a chance to work on them on daily basis. While it is hard to define what makes any given library “well-designed”, it is rather easy to identify what is not. However, there are few exceptionally good…

1

Having hard time marshalling parameters from C++ to .Net?

If you are finding it difficult to send parameters from C++ to .Net, try if you can use the following class: ——————————————————————————————————————————– #ifndef __PARAMETERS_H_A1B7ECCA_1691_43d0_ACDD_EBE1208005F9#define __PARAMETERS_H_A1B7ECCA_1691_43d0_ACDD_EBE1208005F9#include <Comdef.h>#ifdef _DEBUG  #define NO_ERROR_CHECKING FALSE //Use Error Checking for Debug Versions (throws Exception from Constructor !!)#else  #define NO_ERROR_CHECKING TRUE //Turn-off Error Checking for Release Versions#endif#ifndef _MFC_VER //Check if this is…

1

How to return String-Arrays from C++ COM component to C#?

Want to return an array of strings from native COM component to managed code? You need to declare the string array as SAFEARRAY(VARIANT) in the COM code. IDL for the function that returns the array of strings for the COM component would look like,       [id(1)] HRESULT GetStringArray([out] SAFEARRAY(VARIANT)* StrArray); The C++ implementation of the…

3

How to Modify Managed Strings in Native Code?

Want to modify a managed string passed to a native function? I collected two ways of doing it. Either you can use System::Text::StringBuilder mechanism or you can use the array method mentioned at http://msdn2.microsoft.com/en-us/library/s04yfy1s(VS.80).aspx You can pass the string that you want to modify as a one-element string array to the native code and modify…

1