This is the second part in an ongoing series looking at using the vSphere REST API and C++ with the cpp rest sdk (formerly known as “Casablanca”). In the first part we authenticated against SSO and got some information from the vCenter.
In this part we are going to refine our methods so that we can reuse our code. We will introduce some structs and functions that allow us to work with results.
One of the new features in vSphere 6.5 is the vSphere REST API. I’ve used the Web Services SDK before and it has never appeared as elegant as other automation APIs I’ve worked with, so the introduction of this held a lot of promise.
I rarely see examples for REST services in C++ and as it’s my chosen language and I’ve occasionally used “cpprestsdk” (previously known as Casablanca) I wondered if I could put something together. This is the first article in a series playing around with what is possible.
I had a problem recently where LoadState was not being called in my C++ based Windows Store App page that was based upon LayoutAwarePage.
This question from the Microsoft forums pointed me in the right direction – I had an OnNavigatedTo declared, this was being called and the LoadState was not. I moved the code from the OnNavigatedTo into LoadState and removed the former. Everything works again and I can now use Suspend/Resume properly on the page 🙂
So I’m going to start writing my own apps – I’ve been doing C++ for a while now (15 odd years) and fancy a new project to occupy my commute each day. I’ve equipped an old laptop with a cheap SSD and Windows 8 and installed Visual Studio. The SSD really makes a difference !
Some things I’ve noticed:
– System Restore Protection was not enabled for drive C: out of the box. I suffered some registry corruption (old laptop) and had to rebuild because of this.
– It took about an hour to build my refresh/reset image in case I suffered more problems. I really feel there should be UI elements advertising this feature.
I’ve been using it on my desktop (dual monitor) for a little while now, and while the base of the OS is good, it is hampered by a slightly unclear UI design. The ModernMix application that changes full screen Store apps to windowed apps is very welcome, but I still don’t like the number of clicks required to restart/shutdown, or that Control Panel/Preferences exists in two places.
Finally, some C++ and the class scope “internal”. I didn’t catch this in my first reading and it is essential to building your application. As you can’t have public class members which are not a Windows Runtime type, this is the only way of allowing classes to have accessible non-private members. For more information, see Namespaces and Type Visibility (C++/CX ) at MSDN.
For a while I’ve been looking into how to work out what browser URL’s a user has open with some code. Internet Explorer is easy – I’ll post that code later – but Firefox and others, that’s where it gets interesting.
From my searching there seems to be two ways to do this – DDE or by using looking through some child windows. This article isn’t going to tell you how to achieve this aim as I haven’t looked too closely at the second option but I have looked at the first and can write about it. But why ? for the sole reason that whilst trying to find this out I found many questions, but no clear answers and very little code. Everything in this article has been pieced together from the many to produce this one. Hopefully it will be helpful.