CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 13 of 13

Thread: Reading Memory

  1. #1
    Join Date
    May 2006
    Posts
    203

    Question Reading Memory

    Whats the possibility to set some text to the memory and read the same text after a while but in the same process. If it is possible how can i accoplish this please explain me in detial.

    I have tried with memset() and etc., but i couldnt see the desired output.

  2. #2
    Join Date
    Dec 2004
    Location
    Poland
    Posts
    1,165

    Re: Reading Memory

    Write text to memory:
    Code:
    std::string mystring = "TEST STRING";
    Read the same text after a while but in the same process:
    Code:
    std::cout << mystring;
    Is this not sufficient?
    B+!
    'There is no cat' - A. Einstein

    Use &#91;code] [/code] tags!

    Did YOU share your photo with us at CG Members photo gallery ?

  3. #3
    Join Date
    May 2006
    Posts
    203

    Question Re: Reading Memory

    Actually i am reading some text from file so it will be a stream of Bytes, i need to send bytes to MFC Activex control and i need to read it. I have tried in many ways but i couldnt so i am thought going this method. Do you have solution for this.

  4. #4
    Join Date
    Oct 2002
    Location
    Germany
    Posts
    6,205

    Re: Reading Memory

    Quote Originally Posted by sivaprakash.shanmugam
    Actually i am reading some text from file so it will be a stream of Bytes, i need to send bytes to MFC Activex control and i need to read it. I have tried in many ways but i couldnt so i am thought going this method.
    How are you reading the text file? Post code.

  5. #5
    Join Date
    Jul 2005
    Posts
    767

    Re: Reading Memory

    So you think you just read some bytes from the memory and some how tranfer it to the activex control...well I have to say that is would not be possible. ActiveX control's work and comunicate with each other using COM and you have to use COM API to achieve your task.

  6. #6
    Join Date
    Oct 2002
    Location
    Germany
    Posts
    6,205

    Re: Reading Memory

    Quote Originally Posted by MrBeans
    So you think you just read some bytes from the memory and some how tranfer it to the activex control...well I have to say that is would not be possible. ActiveX control's work and comunicate with each other using COM and you have to use COM API to achieve your task.
    It is possible for the methods exposed by an ActiveX control (and interface thereof) to accept a BYTE*, or a BSTR...

  7. #7
    Join Date
    May 2006
    Posts
    203

    Question Re: Reading Memory

    System::IO::FileStream* fsFileContennt = new System::IO::FileStream(dlgUploadFile->get_FileName (),System::IO::FileMode::Open,System::IO::FileAccess::Read);
    BinaryReader* brFileContent = new BinaryReader(fsFileContennt);

    From this i am getting Bytes how can i send it to Activex control.

  8. #8
    Join Date
    Oct 2002
    Location
    Germany
    Posts
    6,205

    Re: Reading Memory

    Quote Originally Posted by sivaprakash.shanmugam
    From this i am getting Bytes how can i send it to Activex control.
    I presume that the ActiveX control is available via a member variable.

    If so, simply call -
    Code:
    m_MyActiveX.Method (Appropriate Parameters...);
    As you can see, without knowing the signature of "Method", people here will be clueless as to what you are asking for.

  9. #9
    Join Date
    Oct 2002
    Location
    Germany
    Posts
    6,205

    Re: Reading Memory

    [ redirected ]

    Regards,
    Siddhartha

  10. #10
    Join Date
    May 2006
    Posts
    203

    Question Re: Reading Memory

    mMyActiveX.Method (Appropriate Parameters...);

    Here is the problem; i couldnt get appropriate Parameter formates thats where exactly i'm struggling. Let me know whats the correct format for both the side.

  11. #11
    Join Date
    Oct 2002
    Location
    Germany
    Posts
    6,205

    Re: Reading Memory

    Quote Originally Posted by sivaprakash.shanmugam
    mMyActiveX.Method (Appropriate Parameters...);

    Here is the problem; i couldnt get appropriate Parameter formates thats where exactly i'm struggling. Let me know whats the correct format for both the side.
    You need to know the parameters that the ActiveX takes. We can't tell you what parameters a control we know nothing of takes, right?

    (It's like me asking you to name the method I am currently programming... )

    Is the ActiveX one of your creation? If so, program the method to accept either BSTR or BYTE*

    If the ActiveX is not of your creation, the documentation / the compiler error will tell you what it expects vis-a-vis what you are (wrongly) supplying.

  12. #12
    Join Date
    May 2006
    Posts
    203

    Question Re: Reading Memory

    As you said, it is not third party control i am creating both the things and i have used BYTE* to send the data but i dont know how to read the BYTE* variable in MFC Activex control side thats why i have started to search some articles and distracted.

    BYTE* will hold the pointer of character right?. I have length also from these how can i get my data back in Activex control.

    Please explain me.,since i am very new to MFC ActiveX.

  13. #13
    Join Date
    Oct 2002
    Location
    Germany
    Posts
    6,205

    Re: Reading Memory

    Actually, as you are reading a text file, a BSTR makes more sense. A BSTR is a Binary String.

    Quote Originally Posted by sivaprakash.shanmugan
    BYTE* will hold the pointer of character right?. I have length also from these how can i get my data back in Activex control.
    You are right that it will point to the first BYTE (which happens to be a character). However, there is no way to know the length of a BYTE* array and you need to pass array length as a second parameter.

    Of course, if you assume that your BYTE* is always a character array, then you can stop at the first NULL character. But, rather than do this, one would change the input to BSTR instead of BYTE* and use the BSTR as a wide-character string.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured