Microsoft KB Archive/44730

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 17:56, 18 July 2020 by 3155ffGd (talk | contribs) (importing KB archive)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Base


INF: Using Windows Global Heap Buffers

Article ID: 44730

Article Last Modified on 3/14/2005



APPLIES TO

  • Microsoft SQL Server Programmer's Toolkit 4.2
  • Microsoft SQL Server 2000 Standard Edition



This article was previously published under Q44730

SUMMARY

Although the Windows 3.x 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: kbinfo kbprogramming KB44730