INF: Using Windows Global Heap Buffers

Last reviewed: April 25, 1997
Article ID: Q44730

The information in this article applies to:
  • Microsoft SQL Server Programmer's Toolkit, version 4.2

SUMMARY

Although the Windows version of DB-Library (DB-Lib) is compiled with the medium memory model (near data pointers), all of the DB-Lib functions use far pointers for buffer parameters. This means that you can pass a far pointer to a buffer allocated with GlobalAlloc() to dbbind.

Be sure to use both the DB-Lib and the Windows LOCK and UNLOCK functions around the code that references the global heap buffers.

MORE INFORMATION

The following code fragment illustrates how this might be done:

HANDLE hMem1; HANDLE hMem2;

LPSTR lpMem1; LPSTR lpMem2;

DBLOCKLIB(); while( dbresults(dbproc)!=NO_MORE_RESULTS ) {

 lpMem1 = GlobalLock(hMem1);
 lpMem2 = GlobalLock(hMem2);

 dbbind( dbproc, 1, ???, ??L, (LPSTR)lpMem1 );
 dbbind( dbproc, 2, ???, ??L, (LPSTR)lpMem2 );

 while( dbnextrow(dbproc)!=NO_MORE_ROWS )
 {
   TextOut(hDC,?,????, lpMem1, ??? );
   TextOut(hDC,?,????, lpMem2, ??? );

 }
 GlobalUnlock(hMem1);
 GlobalUnlock(hMem2);

} DBUNLOCKLIB();


Additional query words: dblib
Keywords : kbprg SSrvDB_Lib
Version : 4.2
Platform : OS/2


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 25, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.