'shell并等待执行完毕
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Public Function ShellForWait(sAppName As String, Optional ByVal lShowWindow As VbAppWinStyle = vbMinimizedFocus, Optional ByVal lWaitTime As Long = 0) As Boolean
Dim lID As Long, lHnd As Long, lRet As Long
On Error Resume Next
lID = Shell(sAppName, lShowWindow)
If lID > 0 Then
lHnd = OpenProcess(SYNCHRONIZE, 0, lID)
If lHnd <> 0 Then
Do
lRet = WaitForSingleObject(lHnd, lWaitTime)
DoEvents
Loop While lRet = WAIT_TIMEOUT
CloseHandle lHnd
ShellForWait = True
Else
ShellForWait = False
End If
Else
ShellForWait = False
End If
End Function
Private Sub Command1_Click()
ShellForWait "cmd.exe ", , &HFFFF
MsgBox ""
End Sub
OO4O拥有优异的功能性,访问Oracle数据库,其他任何数据库访问方式很难达到它的功能性。但OO4O仍有不足:
·在某些实例中,它的速度不是最快的。部分原因是因为它是一种进程中的服务程序。
·OO4O不支持异步操作或事件。
·OO4O不支持GetRows方式。OO4O主要被设计用于可更新动态集。
在OO4O中,连接是比较容易实现的,你只需简单的键入你的用户名、口令和数据库别名即可。对象模型与DAO的相似,比较明显的不同是所有的对象前面都冠有“Ora”字样。下面这些代码创建了Ora会话对象和相应的Ora数据库对象,然后又创建了Ora动态集来保存所检索的结果集。最后,关闭了Ora动态集和Ora数据库对象。
程序清单
private sub FetchOO4O()
Dim OraSession As Object
Dim OraDatabase As Object
Set OraSession(i) = CreateObject("OracleInProcServer.XOraSession")
Set OraDatabase(i) = OraSession(i).DbOpenDatabase("exampledb", "scott/tiger", 0&)
'Connect to the daabase
Set OraSession = CreatObject("OracleInProcSever.XoraSession")
Set OaDataBase = OraSession.OpenDatebase("beq-local",_
"video_user/ummagumma",ORADB_DEFAULT)
'Run then query
strSQL="SELECT * FROM video_store.movies ORDER BY movie_id"
Set rsMovies = OraDateBase.CreatDynaset(strSQL,ORADYN_READONLY)
'Display the fields
while not rsMovies.EOF
FOR ifields = 0 to rsMovies.fields.Count-1
Debug. rsMovies.(iFields)
Next 'iField
rsMovies.MoveNext
Wend