Click here to Skip to main content
Licence 
First Posted 12 Nov 2000
Views 78,731
Downloads 745
Bookmarked 23 times

Hex Converter

By | 13 Nov 2000 | Article
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

License

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

About the Author

Mukesh Gupta



United States United States

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Questionsql connection with MFC Pinmemberkoushik.net3:07 2 Jun '08  
GeneralMore Bugs PinmemberJames R. Twine13:28 16 Nov '02  
GeneralHex to string Pinmemberanoymous18:30 27 Apr '02  
GeneralSome bugs PinmemberThomas Hoekstra7:34 14 Feb '02  
GeneralHelp me for converting ! Pinmember55AABK9:49 19 Nov '01  
GeneralRe: Help me for converting ! Pinmemberllangolas6:05 28 Nov '01  
Questionhow to write a Test program of COM object PinmemberAnonymous18:58 3 Oct '01  
Questionhow to use? Pinmemberlinghuchong16:44 14 Dec '00  
AnswerRe: how to use? PinmemberMukesh Gupta20:19 14 Dec '00  
GeneralIt is me,again Pinmemberlinghuchong0:15 15 Dec '00  

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

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

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 14 Nov 2000
Article Copyright 2000 by Mukesh Gupta
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid