这是我调用ODBC的代码 Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As LongPrivate Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As LongPrivate Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As LongPrivate Const SYNCHRONIZE = &H100000 Private Const INFINITE = &HFFFFPrivate Function RunODBCDataSource() As Boolean Dim lngProcID As Long Dim lngHwnd As Long Dim lngReturn As Long lngProcID = Shell("rundll32.exe shell32.dll,Control_RunDLL odbccp32.cpl", vbNormalFocus)
AppActivate lngProcID
' SendKeys "%d" 'alt+d, add ODBC ' SendKeys "i" 'i, move to informix, ' SendKeys "~" 'return key 'was going to focus on client and default its value to 819, cannot do it as error when empty database name 'in connection tab after given dummy data source name
If lngProcID <> 0 Then lngHwnd = OpenProcess(SYNCHRONIZE, 0, lngProcID) DoEvents
If lngHwnd <> 0 Then lngReturn = WaitForSingleObject(lngHwnd, INFINITE) CloseHandle lngHwnd End If RunODBCDataSource = True Else MsgBox "Unable to run " & ODBCADM & ".", vbCritical + vbOKOnly, "Error" End If End Function换下1楼的 rundll32.exe shell32.dll,Control_RunDLL netcpl.cpl
以后的 好象只能用
rundll32.exe shell32.dll,Control_RunDLL netcpl.cpl,然后手动
希望具体的代码,本人是初学,再一次谢谢
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As LongPrivate Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As LongPrivate Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As LongPrivate Const SYNCHRONIZE = &H100000
Private Const INFINITE = &HFFFFPrivate Function RunODBCDataSource() As Boolean
Dim lngProcID As Long
Dim lngHwnd As Long
Dim lngReturn As Long lngProcID = Shell("rundll32.exe shell32.dll,Control_RunDLL odbccp32.cpl", vbNormalFocus)
AppActivate lngProcID
' SendKeys "%d" 'alt+d, add ODBC
' SendKeys "i" 'i, move to informix,
' SendKeys "~" 'return key
'was going to focus on client and default its value to 819, cannot do it as error when empty database name
'in connection tab after given dummy data source name
If lngProcID <> 0 Then
lngHwnd = OpenProcess(SYNCHRONIZE, 0, lngProcID)
DoEvents
If lngHwnd <> 0 Then
lngReturn = WaitForSingleObject(lngHwnd, INFINITE)
CloseHandle lngHwnd
End If
RunODBCDataSource = True
Else
MsgBox "Unable to run " & ODBCADM & ".", vbCritical + vbOKOnly, "Error"
End If
End Function换下1楼的
rundll32.exe shell32.dll,Control_RunDLL netcpl.cpl
看一楼。
xp以后的冒是不能,不然发到windows的论坛试试。
权限是首要的。
讲清楚你的os和域,我想当然你有administration 权限。
在注册表"HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Tcpip\Parameters\Interfaces"能见到本机的IP和DNS,我想vb专家肯定能解决我说的问题.但我就没办法.