-
dll access help
hi!
I am new to c++ and for a project i have to access a dll file. And in the access details of this dll the company has given this help -
Load dll and create the main interface (ILITWriter) using the CreateWriter() export.
// CreateWriter method detail
HRESULT CreateWriter(
[out, retval] IUnknown** ppWriter
);
Parameter ppWriter - Pointer to interface pointer of new writer
Could anybody pls tell me what they are actually want to say.Specifically what doest they mean with the term - "create the main interface (ILITWriter) using the CreateWriter() export." and how should i go about this.
Thanxs,
-
to load a dll, you can go through your options and settings and tell your linker to link the dll file.
To use the function, try something like this
Code:
IWriter * pWriter;
CreateWriter(&pWriter);
I'm not positive that IWriter is the correct type you would want, but it looks like what they would use with the naming conventions they have.
-
[EDIT]
Whoops, I thought you had to create the DLL. To use the CreateWriter() functions see these pages:
http://msdn.microsoft.com/library/de...ilitwriter.asp
http://msdn.microsoft.com/library/de...ilitwriter.asp
[/EDIT]
It is expecting you to return a COM object that implements the ILITWriter interface. If you have no knowledge of COM you are going to need to start with a tutorial.
Here is the beginnings of an object that implements ILITWriter:
Code:
class CLITWriter : public ILITWriter
{
private:
LONG m_cRefs;
public:
/* --IUnknown methods-- */
STDMETHODIMP QueryInterface(REFIID riid, void ** ppv)
{
if (ppv == NULL) return E_INVALIDARG;
if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_ILITWriter))
{
*ppv = (ILITWriter *) this;
}
else
{
*ppv = NULL;
return E_NOINTERFACE;
}
AddRef();
return NOERROR;
}
STDMETHODIMP_(ULONG) AddRef(void)
{
return InterlockedIncrement(&m_cRefs);
}
STDMETHODIMP_(ULONG) Release(void)
{
if (InterlockedDecrement(&m_cRefs) == 0)
{
delete this;
return 0;
}
return m_cRefs;
}
/* --ILITWriter methods -- */
STDMETHODIMP SetCallback(IUnknown * pCallback)
{
// code
}
STDMETHODIMP Create(const wchar_t* pwszLitFile, const wchar_t* pwszSourceBasePath,
const wchar_t* pwszSource, int iMinimumReaderVersion)
{
// code
}
// Rest of the ILITWriter methods
};
and here is an implementation of CreateWriter():
Code:
STDMETHODIMP CreateWriter(IUnknown** ppWriter)
{
if (NULL == ppWriter)
{
return E_INVALIDARG;
}
CLITWriter * pLitWriter = new CLITWriter;
*ppWriter = (IUnknown *) pLitWriter;
if (NULL == *ppWriter)
{
return E_OUTOFMEMORY;
}
return NOERROR;
}
-
hye!
thnxs for your help. i have started learning about COM .
Could u explain what does u mean with this method of Create
STDMETHODIMP Create(const wchar_t* pwszLitFile, const wchar_t* pwszSourceBasePath,
const wchar_t* pwszSource, int iMinimumReaderVersion)
{
// code
}
i.e what code we have to written in this method.
bye!