// Declare Variables
extern GUID CLSID_PROVIDER;
IDBInitialize *pIDBInitialize;
IDBProperties *pIDBProperties;
IDBCreateSession *pIDBCreateSession;
IOpenRowset *pIOpenRowset;
DBPROP      rgProperties[1];
DBPROPSET   rgPropertySets[1];
DBID TableID;
HRESULT hResult;

// NOTE Error checking is removed for clarity

// Load the driver via CoCreateInstance
hResult = CoCreateInstance(CLSID_PROVIDER, NULL, CLSCTX_INPROC_SERVER, IID_IDBInitialize,
  (LPVOID*)&pIDBInitialize);

// Set any Data Source initialization properties here
// This example only sets the Data Source Name rgPropertySets.rgProperties = rgProperties;
rgPropertySets.cPropertySets = 4;
rgPropertySets.guidPropertySet = DBPROPSET_DBINIT;

VariantInit (&rgProperties[0].vValue); rgProperties[0].dwPropertyID =
DBPROP_INIT_DATASOURCE; rgProperties[0].dwOptions = DBPROPOPTIONS_REQUIRED;
rgProperties[0].vValue.vt = VT_BSTR; rgProperties[0].vValue.bstrVal = SysAllocString
(OLESTR("Amazon Redshift Wire Protocol"));

// Get the Data Source Properties Interface
hResult = pIDBInitialize->QueryInterface(IID_IDBProperties, (void**) &pIDBProperties);

// Set the Properties
hResult = pIDBProperties->SetProperties (1, &rgPropertySets);

// Initialize the Provider 
hResult = pIDBInitialize->Initialize ();

// Request the IDBCreateSession interface from the Data Source object
hResult = pIDBInitialize->QueryInterface(IID_IDBCreateSession, (void**)
&pIDBCreateSession);

// Create a Session
hResult = pIDBCreateSession->CreateSession(NULL, IID_IOpenRowset, (IUnknown**)
&pIOpenRowset);

// Save the unlock key as a TableID
TableID.eKind = DBKIND_NAME;
TableID.uName.pwszName = L"{License File Name,OEM Password}";

// first action must be to unlock the driver ...
// Open a table with the unlock key
// Since we know it will fail, don't request properties
// and we don't request an interface returned back.
hResult = pIOpenRowset->OpenRowset(NULL,&TableID,NULL, IID_IRowset, 0, NULL, (IUnknown**) NULL);

// The provider is now unlocked

// Clean up unneeded resources
pIDBInitialize->Release ();
pIDBProperties->Release ();
VariantClear (&rgProperties[0].vValue);