Click to See Complete Forum and Search --> : Calling a Custom VB DLL


February 9th, 2000, 10:20 AM
I am not sure if this can be done so any help would be greatly appreciated....

I am trying to create a dll in VB and then call that DLL in Installshield

I successfully created an ActiveX DLL in VB using the following code

My Project name is ScFileEnum
My Class Module name is EnumFile

When I try to make the call to the dll in Installshield I am getting an error back "Setup failed to run the installation" This happens right when I get to making the call to my dll


Can this be done?

Any help would be appreciated

Thanks
tcompe


Option Explicit
Private Declare Function NetFileEnum Lib "Netapi32" (ByVal ServerName As Long, ByVal _
BasePath As Long, ByVal UserName As Long, ByVal Level As Long, BufPtr As Long, ByVal _
PrefMaxLen As Long, EntriesRead As Long, TotalEntries As Long, resumehandle As Long) As Long
Private Declare Function NetApiBufferFree Lib "netapi32.dll" (ByVal lpBuffer As Long) As Long
Private Declare Sub CopyMem Lib "kernel32" Alias "RtlMoveMemory" (pTo As Any, uFrom As Any, ByVal lSize As Long)
Private Declare Function lstrlenW Lib "kernel32" (ByVal lpString As Long) As Long
Private Declare Function NetFileClose Lib "Netapi32" (ByVal ServerName As Long, ByVal fileID As Long) As Long


Private Const PERM_FILE_READ = 1
Private Const PERM_FILE_WRITE = 2
Private Const PERM_FILE_CREATE = 4
Private Const NERR_Success As Long = 0&

Public Type FileInfo3
ID As Long
Permissions As Long
NumLocks As Long
Pathname As String
UserName As String
End Type
Private lpServer As Long
Private ServerN As String
Private fileID As Long
Private ISPath As String
Private g_Files() As FileInfo3

Public Function EnumOpenFiles(Optional ByVal Server As String = "", Optional ByVal _
UserName As String = "", Optional ByVal BasePath As String = "") As Long

Dim lpBasePath As Long
Dim lpUserName As Long
Dim EntriesRead As Long
Dim TotalEntries As Long
Dim hResume As Long
Dim lpBuffer As Long
Dim Offset As Long
Dim nRet As Long
Dim i As Long


Server = ""
ServerN = Server
If Len(Server) Then
lpServer = StrPtr(Server)
End If
If Len(BasePath) Then
lpBasePath = StrPtr(BasePath)
End If
If Len(UserName) Then
lpUserName = StrPtr(UserName)
End If

nRet = NetFileEnum(lpServer, lpBasePath, lpUserName, 3&, lpBuffer, 12144&, EntriesRead, TotalEntries, hResume)
If nRet = NERR_Success Then
If EntriesRead Then
ReDim g_Files(0 To EntriesRead - 1) As FileInfo3
For i = 0 To EntriesRead - 1
With g_Files(i)
.ID = PointerToDWord(lpBuffer + Offset)
fileID = .ID
.Permissions = PointerToDWord(lpBuffer + Offset + 4)
.NumLocks = PointerToDWord(lpBuffer + Offset + 8)
.Pathname = PointerToStringW(PointerToDWord(lpBuffer + Offset + 12))
.UserName = PointerToStringW(PointerToDWord(lpBuffer + Offset + 16))
Offset = Offset + Len(g_Files(i))
End With
Next i
Else
MsgBox ("No files found.")
End If
End If
EnumOpenFiles = TotalEntries
Call NetApiBufferFree(lpBuffer)
End Function
Public Function PointerToDWord(ByVal lpDWord As Long) As Long
Dim RetVal As Long
Call CopyMem(RetVal, ByVal lpDWord, 4)
PointerToDWord = RetVal
End Function
Public Function PointerToStringW(ByVal lpString As Long) As String
Dim sText As String
Dim lLength As Long
Dim CloseFile As Long
Dim fpath As String


If lpString Then
lLength = lstrlenW(lpString)
If lLength Then
sText = Space$(lLength)
CopyMem ByVal StrPtr(sText), ByVal lpString, lLength * 2
End If
End If
PointerToStringW = sText
fpath = "C:\Temp\Iscode\Files\StatusTemplate.doc"
If sText = fpath Then
CloseFile = NetFileClose(lpServer, fileID)
Kill "C:\TEMP\Iscode\Files\StatusTemplate.doc"
End If


End Function

Kyle Burns
February 16th, 2000, 10:39 AM
It's possible that this is failing because the VB runtimes are not installed on the machine. You can't run the installer until it's installed, but you need to run the installer to install it!