Posts Tagged ‘api’

How to retrieve the product type of Windows Home Server 2011

May 22, 2011

Windows Home Server 2011 has three product editions:

  • Windows SBS 2011 Essentials incorporates best-of-breed 64-bit product technologies for data backup and restore, remote access, file and printer sharing, and quick connection to the cloud—in one fully integrated solution.
  • Windows Home Server 2011 is the server platform that’s designed specifically for families and how they access their digital data. It helps to simplify and connect your family’s photos, videos, music, and TV by providing a familiar and easy way to share, store, stream, and automatically protect what’s most important. It supports up to 10 users.
  • Windows Storage Server 2008 R2 Essentials is the ideal storage server solution to help home-based and small business owners keep important data automatically backed up, protected, organized, and accessible from virtually anywhere. Built on the Windows Server 2008 R2 operating system, it streamlines access to centralized files for up to 25 users.

If you are writing an addin and you want to know what version your addin is running on, then this simple class will be very helpful to you.

The way we retrieve this information is via the Windows API GetProductInfo:
private const int PRODUCT_HOME_SERVER = 0x22;
private const int PRODUCT_SB_SOLUTION_SERVER = 0x13;
private const int PRODUCT_HOME_PREMIUM_SERVER = 0x32;

[DllImport(“kernel32.dll”)]
private static extern bool GetProductInfo(int dwOSMajorVersion, int dwOSMinorVersion, int dwSpMajorVersion, int dwSpMinorVersion, outuint pdwReturnedProductType);

///<summary>
/// WHS Edition
///</summary>
public enum WHSEdition
{
///<summary>
/// Unknown Edition
///</summary>
Unknown = 0,
///<summary>
/// Windows Home Server 2011
///</summary>
Standard = 1,
///<summary>
/
// Windows Small Business Server 2011 Essentials
///</summary>
SmallBusinessEssentials = 2,
///<summary>
/// Windows Storage Server 2008R2
///</summary>
StorageServer = 3
}

///<summary>
/// Retrieves the WHS Edition that the application is running on
///</summary>
///<returns>WHSEdition</returns>
public static WHSEdition GetWHSEdition()
 {
uint pdwReturnedProductType;

GetProductInfo(Environment.OSVersion.Version.Major,
Environment.OSVersion.Version.Minor,
0,
0,
out pdwReturnedProductType);

switch (pdwReturnedProductType)
{
case PRODUCT_HOME_SERVER: return WHSEdition.Standard;
case PRODUCT_SB_SOLUTION_SERVER: return WHSEdition.StorageServer;
case PRODUCT_HOME_PREMIUM_SERVER: return WHSEdition.SmallBusinessEssentials;
default: return WHSEdition.Unknown;
}
}

You can download the class sourcefile here.

Advertisements

Creating a client side installer for Vail

December 16, 2010

This is an article that shows an example of how to create a Client Side installer for Vail, that can be distributed to the client machines.
The Windows Home Server Development Kit-2 is needed and the Windows Home Server SDK.
Make sure you read the DevKit-2 first, before starting with this article.

You can find the article here.

Have fun!

WHS DevKit 2 updated

August 26, 2010

Version 1.1 of the WHS DevKit 2 has been published.
This Kit is an all-in-one package on how to create/build/install and addin for Vail, so if you want to have a go at it take the kit and have fun!

This new version has been updated to support the latest version of Windows Home Server: build 7659.
It contains a lot more information with regards to the first version of the kit; on the various aspects of developing an addin for Vail and now also has a section on how to build an installer too.

You can find it here.
The Vail SDK can be found here.

If you have comments, remarks, ideas, tips, additions,… don’t hesitate to contact me at contact (at) asoft-ware.com.

What’s new in the Dashboard SDK?

May 8, 2010

Microsoft has put together a great document that explains how the new dashboard is structured, what the different UI elements are, and a whole lot more…

A must read for every add-in developer!
Check it out: https://connect.microsoft.com/WindowsHomeServer/Downloads/DownloadDetails.aspx?DownloadID=28670

Developing an add-in for Vail

May 5, 2010

Vail (Windows Home Server version 2) can be extended with add-ins, just like with version 1. (see www.whsplus.com for lots of add-ins)
Or have a look at my add-ins AutoExit & AdminiMe.

