Introduction
This is a simple COM component that converts a lump of binary/text
data to the hex format. I just wrote it for one of my projects to
have a look at the binary data. The component supports only two
interfaces; IHexConverter
and ISupportErrorInfo
,
with four methods. It's been developed on Win98, with VC++ 6.0. It's
very simple in use, and I thought it might be useful for others.
Methods
SetFile([in] BSTR bstrFilePath);
SetString([in] BSTR bstrInput);
GetLineCount([out] long* pLineCount)
GetNextLine([out] BSTR* pbstrOutput)
Typical Usage (in C++):
::CoInitialize(NULL);
IHexConvertor* pHC = NULL;
HRESULT hr = CoCreateInstance(CLSID_HexConverter,
CLSTX_INPROC_SERVER,
IID_IHexConverter,
(void**)&pHC);
CComBSTR bstrFile(_T("C:\MyFile.dat"))
hr = pHC->SetFile(bstrFile);
or
CComBSTR bstrInput(_T("blah........blah............"));
hr = pHC->SetString(bstrString);
long lLines;
hr = pHC->GetLineCount(&iLines);
for(int i = 0; i < iLines; i++)
{
CComBSTR bstrOutput;
hr = pHC->GetNextLine(&bstrOutput);
}
pHC->Release();
pHC = NULL;
::CoUnInitialize();
You need to register the component before use. If you spot any problems
or possible enhancements please let me know at [Mukesh Gupta].
References:
- Windows Programming With MFC By: Jeff Prosise