void Nish(char* szBlog);

Nish’s thoughts on MFC, C++/CLI and .NET

void Nish(char* szBlog); header image 4

Entries from January 2006

Preserving method signature for CCW

January 24th, 2006 · No Comments

I got this tip from my friend, Rama Krishna Vavilala – who’s virtually a total expert in anything Win32, from SDK to COM to .NET! Thanks Rama! By default, the CCW will convert your managed object’s methods so that the return type is an out parameter of the COM method. For example, if your managed [...]

[Read more →]

Tags: C++/CLI

CCW and returning an array of String^

January 22nd, 2006 · 3 Comments

I was working on an app that uses CCW to access a managed library. One of the methods in the library returns an array<String^>^. The COM version of this method will have a SAFEARRAY** as the [out,retval] parameter. Not having a lot of COM experience, I was pretty surprised to find how little documentation there [...]

[Read more →]

Tags: VC++ 2005

A managed smart pointer for using native objects in managed code

January 20th, 2006 · 2 Comments

CAutoNativePtr is a managed template class that I wrote, which acts as a smart pointer for using native objects in managed code, and it’s been posted on Code Project. CAutoNativePtr – A managed smart pointer for using native objects in managed code The class manages a smart pointer, which will automatically free the native resource [...]

[Read more →]

Tags: C++/CLI

A finalizer that nearly ended up wrong!

January 19th, 2006 · 8 Comments

Holy cow! I very nearly wrote some messed up code a few minutes ago. I was writing this disposable class, and I wanted to call the finalizer from my destructor, to avoid code duplication. Guess what I did first! Man, I really was stupid! Here goes. ~MyType() { !MyType(); } And you know what that [...]

[Read more →]

Tags: C++/CLI

gcnew T vs gcnew T()

January 13th, 2006 · 6 Comments

I was asked recently, why I always do gcnew T() when gcnew T produces the exact same MSIL. Here’s why. In standard C++, new T and new T() are not the same. The latter version zeroes out the memory before calling the constructor, so if you haven’t initialized a member variable, it’s zero initialized by [...]

[Read more →]

Tags: C++ · C++/CLI

You cannot #include wabdefs.h with VC++ 2005

January 4th, 2006 · 3 Comments

The following code will not compile :- #include <windows.h> #include <wabdefs.h> int main() { return 0; } You’ll get a compiler error (C2371) saying that you are redefining WCHAR. The problem is that wabdefs.h defines WCHAR as a typedef for WORD, while winnt.h defines WCHAR as a typedef for wchar_t. In VC++ 2005, /Zc:wchar_t is [...]

[Read more →]

Tags: VC++ 2005

No more implicit overriding for virtual functions of ref types

January 2nd, 2006 · No Comments

I was just going through my Code Project article on Function overriding in C++/CLI, and I noticed how the code snippets in the article indicated that if you don’t specify new or override on a derived class virtual function, override is assumed. Well, I was using an early Alpha compiler when I wrote that article [...]

[Read more →]

Tags: C++/CLI

Windshield fluid that freezes on the windshield!

January 2nd, 2006 · 11 Comments

The first time it happened to me, I was totally stunned I tell you. There I was, driving happily when it started snowing, and when I used my wipers, the glass got all cloudy and so I used the windshield (or wiper) fluid, and guess what! The damn liquid froze on the windshield, despite my [...]

[Read more →]

Tags: Toronto