我的应用程序现在仅支持 64 位,我需要获取机器上或新创建的所有 ODBC 或 Access DataSouces。
下面的代码是为获取 32 位列表而实现的,但现在它在调用SQLAllocEnv
方法时崩溃。
[DllImport("odbc32.dll")]
private static extern int SQLDataSources(
int EnvHandle, int Direction, StringBuilder ServerName,
int ServerNameBufferLenIn, ref int ServerNameBufferLenOut,
StringBuilder Driver, int DriverBufferLenIn, ref int DriverBufferLenOut);
[DllImport("odbc32.dll")]
private static extern int SQLAllocEnv(ref int EnvHandle);
[DllImport("odbc32.dll")]
private static extern int SQLFreeEnv(int EnvHandle);
那么,有谁知道如何解决这个问题?