|
- Option Explicit
- Private Declare Function SetHandleCount Lib "Kernel32" _
- (ByVal a As String) As Long
- Private Declare Function SetHandleCount1 Lib "Kernel32" _
- Alias "SetHandleCount" (ByVal a As Long) As String
- Private Declare Function RtlMoveMemory Lib "Kernel32" _
- (ByVal a As Long, ByVal b As String, ByVal c As Long) As Long
- ''''''''''''''''''''''''''''''''''''''''''''''''
- '' DLL PROJECT ?2004 DanSoft Australia ''
- '' Your dlls MUST HAVE a DLLMain and Main ''
- '' proc, otherwise it won't compile properly! ''
- ''''''''''''''''''''''''''''''''''''''''''''''''
- Function DLLMain(ByVal a As Long, ByVal b As Long, ByVal c As Long) As Long
- DLLMain = 1
- End Function
- Sub Main()
- 'This is a dummy, so the IDE doesn't complain
- 'there is no Sub Main.
- End Sub
- Function gettime()
- Dim cn As New ADODB.Connection
- Dim cmd As New ADODB.Command
- Dim rst As New ADODB.Recordset
- Dim str As String
- On Error GoTo ErrPro
- cn.ConnectionString = "driver={SQL Server};" & _
- "server=cnaecfuyd000072;uid=sa;pwd=123623255;database=master"
- cn.ConnectionTimeout = 300
- cn.Open
- cmd.ActiveConnection = cn
- cmd.CommandText = "select convert(char(20),getdate(),120) as sys_date"
- 'cmd.ActiveConnection = cn
- Set rst = cmd.Execute
- str = CStr(rst(0))
- gettime = str
- Call RtlMoveMemory(200, gettime, Len(gettime) * 2 + 1)
- rst.Close
- cn.Close
- Exit Function
- ErrPro:
- gettime = Format(Now(), "YYYY-mm-DD HH:mm:ss")
- End Function
复制代码 请教大侠这代码有什么问题, 他是一个DLL 里面的函数,我在main 函数中调试,就出错,VB 直接关掉了。 |
|