SysAllocString

This is a discussion on SysAllocString within the C++ Programming forums, part of the General Programming Boards category; Hello everyone, For the SysAllocString API, I am wondering, 1. any special benefits if we use SysAllocString compared with using ...

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    1,579

    SysAllocString

    Hello everyone,


    For the SysAllocString API, I am wondering,

    1. any special benefits if we use SysAllocString compared with using a simple wide character string, like L"Hello"?

    2. If we use SysAllocString to allocate constant string, then does SysAllocString allocate the constant string on heap, stack or on the constant string pool?


    thanks in advance,
    George

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    SysAllocString, according to what I understand from the page below, is a OLE function.
    http://msdn2.microsoft.com/en-us/library/ms221458.aspx

    It would certainly allocate from A heap - whether it's "the" heap or "some other" heap.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    As for the difference to a normal wide character string, the OLE string has the length stored prior to its start. It thus may contain embedded NULs, and is faster to work with for many tasks.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  4. #4
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,295
    If you want to use SysAllocString, you would be better off using CComBSTR in the C++ world.
    You shouldn't ever need to use SysAllocString directly, in C++.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21