用ODBC访问paradox数据库
想用程序实现自动注册ODBC数据源
请问该如何做?
想用程序实现自动注册ODBC数据源
请问该如何做?
解决方案 »
- 为什么用Terminatethread终止线程后,输入不起作用了呢?谢谢大家了
- ISAPI过滤器 如何替换utf-8 网页中的中文字符
- 紧急求助,近来看看
- 关于计时器的问题
- 整数的显示问题
- 如何在一个位图上写字,并且把位图保存下来?
- 有没有不需要用户身份验证的SMTP的服务器,请告诉我IP地址?
- 在那里有关于DLL开发的好书请推荐,在用向导生成DLL工程时,那三个选项是什么意思,注释中AFX_MANAGE_STATE宏又是什么意思,请高手指教!
- 问VC++6和VC.Net区别?
- 谁用过RealSystem SDK
- 发现了一种很方便的注释代码的方法(VC)~
- SetWindowLong(hwnd, GWL_USERDATA, lParam)有什么作用
void RegisterDBSource(CString strDSName, CString strDBPath)
{
HKEY hKey;
DWORD nLabel; CString strBaseKey = _T("SOFTWARE\\ODBC\\ODBC.INI");
CString strMid = strBaseKey + _T("\\ODBC Data Sources") ; if(strDataSourceName.IsEmpty()) return;
if(strDBPath.IsEmpty()) return; CString strDataSource = strBaseKey + _T("\\") + strDSName; CString strMdb = _T("Microsoft Access Driver (*.mdb)");
CString strDBDriver = _T("C:\\WINNT\\System32\\odbcjt32.dll");
CString strFIL = _T("Ms Access;");
CString strUID = _T(""); RegCreateKeyEx(HKEY_CURRENT_USER,
strMid,
0,
NULL,
REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS,
NULL,
&hKey,
&nLabel );//获取数据源键值句柄 RegSetValueEx(hKey,
strDSName,
0,
REG_SZ,
(const unsigned char *)((LPCTSTR)strMdb),
strlen((LPCTSTR)strMdb)+1);///设置数据源类型 RegCreateKeyEx(HKEY_CURRENT_USER,
strDataSource,
0,
NULL,
REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS,
NULL,
&hKey,
&nLabel );//创建数据源子键 RegSetValueEx(hKey,
_T("DBQ"),
0,
REG_SZ,
(const unsigned char *)((LPCTSTR)strDBPath),
strlen((LPCTSTR)strDBPath)+1);//数据库表的全路径 RegSetValueEx(hKey,
_T("Driver"),
0,
REG_SZ,
(const unsigned char *)((LPCTSTR)strDBDriver),
strlen((LPCTSTR)strDBDriver)+1);//ODBC驱动的全路径 RegSetValueEx(hKey,
_T("FIL"),
0,
REG_SZ,
(const unsigned char *)((LPCTSTR)strFIL),
strlen((LPCTSTR)strFIL)+1);//表的类型 RegSetValueEx(hKey,
_T("UID"),
0,
REG_SZ,
(const unsigned char *)((LPCTSTR)strUID),
strlen((LPCTSTR)strUID)+1);//必须项
DWORD DriverId = (DWORD)25;
RegSetValueEx(hKey,
_T("DriverId"),
0,
REG_DWORD,
(const BYTE *)(&DriverId),
sizeof(DWORD));//必须项
DWORD SafeTrans = (DWORD)0;
RegSetValueEx(hKey,
_T("SafeTransactions"),
0,
REG_DWORD,
(const BYTE *)(&SafeTrans),
sizeof(DWORD));//可选项
}