关于dll创建的问题请教(40分)

  • 主题发起人 主题发起人 闲清
  • 开始时间 开始时间

闲清

Unregistered / Unconfirmed
GUEST, unregistred user!
这个dll是在VB里创建的:
dll的工程名为files32
类名为filesystem
定义的函数:
Public Function EnumFiles(ByRef dir As String) As String
Dim FO As FileSystemObject
Dim FD As Folder
Dim Result As String

On Error Resume Next
FO = New FileSystemObject
Set FD = FO.GetFolder(dir)
For Each thing In FD.Files
Result = Result &amp
thing.Name &amp
" "
Next

EnumFiles = Result
End Function

在一个新工程里引用该dll之后我是这样使用的:
dim fs as new files32.filesystem
dim str as string
str=fs.enumfiles("C:/")
可是str为空,函数没问题,我试过了,为什么会没有返回值?
我在Delphi里定义了该函数之后,运行时提示找不到enumfiles入口,是怎么回事?
 
转贴:
修改为:
Public Function EnumFiles(ByRef dir As String) As String
Dim objFSO As FileSystemObject
Dim objFolder As Folder
Dim objFile As File
Dim Result As String
'On Error Resume Next
Set objFSO = New FileSystemObject '要加上Set
Set objFolder = objFSO.GetFolder(dir)
For Each objFile In objFolder.Files
Result = Result &amp
objFile.Name &amp
" "
Next
Set objFSO = Nothing
EnumFiles = Result
End Function
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
817
import
I
后退
顶部