Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you register a .dll using VBA? 1

Status
Not open for further replies.

DallasAggie

Programmer
Oct 24, 2002
98
US
Hi all.

I have an Access application that is calling a .dll file in order to email. I have to use this because our conference rooms do not have Outlook, so I am using this .dll.

The problem is that once I deploy this out, the .dll is copied to the right location, but how do I register (regsvr32) it on remote machines? Does any one have any code on how to accomplish this?

Thank you.
Robert Andrade
aka: DallasAggie
 
foolio,

Each time Shell(regsvr32 aspemail.dll) gets called, a message box pops up confirming that the .dll has been registered. Do you know if there is a way to supress that message?

Also, do you know how I can de-register the .dll on close? Right now I have "Overwrite Existing", but I keep getting a Permission Denied error after using the Shell command.

Thanks for your help.
Robert

Here is what I'm doing on open:
Function ReportFileStatus(filespec)

Dim objFSO
Dim strcopy As String

Const OverwriteExisting = True

strcopy = "\\dev-eds-01\AccessDLLs\aspemail.dll"

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile strcopy, filespec, OverwriteExisting


Shell ("regsvr32 AspEmail.dll")

End Function
 
I told you it was an awful solution. I think I have a better idea now, but let me first answer your questions:

1. suppress message box? I don't know
2. de-register .DLL? I don't know


Now the newer system. This will hopefully lead to a one-time use setting, which is better than de-registering the DLL after every use.

Steps:

1. Create "DLL" table with a "ComputerName" field (text).
2. Add the following to a function which is called only on startup:
Code:
Dim strComputerName as String
'On NT-based computers, the COMPUTERNAME environment 
'variable is set to your computer.  On non-NT, this will
'probably not work.

strComputerName = Environ("COMPUTERNAME")

If Nz(DLookup("[ComputerName]","[DLL]","[ComputerName] = '" & strComputerName & "'")) = "" Then
    Shell("regsvr AspEmail.dll")
    DoCmd.RunSQL "INSERT INTO DLL VALUES ('" & _
                 strComputerName & "')"
End If



If you're not running all-NT-based clients, you're going to have to figure another way to uniquely identify the computer (I'm sure that there's an actual API call that will retrieve the computer name, but I don't know it myself). Anyway. That should work. Maybe.

--
Find common answers using Google Groups:

Corrupt MDBs FAQ
 
Better answer to suit your needs:



The reply has everything you need: just make sure your file exists in the Windows\System directory. Then you can make API calls and they should work.

I believe this would work.


(really, I'm inexperienced in messing with custom DLL's)

--
Find common answers using Google Groups:

Corrupt MDBs FAQ
 
foolio,

thanks for your help. I did what you recommended and it worked great! :) The only thing I changed was where the .dll is copied to. Since the machines don't have 'admin' rights to them, I had to copy it to 'My Documents'. I know, this is a bad way to do it, but it's the only way I could work around admin privlidges. I' just running a function that finds the user name (from NT logon) and using it in the following:

strLocation = "c:\documents and settings\" & strUserName & "\My Documents\"

Well, again, thanks for your help..I can finally move on to the next phase :)

Cheers!
Robert
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top