October 2008 - Posts

Excel RTD Servers: C++ Interfaces

Excel provides a function called RTD (real-time data) that lets you specify a COM server via its ProgId so that you can push data into Excel. Recently I had to implement an RTD server for a client and was frustrated at how hard it was to find the COM interface definitions to implement. It doesn’t appear to be documented anywhere. They’re clearly geared toward VB6 or VBA or VBScript or whatever. Anyway, I sucked out the necessary COM interfaces from the type library embedded inside the Excel executable. Here’s what an RTD server written in C++ needs to implement:

struct __declspec(novtable) __declspec(uuid("A43788C1-D91B-11D3-8F39-00C04F3651B8"))
IRTDUpdateEvent : IDispatch
{
    virtual HRESULT __stdcall UpdateNotify() = 0;

    virtual HRESULT __stdcall get_HeartbeatInterval(/*[out]*/ long* value) = 0;

    virtual HRESULT __stdcall put_HeartbeatInterval(long value) = 0;

    virtual HRESULT __stdcall Disconnect() = 0;
};

struct __declspec(novtable) __declspec(uuid("EC0E6191-DB51-11D3-8F3E-00C04F3651B8"))
IRtdServer : IDispatch
{
    virtual HRESULT __stdcall ServerStart(/*[in]*/ IRTDUpdateEvent* callback,
                                          /*[out]*/ long* result) = 0;

    virtual HRESULT __stdcall ConnectData(long topicId,
                                          /*[in]*/ SAFEARRAY** strings,
                                          /*[in,out]*/ VARIANT_BOOL* newValues,
                                          /*[out]*/ VARIANT* values) = 0;

    virtual HRESULT __stdcall RefreshData(/*[in,out]*/ long* topicCount,
                                          /*[out]*/ SAFEARRAY** data) = 0;

    virtual HRESULT __stdcall DisconnectData(long topicId) = 0;

    virtual HRESULT __stdcall Heartbeat(/*[out]*/ long* result) = 0;

    virtual HRESULT __stdcall ServerTerminate() = 0;
};

I’m posting this mostly so that I can quickly find it in future but perhaps it will come in handy for others. I could write some more about how the heck you implement these crazy interfaces and other tricks I’ve picked up but I suspect there’s a very small number of developers who care.  :)

Posted by KennyKerr with 5 comment(s)

Windows 7 and Concurrency

Now that the Windows 7 keynote is over we can finally start exploring some of the improvements. This is going to be a truly awesome upgrade. As Paul puts it, Windows 7 is Windows Vista done right.

If you’re not sure where to start then I’d suggest starting right at the bottom. Listen to Mark Russinovich introduce many of the improvements made to the Windows kernel. This is really going to benefit those of you with more than 64 processing cores.  :)

Incidentally, if you’re wondering why Mark referred to the Concurrency Runtime as “concert” the reason is that the APIs for the scheduler are included in the concrt.h header file. For more on that check out what Rick has to say about Visual C++ 10.

Posted by KennyKerr with no comments

Time to Move?

I’m starting to think it’s about time I moved this blog. I’ve appreciated not having to worry about hosting and taking advantage of Microsoft’s hosting bandwidth, but it has been frustrating at times not having as much control as I wanted. The weblogs.asp.net server in particular seems to have branched from the blogs.msdn.com server some time back. Originally they were running the same code if I remember correctly.

Also, you have to wonder what’s happening with Microsoft’s online advertising business when they start employing Google ads!   :)

Admittedly, Microsoft is outsourcing this and probably doesn’t pay much attention to it anymore. Still it’s a bit disappointing.

Anyway, as long as you’re subscribed to my feed you should be just fine.

http://feeds.feedburner.com/kennykerr
 
I haven’t yet decided where I’ll move to though. I’m seriously considering just building my own system with ASP.NET MVC. I’ve used quite a few blogging services before but they’ve all lacked one thing or another...

Produce the highest quality screenshots with the least amount of effort! Use Window Clippings.

Posted by KennyKerr with 4 comment(s)

