Function getdate() As String Dim cn As New ADODB.Connection 
Dim cmd As New ADODB.Command 
Dim rst As New ADODB.Recordset 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 
getdate = rst(0) 
rst.Close 
cn.Close 
Exit Function ErrPro: 
getdate = Format(Now(), "YYYY-mm-DD HH:mm:ss") End Function 要封装成一个标准的dll,供PowerStar 5 调用,它无法引用ActiveX Dll.我想在别的平台(PowerStar 5)中调用这个dll ,实现取服务器时间的功能。 但是这个在调用时候只返回第一个字符,也就是“2”,不知道怎么搞。 老马原来有给我改过,但是我试了好像不能用,而且我也不想在调用的时候还往里面传参数,最好就是我用的时候直接一句话就出来,不再往里面传参数了。
原贴:http://topic.csdn.net/u/20090820/15/a863eedc-08cf-4faf-9d52-0bbc4ef43a4d.html

解决方案 »

  1.   

    建议你用VC生成这个标准的DLL,因为VB6不能生成标准的DLL,只能生成ACtiveX DLL.
      

  2.   

    http://www.applevb.com/art/vb_dll.html
    照上面的方式做,注意完成后将 link.exe 恢复过来。
      

  3.   

    是的,先不谈是否标准DLL,但VB是可做有输出函数的DLL的
      

  4.   

    我用的就是一个标准dll 的模板做的dll,不行。
      

  5.   

    PowerStar 5 不熟,不过 VB 的字符串都是 BSTR,不知道该语言是否支持。
    不支持就要自己处理一下。比如 VB 字符串 "2009-08-28 09:18:50" 实际按照 Unicode 编码占用 38 字节:
    '2' + \0 + '0' + \0 + '0' + \0 + '9' + \0 + 
    '-' + \0 + '0' + \0 + '8' + \0 + 
    '-' + \0 + '2' + \0 + '8' + \0 + 
    ' ' + \0 + '0' + \0 + '9' + \0 + 
    ':' + \0 + '1' + \0 + '8' + \0 + 
    ':' + \0 + '5' + \0 + '0'