MSDN[
^] says:
WINOLEAPI StgCreateStorageEx(
__in const WCHAR *pwcsName,
__in DWORD grfMode,
__in STGFMT stgfmt,
__in DWORD grfAttrs,
__in STGOPTIONS *pStgOptions,
__in PSECURITY_DESCRIPTOR *pSecurityDescriptor,
__in REFIID riid,
__out void **ppObjectOpen
);
Which means that your pStg is an OUT parameter: I.e A pointer to an interface pointer variable that receives a pointer for an interface on the new storage object. pStg is not initialized to point anywhere, so you get an error!