R
Russell Mangel
/*
Hi,
I am trying to hold a reference to un-managed pointer IStorage.
The client/callers will make many accesses to IStorage, but
only in-directly. For performance reasons IStorage needs to be
opened once, and a reference held by MyClass for duration of session.
1. Should I use a native class to do the native stuff?
2. Should I use pin_ptr?
3. Is it possible to correct the error message in MyClass?
Please suggest to me the best way to accomplish this.
Russell Mangel
Las Vegas, NV
PS.
Thanks for your assistance.
This project is a C++/CLI CLR Class Library, a DLL for use by C#, and VB.Net
clients.
When you create a CLR Class Library project do the following:
Under Linker, Input, Additional Dependencies, remove $(NoInherit).
*/
#pragma once
using namespace System;
#define WIN32_LEAN_AND_MEAN
#include <stdio.h>
#include <tchar.h>
#include <windows.h>
#include <ole2.h>
namespace MyNameSpace
{
public ref class MyClass
{
private:
// This line causes an error:
IStorage *pStorage;
// C2440: 'reinterpret_cast' : cannot convert from 'cli::interior_ptr<Type>'
to 'IStorage **'
public:
int Open()
{
HRESULT hr = S_OK;
// IStorage *pStorage = NULL;
hr = StgOpenStorage(
L"C:\\AnyMSOfficeDocument.doc",
NULL,STGM_READ | STGM_SHARE_DENY_WRITE,
NULL,
NULL,
reinterpret_cast <IStorage**>(&pStorage) );
return hr;
}
};
}
Hi,
I am trying to hold a reference to un-managed pointer IStorage.
The client/callers will make many accesses to IStorage, but
only in-directly. For performance reasons IStorage needs to be
opened once, and a reference held by MyClass for duration of session.
1. Should I use a native class to do the native stuff?
2. Should I use pin_ptr?
3. Is it possible to correct the error message in MyClass?
Please suggest to me the best way to accomplish this.
Russell Mangel
Las Vegas, NV
PS.
Thanks for your assistance.
This project is a C++/CLI CLR Class Library, a DLL for use by C#, and VB.Net
clients.
When you create a CLR Class Library project do the following:
Under Linker, Input, Additional Dependencies, remove $(NoInherit).
*/
#pragma once
using namespace System;
#define WIN32_LEAN_AND_MEAN
#include <stdio.h>
#include <tchar.h>
#include <windows.h>
#include <ole2.h>
namespace MyNameSpace
{
public ref class MyClass
{
private:
// This line causes an error:
IStorage *pStorage;
// C2440: 'reinterpret_cast' : cannot convert from 'cli::interior_ptr<Type>'
to 'IStorage **'
public:
int Open()
{
HRESULT hr = S_OK;
// IStorage *pStorage = NULL;
hr = StgOpenStorage(
L"C:\\AnyMSOfficeDocument.doc",
NULL,STGM_READ | STGM_SHARE_DENY_WRITE,
NULL,
NULL,
reinterpret_cast <IStorage**>(&pStorage) );
return hr;
}
};
}