Declare Function CopyFile Lib "kernel32" Alias "CopyFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long) As Long
Public Function a As string
'以下忽略copyfile的用法,仅仅举个例子而已
if copyfile(参数)=0 then
a=0
else
a=1
end if
End Function
编译生成dll文件。注册regsvr32 路径\dll。
web页面中
set dcss=server.CreateObject("工程名.类名")
flag=dcss.a
if flag=0 then
response.write "底层驱动调用成功"
else
response.write "底层驱动调用失败"
response.end
end if
这个dll应该是标准的dll,就先在类中声明函数,然后,
重新用vb写要暴露给web调用的接口。一般用public function或者public sub
如下
class中
Public Function datasource() As Variant
datasource = "driver={sql server};server=yang;uid=sa;pwd=; database=dcss"
End Function
web页面中
set dcss=server.CreateObject("工程名.类名")
oconn=dcss.datasource()
application("strconn")=oconn
这说明dll文件为标准的dll,需要在类中声明该函数a,格式类似下面:
Declare Function CopyFile Lib "kernel32" Alias "CopyFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long) As Long
Declare Function a Lib "库文件名" Alias "别名" (参数1,参数2) As 返回值类型(long居多)