Solved

Referencing dll's and ActiveX exe's - (more pts for a solution)

Posted on 2001-06-20
14
277 Views
Last Modified: 2010-05-02
Can project references to dll's or ActiveX exe's be modified dynamically in Vb, I seem to remember they can in Access using Vba. Eg if my compiled exe references a dll or ActiveX exe on one server can I change the reference to a dll or ActiveX exe on another server?

More points if there is a solution and the answer is more than 'no'.
0
Comment
Question by:rhubarbtwo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +4
14 Comments
 
LVL 5

Expert Comment

by:rkot2000
ID: 6210534
I think you can use late binding to do this.

0
 
LVL 4

Expert Comment

by:beckingh
ID: 6210555
Right.  Just don't make your project reference a specific DLL or EXE.  Then in your code, create the object like this:

Set myObj = CreateObject("MyObj.ObjectName")

Obviously, you can pass in a string to "CreateObject", so you can modify it as necessary.

This is Late Binding.
0
 
LVL 1

Expert Comment

by:mcbeth
ID: 6210571
you have to unregister the dll and then register the dll you like to use. Windows stores the information where to find the dll local. e.g. if you register a dll not local Windows create a fake Interface und forward all requests to the dll (called proxy stub).  
0
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
LVL 15

Expert Comment

by:ameba
ID: 6210841
You can also use Early binding.
You don't need reference to the actual ActiveX DLL or EXE, you only need reference to interface it implements.
0
 
LVL 9

Expert Comment

by:Valliappan AN
ID: 6211006
If you are talking about different OS, or specific servers, then you could also, use compiler directives for declaration, if I am right.

Cheers
0
 
LVL 3

Expert Comment

by:Hornet241
ID: 6211699
You can use the create object function

Set Obj = CreateObject("MyObj.ObjectName", "MyServerName")

I have used this on a W2K server with the object in a Com+ application, I think it should work with an MTS object as well
0
 

Author Comment

by:rhubarbtwo
ID: 6214235
So I can dynamically reference a dll if I don't reference a specific DLL in the references dialog and if I use late binding with method CreateObject. But Windows has to know about the object name (MyObj.ObjectName) so that dll has to be registered with Windows.

Now if I have the dll or activeX exe located on 2 different servers and the file name is identical, could I differentiate between dll's, eg depending on a parameter could I instantiate either 1 of the 2 dll's? I can't see how I can because when the dll's are registered with Windows using a proxy stub the dll's would have identical class names.
0
 
LVL 5

Expert Comment

by:rkot2000
ID: 6214285
try to use :
CreateObject(prodname.classname, location)

prodname.classname
Required.The type or class of the object to create.

location

Optional. The name of the network server where the object is to be created.

0
 
LVL 15

Expert Comment

by:ameba
ID: 6214458
' Early bound sample 1
' add reference to whichever MyObj.dll you want
Dim Obj As MyObj.ObjectName
Set Obj = CreateObject("MyObj.ObjectName", "MyServerName")


' Early bound sample 2
' add reference to whichever MyObj.dll you want, or reference to other dll or type library which contains declaration for interface IObjectName

Dim Obj As SomeDll.IObjectName
Set Obj = CreateObject("MyObj.ObjectName", "MyServerName")
(where MyObj.ObjectName implements IObjectName interface)
or:
Set Obj = CreateObject("TheObj.WhatEver", "MyServerName")
(where TheObj.WhatEver implements IObjectName interface)
0
 
LVL 3

Expert Comment

by:Hornet241
ID: 6215010
One thing to remember when using the server parameter with the createobject function is that the DLL must be registered on both the Calling machine and the server.

>>>Now if I have the dll or activeX exe located on 2 different servers and the file name is identical, could I differentiate between dll's, eg depending on a parameter could I instantiate either 1 of the 2 dll's?

 If the class id of the DLL is the same all around then the Servername will determine the location it is created

One other thing the DLL does not have to reside on the calling machine, it just has to be registered
0
 
LVL 3

Expert Comment

by:Hornet241
ID: 6215029
Forgot to mention that you only register the DLL once on the calling machine, the physical location does not matter as when the Servername parameter is use it does not even look for the file just the class id in the registry
0
 

Author Comment

by:rhubarbtwo
ID: 6218138
Thanks everyone for your help, I think Hornet241's comments have been the most help to my specific problem.

Hornet: how do I register a dll on the calling machine when the dll is located on a server? Do I run regsvr.exe on the client with a path to the dll on the server as the argument?
0
 
LVL 3

Accepted Solution

by:
Hornet241 earned 50 total points
ID: 6218809
That will work.

You can also copy the DLL using Windows Explorer from the Server and paste it on top of "regsvr32.exe", also you could drag the DLL and drop it on the "regsrv32.exe".  

All of these ways will work when done from the machine you want to register it on.

0
 

Author Comment

by:rhubarbtwo
ID: 6230442
Thanks, that's interesting
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question