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.

113 lines
3.5 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 "precomp.hxx"
  13. #define ODBC_MODULE_NAME "odbc32.dll"
  14. #define LOAD_ENTRY( hMod, Name ) \
  15. ( p##Name = ( pfn##Name )GetProcAddress( ( hMod ), #Name ) )
  16. //
  17. // ODBC DLL Entry Points, fill by calling LoadODBC
  18. //
  19. pfnSQLAllocConnect pSQLAllocConnect ;
  20. pfnSQLAllocEnv pSQLAllocEnv ;
  21. pfnSQLAllocStmt pSQLAllocStmt ;
  22. pfnSQLBindCol pSQLBindCol ;
  23. pfnSQLCancel pSQLCancel ;
  24. pfnSQLColAttributes pSQLColAttributes ;
  25. pfnSQLConnect pSQLConnect ;
  26. pfnSQLDescribeCol pSQLDescribeCol ;
  27. pfnSQLDisconnect pSQLDisconnect ;
  28. pfnSQLError pSQLError ;
  29. pfnSQLExecDirect pSQLExecDirect ;
  30. pfnSQLExecute pSQLExecute ;
  31. pfnSQLFetch pSQLFetch ;
  32. pfnSQLFreeConnect pSQLFreeConnect ;
  33. pfnSQLFreeEnv pSQLFreeEnv ;
  34. pfnSQLFreeStmt pSQLFreeStmt ;
  35. pfnSQLGetCursorName pSQLGetCursorName ;
  36. pfnSQLNumResultCols pSQLNumResultCols ;
  37. pfnSQLPrepare pSQLPrepare ;
  38. pfnSQLRowCount pSQLRowCount ;
  39. pfnSQLSetCursorName pSQLSetCursorName ;
  40. pfnSQLTransact pSQLTransact ;
  41. pfnSQLSetConnectOption pSQLSetConnectOption;
  42. pfnSQLDrivers pSQLDrivers ;
  43. pfnSQLDataSources pSQLDataSources ;
  44. pfnSQLBindParameter pSQLBindParameter ;
  45. pfnSQLGetInfo pSQLGetInfo ;
  46. pfnSQLMoreResults pSQLMoreResults ;
  47. static BOOL s_fODBCLoaded = FALSE;
  48. BOOL
  49. DynLoadODBC(
  50. VOID
  51. )
  52. {
  53. HMODULE hMod;
  54. if( s_fODBCLoaded )
  55. {
  56. return TRUE;
  57. }
  58. if( ( hMod = ( HMODULE ) LoadLibraryA( ODBC_MODULE_NAME ) ) )
  59. {
  60. if( LOAD_ENTRY( hMod, SQLAllocConnect ) &&
  61. LOAD_ENTRY( hMod, SQLAllocEnv ) &&
  62. LOAD_ENTRY( hMod, SQLAllocStmt ) &&
  63. LOAD_ENTRY( hMod, SQLBindCol ) &&
  64. LOAD_ENTRY( hMod, SQLCancel ) &&
  65. LOAD_ENTRY( hMod, SQLColAttributes ) &&
  66. LOAD_ENTRY( hMod, SQLConnect ) &&
  67. LOAD_ENTRY( hMod, SQLDescribeCol ) &&
  68. LOAD_ENTRY( hMod, SQLDisconnect ) &&
  69. LOAD_ENTRY( hMod, SQLError ) &&
  70. LOAD_ENTRY( hMod, SQLExecDirect ) &&
  71. LOAD_ENTRY( hMod, SQLExecute ) &&
  72. LOAD_ENTRY( hMod, SQLFetch ) &&
  73. LOAD_ENTRY( hMod, SQLFreeConnect ) &&
  74. LOAD_ENTRY( hMod, SQLFreeEnv ) &&
  75. LOAD_ENTRY( hMod, SQLFreeStmt ) &&
  76. LOAD_ENTRY( hMod, SQLNumResultCols ) &&
  77. LOAD_ENTRY( hMod, SQLPrepare ) &&
  78. LOAD_ENTRY( hMod, SQLRowCount ) &&
  79. LOAD_ENTRY( hMod, SQLTransact ) &&
  80. LOAD_ENTRY( hMod, SQLSetConnectOption ) &&
  81. LOAD_ENTRY( hMod, SQLDrivers ) &&
  82. LOAD_ENTRY( hMod, SQLDataSources ) &&
  83. LOAD_ENTRY( hMod, SQLGetInfo ) &&
  84. LOAD_ENTRY( hMod, SQLBindParameter ) &&
  85. LOAD_ENTRY( hMod, SQLMoreResults ) )
  86. {
  87. s_fODBCLoaded = TRUE;
  88. }
  89. }
  90. return ( s_fODBCLoaded );
  91. } // DynLoadODBC()