Click here to Skip to main content
15,880,200 members
Articles / Programming Languages / C++

Hex Converter

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
13 Nov 2000 102.1K   996   23   10
Converts a lump of binary/text data to hex format.


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.


SetFile([in] BSTR bstrFilePath);
SetString([in] BSTR bstrInput);
GetLineCount([out] long* pLineCount)
GetNextLine([out] BSTR* pbstrOutput)

Typical Usage (in C++):


IHexConvertor* pHC = NULL;
HRESULT hr = CoCreateInstance(CLSID_HexConverter,

//Set the input file / string
CComBSTR bstrFile(_T("C:\MyFile.dat"))
hr = pHC->SetFile(bstrFile);


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);



You need to register the component before use. If you spot any problems or possible enhancements please let me know at <a href="">[Mukesh Gupta].


  • Windows Programming With MFC By: Jeff Prosise


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

Questionsql connection with MFC Pin
koushik.net2-Jun-08 3:07
koushik.net2-Jun-08 3:07 
GeneralMore Bugs Pin
James R. Twine16-Nov-02 13:28
James R. Twine16-Nov-02 13:28 
GeneralHex to string Pin
27-Apr-02 18:30
suss27-Apr-02 18:30 
GeneralSome bugs Pin
14-Feb-02 7:34
suss14-Feb-02 7:34 
GeneralHelp me for converting ! Pin
19-Nov-01 9:49
suss19-Nov-01 9:49 
GeneralRe: Help me for converting ! Pin
28-Nov-01 6:05
suss28-Nov-01 6:05 
Questionhow to write a Test program of COM object Pin
3-Oct-01 18:58
suss3-Oct-01 18:58 
Questionhow to use? Pin
linghuchong14-Dec-00 16:44
linghuchong14-Dec-00 16:44 
AnswerRe: how to use? Pin
14-Dec-00 20:19
suss14-Dec-00 20:19 
GeneralIt is me,again Pin
linghuchong15-Dec-00 0:15
linghuchong15-Dec-00 0:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.