Hex Converter





0/5 (0 vote)
Nov 13, 2000

103030

998
Converts a lump of binary/text data to hex format.
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); //Set the input file / string CComBSTR bstrFile(_T("C:\MyFile.dat")) hr = pHC->SetFile(bstrFile);
or
CComBSTR bstrInput(_T("blah........blah............")); hr = pHC->SetString(bstrString); //get the total no. of lines in the output string (containing 16 bytes each) long lLines; hr = pHC->GetLineCount(&iLines); //get each line 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