Recent Reading List

My family loves books. Here are a few of the better books I've read this year.   

 

Business

I really like the idea of a small software company. If that interests you then you should find these books very helpful.

Business of Software by Eric Sink

Micro-ISV by Bob Walsh

Growing a Business by Paul Hawken

 

Programming and Debugging

I recently started reading Advanced Windows Debugging and just love it. Windows Internals is one of those books I tend to read again each year, especially when a new edition is out. I can't wait for the 5th edition. Large-Scale C++ Software Design is a very different kind of C++ text book. Most book focus on the logical aspects of C++ design. This book focuses more on the physical. Its packed full of helpful guidance for managing larger projects.

Advanced Windows Debugging by Mario Hewardt and Daniel Pravat

Windows Internals (4th edition) by Mark Russinovich and David Solomon. You can also pre-order the 5th edition.

Large-Scale C++ Software Design by John Lakos

 

Other

Just a random collection of other books I really enjoyed.

You're Stepping on My Cloak and Dagger by Roger Hall

Family Driven Faith by Voddie Baucham

Culture Warrior by Bill O'Reilly

Here Comes Everybody by Clay Shirky

 

My wife also introduced me to The Book Depository. Free shipping worldwide. We've used it a lot and it's been great. They're also often quite a bit cheaper than Amazon, at least here in the UK.

What have you been reading lately?

Posted by KennyKerr with 1 comment(s)

The Biggest Release of the Year...

I’ve been a bit distracted over the last few weeks as our third son Samuel John was born earlier this month. I hope to catch up on email soon.

 

Posted by KennyKerr with 9 comment(s)

MSDN Library without the Bling

The MSDN Library is one of those things I install locally right after installing Visual Studio. It’s an invaluable resource to have at your fingertips. There are however occasions when I don’t have it installed or I’m using the web for some extra search power. Inevitably I end up with something like this:

Can you find the content? Its hiding in the lower right corner and most of it is scrolled out of view to make space for all the bling that dominates the MSDN website. This is really frustrating and makes me long for the simple days of the web when it was all about content. Well there’s hope!

Instead of visiting http://msdn.com/library for the MSDN Library, visit http://msdn.com/library(loband). Notice the (loband) at the end of the URL. You’ll be presented with a simple HTML page with a link to “Persist low bandwidth view”. This stores a cookie on your computer that instructs the MSDN Library to display all future content without frames and simpler HTML.

Although it’s geared at folks with limited bandwidth, it’s a great help for those who appreciate a focus on content. Now when I search the web for shared_ptr here’s what I get:

Now if only I can remember that “bb982026” stands for shared_ptr!

Thanks for the tip Kate!

Produce the highest quality screenshots with the least amount of effort! Use Window Clippings.

Posted by KennyKerr with 1 comment(s)

Installing Visual Studio for C++ Development

Installing Visual Studio for .NET development is pretty easy: Install Visual Studio and the latest service pack. You’re done.

Installing Visual Studio for C++ development is fraught with problems (ok that’s perhaps a bit dramatic). In most cases you not only need Visual Studio and its service pack, but you also need the latest Windows SDK. Since Visual Studio SP1 was released I’ve had some of my installations fail, or worse, just corrupt my build environment. I couldn’t figure out why it would fail some of the time. I eventually pinged Stephan (STL) on the Visual C++ team who pointed out that the Windows SDK installation corrupts the SP1 build environment. Anyway, here is the order in which you must install everything in order for it to work.

1. Visual Studio 2008

2. Windows SDK for Windows Server 2008

3. Visual Studio 2008 Service Pack 1

If you did step 3 before step 2 you need to rerun step 3 which is extremely tedious. Also, since the Visual Studio installation is so complex, I’ve found its less painful to simply reinstall Windows than to try upgrading or repairing a broken installation.

If you follow the steps above you shouldn’t have any problems. Hope that helps.

Produce the highest quality screenshots with the least amount of effort! Use Window Clippings.

Posted by KennyKerr with 1 comment(s)
More Posts