Microsoft KB Archive/72201

{|
 * width="100%"|

PRB: Problems When W3DBLIB.DLL is Loaded at Run-Time

 * }

Q72201

-

The information in this article applies to:


 * Microsoft SQL Server Programmer's Toolkit, version 4.2

-

SYMPTOMS
Attempting to load W3DBLIB.DLL at run-time in a program [by calling LOADLIBRARY], and then attempting to get the address of a function by calling GetProcAddress(hLibrary, &quot;&quot;), will return a NULL pointer.

CAUSE
Windows assumes that all procedures are defined with the PASCAL calling sequence; therefore, the application always looks for the function name to be in uppercase letters when GetProcAddress is called. Functions declared with the C calling convention are case sensitive. DB-Library (DB-Lib) functions use the C calling convention and are in all lowercase letters; therefore, Windows cannot load these functions when they are referenced by name.

WORKAROUND
Pass the ordinal number of the db-lib functions (assigned in the .DEF file) to GetProcAddress. For example:

  GetProcAddress(hLibrary,MAKESOURCE(43)); // dbinit

The ordinal numbers of the DB-Lib functions can be obtained by using the EXEHDR program against W3DBLIB.DLL.

STATUS
Microsoft has confirmed this to be a problem in SQL Server version 4.2. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

Additional query words: Programming tools - windows dblib

Keywords : kbprogramming

Issue type :

Technology : kbSQLServSearch kbAudDeveloper kbSQLServPTK420