Using the old activeX dll?

Jourdan
08-26-2009, 03:23 AM
My application plays a director dcr files using an old Shockwave activeX control (Control.dll). It plays great on my computer. But everytime I run it on another computer, my application plays it using the new one wich is installed on that computer. My dcr files are an old files, so it need to play using an old control too.
The old shockwave ctrl is using "Control.dll" and the new one uses "SwDir.dll".

Is there any solution?

Thanks in advance

jantje
08-26-2009, 03:45 AM
the easiest solution is to use side by side assemblies using a manifest file, but then your client should be at least WinXp (SP1 ?)
If that's not a problem, then I'd go down that path.
You could also dynamically load the dll with DllGetClassObject and instantiate it. That way it'll be compatible from win95 onwards, but it will require you to write a (small) typelib and you must have some COM knowledge.
Both are perfectly doable solutions

vb5prgrmr
08-26-2009, 08:03 AM
jantje win 2ksp3 if I remember correctly...

Create install package via PDW and see if the old dll is included in the package. If so then use it to install the old dll. Then check to see if it was installed.

You might be able to get away with either downloading and installing Windows Media Player Classic to get the old codecs or perhaps searching for the correct codecs (had similar problem with different file type and this is how I fixed it).



Good Luck

Jourdan
08-26-2009, 01:09 PM
I'm very noobs, how do I use DllGetClassObject to be exactly? :confused:

sorry and thanks in advance

jantje
08-27-2009, 02:03 AM
First, you need IClassFactory interface. VB6 natively doesn't ship with one, so you'll need to define it yourself in a typelibrary. If you are comfortable with IDL or ODL then with a little bit of help from MSDN it's not too hard to write it. Perhaps you can even find it done for you on the internet somewhere, I don't know...

Then you need to call DllGetClassObject, which is an export in every COM file. If you don't want to have to fiddle with calling pointers etc., the easiest way to call it is by defining a declare function.
A bit like:
Private Declare Function DllGetClassObject Lib "foo.dll" (rclsid As CLSID, riid As IID, ByRef ppv As Any) As Long
As you see, you also need CLSID and IID types (which basically are the same). I prefer to write them in a typelib, but you can also use a 'type' for this. There's enough info on the internet how to write that.

Then you call DllGetClassObject with the CLSID of the interface you want to instantiate. The second parameter is the IID from IClassFactory ("{00000001-0000-0000-C000-000000000046}") and third your instance of your IClassFactory interface.

you can convert a GUID string to a CLSID or IID with "IIDFromString" defined in Ole32.dll

Once that is done you can call your IClassFactory.CreateInstance to create your object and pass Nothing as a first parameter and the IID from IUnknown ("{00000000-0000-0000-C000-000000000046}") as the second parameter and it will return a new instance of your object.

You can still hold a reference in your project to keep intellisense functionality intact and write a small helper function to do most of the work for you.
You might even want to expand it so you can retrieve the CLSID from the ProgID, but that's not really easy if the control is not registered as you can't use the API function for that. It still is possible, however.

After all is done the only difference in your code will be something like:

Dim myFoo as Foo
Dim myBar as Bar

Set myFoo = New Foo
Set myBar = New Bar


Will become something like (pseudo code)

Dim myFoo as Foo
Dim myBar as Bar

Set myFoo = CreateObjectEx("{0DBDB8E7-EEA4-46FB-85C2-77201BCC453A}") 'The CLSID string of your Foo interface
Set myBar = CreateObjectEx("{00000000-DEAD-BEEF-C000-000000000099}") 'The CLSID string of your Bar interface

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum