Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123 lines
3.6 KiB

  1. /*++
  2. Copyright (c) 1995-1996 Microsoft Corporation
  3. Module Name:
  4. dynodbc.c
  5. Abstract:
  6. This module provides functions for dynamically loading the ODBC
  7. functions.
  8. Author:
  9. Murali R. Krishnan (MuraliK) 3-Nov-1995
  10. Revision History:
  11. --*/
  12. #include <windows.h>
  13. #include <stdio.h>
  14. # include "dynodbc.h"
  15. //
  16. // ODBC DLL Entry Points, fill by calling LoadODBC
  17. //
  18. pfnSQLAllocConnect pSQLAllocConnect ;
  19. pfnSQLAllocEnv pSQLAllocEnv ;
  20. pfnSQLAllocStmt pSQLAllocStmt ;
  21. pfnSQLBindCol pSQLBindCol ;
  22. pfnSQLCancel pSQLCancel ;
  23. pfnSQLColAttributes pSQLColAttributes ;
  24. pfnSQLConnect pSQLConnect ;
  25. pfnSQLDescribeCol pSQLDescribeCol ;
  26. pfnSQLDisconnect pSQLDisconnect ;
  27. pfnSQLError pSQLError ;
  28. pfnSQLExecDirect pSQLExecDirect ;
  29. pfnSQLExecute pSQLExecute ;
  30. pfnSQLFetch pSQLFetch ;
  31. pfnSQLFreeConnect pSQLFreeConnect ;
  32. pfnSQLFreeEnv pSQLFreeEnv ;
  33. pfnSQLFreeStmt pSQLFreeStmt ;
  34. pfnSQLGetCursorName pSQLGetCursorName ;
  35. pfnSQLNumResultCols pSQLNumResultCols ;
  36. pfnSQLPrepare pSQLPrepare ;
  37. pfnSQLRowCount pSQLRowCount ;
  38. pfnSQLSetCursorName pSQLSetCursorName ;
  39. pfnSQLTransact pSQLTransact ;
  40. pfnSQLSetConnectOption pSQLSetConnectOption;
  41. pfnSQLDrivers pSQLDrivers ;
  42. pfnSQLDataSources pSQLDataSources ;
  43. pfnSQLBindParameter pSQLBindParameter ;
  44. pfnSQLGetInfo pSQLGetInfo ;
  45. pfnSQLMoreResults pSQLMoreResults ;
  46. # define ODBC_MODULE_NAME "odbc32.dll"
  47. #define LOAD_ENTRY( hMod, Name ) \
  48. (p##Name = (pfn##Name) GetProcAddress( (hMod), #Name ))
  49. static BOOL s_fODBCLoaded = FALSE;
  50. BOOL
  51. DynLoadODBC(
  52. VOID
  53. )
  54. {
  55. HMODULE hMod;
  56. if ( s_fODBCLoaded )
  57. return TRUE;
  58. if ( (hMod = (HMODULE) LoadLibrary( ODBC_MODULE_NAME ))) {
  59. if (LOAD_ENTRY( hMod, SQLAllocConnect ) &&
  60. LOAD_ENTRY( hMod, SQLAllocEnv ) &&
  61. LOAD_ENTRY( hMod, SQLAllocStmt ) &&
  62. LOAD_ENTRY( hMod, SQLBindCol ) &&
  63. LOAD_ENTRY( hMod, SQLCancel ) &&
  64. LOAD_ENTRY( hMod, SQLColAttributes ) &&
  65. LOAD_ENTRY( hMod, SQLConnect ) &&
  66. LOAD_ENTRY( hMod, SQLDescribeCol ) &&
  67. LOAD_ENTRY( hMod, SQLDisconnect ) &&
  68. LOAD_ENTRY( hMod, SQLError ) &&
  69. LOAD_ENTRY( hMod, SQLExecDirect ) &&
  70. LOAD_ENTRY( hMod, SQLExecute ) &&
  71. LOAD_ENTRY( hMod, SQLFetch ) &&
  72. LOAD_ENTRY( hMod, SQLFreeConnect ) &&
  73. LOAD_ENTRY( hMod, SQLFreeEnv ) &&
  74. LOAD_ENTRY( hMod, SQLFreeStmt ) &&
  75. LOAD_ENTRY( hMod, SQLNumResultCols ) &&
  76. LOAD_ENTRY( hMod, SQLPrepare ) &&
  77. LOAD_ENTRY( hMod, SQLRowCount ) &&
  78. LOAD_ENTRY( hMod, SQLTransact ) &&
  79. LOAD_ENTRY( hMod, SQLSetConnectOption ) &&
  80. LOAD_ENTRY( hMod, SQLDrivers ) &&
  81. LOAD_ENTRY( hMod, SQLDataSources ) &&
  82. LOAD_ENTRY( hMod, SQLGetInfo ) &&
  83. LOAD_ENTRY( hMod, SQLBindParameter ) &&
  84. LOAD_ENTRY( hMod, SQLMoreResults )
  85. ) {
  86. s_fODBCLoaded = TRUE;
  87. }
  88. }
  89. return (s_fODBCLoaded);
  90. } // DynLoadODBC()
  91. /****************************** End Of File ******************************/
  92.