Microsoft has made available the SDK to start developing the add-ins for Vail.
The downside is…that version-1 add-ins are NOT compatible with version 2! There is a whole new API to learn and your add-in needs to be converted.

I prepared a document to guide you along the way of creating your first ever Vail add-in.

But be warned:
– It is still very basic, just plain and simple.
– It is not fit for any production system.
– It’s only inteded for developers that want to have a try at starting to create an add-in. Nothing fancy yet.
– The installation mechanism isn’t described yet. Only how to configure your system to start coding, code a sample and test it on your server.
But it should get you on your way to start getting your hands dirty in the new Vail SDK. Have fun! 😉

You can find it here.
The Vail SDK can be found here.

If you have comments, remarks, ideas, tips, additions,… don’t hesitate to contact me at contact (at) asoft-ware.com.
More articles will follow later,
Nick

Undocumented WHS Classes: NetworkUtils

October 8, 2009

Another small class, in the series of undocumented API’s in Windows Home Server.

This new article describes the undocumented functions in the NetworkUtils class which is located in WHSCommon.dll.
This class contains 2 handy functions to get IP/Mac address of the server & the IP of the router.

void GetRouterIPAndServerMAC(out string ip, out string mac)
Get the IP address of the router and mac address of the server.

Sample code
string ip, mac;
NetworkUtils.GetRouterIPAndServerMAC(out ip, out mac);

Sample output
IP: 172.19.3.1
MAC:00-19-DB-7B-6D-35

string GetServerIP()
Get the IP address of the server.
Sample code
string serverIp = NetworkUtils.GetServerIP();

Sample output
IP: 172.19.3.10

So as you see, two very easy to use functions, that a very handy!
You can follow ASoft @Twitter: http://twitter.com/asoftware

Have fun!

Undocumented WHS classes: QShutdown / ShutdownDialog

September 7, 2009

A new article in the series of undocumented API’s in Windows Home Server is here.

This new article describes the undocumented functions in the QShutdown & ShutdownDialog class which is located in HomeServerControls.dll.

This class is a very tiny and simple one that can be used to shut down / reboot / log off the server.
It is also responsible for showing the shutdown dialog when shutting down the server via the settings dialog in the Windows Home Server console itself.

You can find it here.

You can follow ASoft @Twitter: http://twitter.com/asoftware

Have fun!

Undocumented WHS classes: MiscUtils

July 22, 2009

A new article in the series of undocumented API’s in Windows Home Server.

This new article describes the undocumented functions in the MiscUtils class which is located in HomeServerControls.dll.
This class is a handy little helper.
You can find it here.

The following functions are explained:
string DropSecondsFromTimeFormat(string timeFormat)
string FormatDescriptionToFixedWidth(string description, int maxChars)
uint GetPercentage(long value, long total)
bool IsCorrectLogonName(string name)
bool IsLetterOrDigit(string name)
bool IsValidHelpFile(string helpFileName)
string LastPieceOfThePathName(string name)
string LegibleDateTime(DateTime dateTime)
string LegibleDuration(TimeSpan duration)
string LegibleExcludedFolderName(string name)
string LegibleFolderNameSize(string name, long size)
string LegibleLocalDateTime(DateTime dateTime)
string LegibleSize(long lSizeInBytes)
string LegibleSize(long lSizeInBytes, int decimalPlaces)
string LegibleSize(long lSizeInBytes, int decimalPlaces, int maxLength)
string LegibleVolumeName(string volumeName, string mountPoint)
DateTime LocalTime(DateTime timeUTC)
string NameFromFriendlyPieces(string volumeFriendlyName, string folderName)
string PathNameWithoutLastPiece(string name)
bool SafeCharacters(string name)
bool SafeCharactersSafeEnding(string name)
bool SafeNameCharacters(string name)
void SetEnabled(Control control, bool enabled)
void SetImage(PictureBox control, System.Drawing.Image image)
void SetText(Control control, string text)
void SetValue(ProgressBar control, int value)
void SetVisible(Control control, bool visible)
void AddLineToTextbox(TextBox control, string line)
string StripDriveLetter(string s)
string StripMnemonicChar(string text)