Results 1 to 3 of 3

Thread: Get some memory and then save that memory stream to disk

  1. #1

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Get some memory and then save that memory stream to disk

    Right now I call my C++ functions from managed code and pass in integer arrays so I have workspace.

    How would I go about grabbing some memory directly in C++ for my use.

    And secondly - how would I go about writing that memory stream to a binary file so that I could restore it's contents from file at a later date?

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  2. #2
    Fanatic Member 2kaud's Avatar
    Join Date
    May 2014
    Location
    England
    Posts
    996

    Re: Get some memory and then save that memory stream to disk

    I don't use managed c++, but in c++ you use new to obtain memory. See http://www.cplusplus.com/reference/new/operator%20new/

    To write this memory to a file use write(). See http://www.cplusplus.com/reference/o...ostream/write/

    and to read back this memory use read() See http://www.cplusplus.com/reference/i.../istream/read/

    You need to open the file for binary See http://www.cplusplus.com/reference/f.../fstream/open/
    All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  3. #3

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Get some memory and then save that memory stream to disk

    Thanks for the links!

    Clarification - I'm not using managed c++, I'm calling my c++ functions from managed VB.Net world. VB.Net was used for proof of concept - now I want to be all c++.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

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