Link to home
Create AccountLog in
Avatar of buzzcarter

asked on

Variable in a Declare Function

What is the correct way to use the Environ variable in a Declare Function?

The path is unknown for some OS.

Public Declare Function MyRegIslic Lib "<Environ("ProgramFiles")>\Common Files\InteractiveStudios\IsLicense30.dll" Alias "DllRegisterServer" () As Long

Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

I don't think you can or should do it that way.
either, the dll is "in the path" (see PATH environment variable), so that it does not matter in which folder it is, or directly in the app's exe folder itself, and then you leave the path out completely
Avatar of buzzcarter


What about this

Public Declare Function MyRegIslic Lib "IsLicense30.dll" Alias "DllRegisterServer" () As Long

Setpath =  Environ("ProgramFiles") & "\Common Files\InteractiveStudios\"
Call MyRegIslic
I have tried the DLL in the application dir with the same results.

It looks like the real problem maybe WIndows 7 needing admin rights?
What are you trying to do?

Generally you would code the Declare function as stated in the documentation, then build an Object using that Declare. Once that Object is built, you would then work with the properties/methods of that function.

All I need to do is register IsLicense30.dll.

I have also tried Shell "regsvr32 /s " & Chr$(34) & Application.CurrentProject.Path & "\IsLicense30.dll"
And the Function above.

These seem to work on my coding Windows 7 Computer.  But when I test the application deployment on another system the DLL fails to register.

You simply want to register the IsLicense30.dll?

I would presume that the installation of your program would take care of this, since you're referring to a licensing program (IsLicense30.dll is part of Quick License Browser). The documentation for the Express version states that you should use the Merge Modules to manage deployment, and should NOT register these sorts of things individually. It also states that you should install this into the Common Files location, with specific instructions on what/how to do that. When dealing with things of this nature, it is always best to do exactly as the documentation instructs:

I am not using Eindows Installer to distrubute my Access 2003/VB program.

Per Inactive Studios for Version 3.0
"If you are not using Windows Installer to distribute your application, you need to include the following files:

IsLicense30.dll: shared, self-registered, to be installed in <Program Files>\<Common Files>\InteractiveStudios

Since the paths to the <Common Files> can differ on my customers computers.  I have try with varying success.

Make sure to register IsLicense30.dll using: regsvr32.exe C:\Program Files\Common Files\InteractiveStudios\IsLicense30.dll"

Public Declare Function MyRegIslic Lib "IsLicense30.dll" Alias "DllRegisterServer" () As Long
' An then Call the Function
      ChDir (Environ("ProgramFiles") & "\Common Files\InteractiveStudios\")
      Call MyRegIslic

Open in new window

  Shell ("regsvr32 /s " & Chr$(34) & Environ("ProgramFiles") & "\Common Files\InteractiveStudios\IsLicense30.dll")

Open in new window

In my installation Tests I get:
Windows 7
RegSvr32 Error
The module “C:\Program Files\Common Files\InteractiveStudios\IsLicense30.dll” was loaded but the call to DllRegisterDerver failed with error code 0x80070005.
My Trapped Error
Automation Error
The specified module could not be found.
Path: C:\Program Files\Common Files\InteractiveStudios\IsLicense30.dll

Good Install

Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Yes, I thought it was permission issue as well and maybe there was something that could be done differently.  There was no difference with UAC on or off.
A second call to tech support of the installer I use (SageKey Access 2003) got me a new version of the installer.  This has solved the problem.