cbWinBuffAlloc() in C++

I'm having a little trouble using this function (from cbw32.lib). The line I'm using is:
where NUMPOINTS, NUMCHANS, and SIZE are #defined as 2, 10000, and 31 respectively.

Every time I call this function it returns 0, even if I change the input parameter to 31 (so insufficient available memory shouldn't be an issue). All documentation I've seen for this function just says that it returns 0 if it doesn't work, but doesn't explain what "it doesn't work" means or how I might fix it.

To confuse things even more, this works fine on another computer with a similar setup.

Any ideas what might cause this?


  • Its an memory allocation function, I think. It is trying to allocate a memory block and the statement casting it to a WORD pointer. The function is returning 0, may be, due to unable to allocate the size given by NUMPOINTS * NUMCHANS * SIZE = 620000.
  • Thanks for the reply. It is a memory allocation function. The description I keep seeing for it:
    [code][b]cbWinBufAlloc() function[/b]
    Allocates a Windows global memory buffer which can be used with the scan functions and returns a memory handle for it.

    [b]Function Prototype:[/b]
    int cbWinBufAlloc(long NumPoints)

    NumPoints: Size of buffer to allocate. Specifies how many data points (16-bit integers, NOT bytes) can be stored in the buffer.

    0 if the buffer could not be allocated, or a non-zero integer handle to the buffer.

    Unlike most other functions in the library, this function does not return an error code. It returns a Windows global memory handle which can then be passed to the scan functions in the library. If an error occurs the handle will come back as 0 to indicate that the buffer was not allocated. [/code]

    I've tried changing the size to only 31, instead of 620000, with the same result; so I suspect that isn't the issue.

    Other ideas?
  • Will you give me more about the function, like, which library it belongs, the header file, etc.
  • Didn't see a further reply on this, so for those that come across this again here's how we solved it>
    The cbWinBufAlloc function call takes a long for vb6 or int for C and returns the same.
    If the card is not in place or has not been installed via InstaCal the call will fail for lack of hardware.
    Just run InstaCal and if the card is PNPray it will ask if you want to install the found card.
    Now the cbWinBufAlloc will function properly.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!