Activex issue and ocx issue - activex

I have created Activex in Vb
It contain one public method in VB
When I call it through javascript
it says 'object does not support properties or method'

You'll get the error message in the following conditions:
1. The method or property is not a valid one.
2. The ActiveX control is not available on the machine.
If the method/property is called in a right way, please check whether you've installed/registered the ActiveX control on the machine.

By the sound of it, you have not have the activex module registered in the Windows registry.
Try registering the ActiveX as shown here:
C:\Windows\System\regsvr32 name_of_activex.ocx
Replace 'name_of_activex.ocx' with the full path to your activex module.

Related

Delphi COM dll with two interfaces. Only one clsid gets registered

I've created a Delphi COM dll that implements two different interfaces, each with its own class id. It didn't register correctly in the Delphi (XE7) IDE but regsvr32 in an elevated command prompt was quite happy and said it succeeded.
However, only one of the two interfaces was registered and there's no sign of the other interface's clsid in the registry and confirmed by attempts to connect to failing with Not registered errors. Naturally I would like both interfaces registered. What's my best course of action?
Well I'm not saying this is the right answer, but I exported the clsid of the interface that worked, edited the file, changed the GUID and merged it back into the registry. It works now on both interfaces, though they are on different threads (the dll is multithreaded- never a dull moment!).
It doesn't feel right though doing it this way! Here is my edited file. Only the GUIDs were changed.
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\CLSID\{C5EF04CB-63D6-4184-9873-2ADCF6C26EF8}]
#="MyRDP"
[HKEY_CLASSES_ROOT\CLSID\{C5EF04CB-63D6-4184-9873-2ADCF6C26EF8}\InprocServer32]
#="C:\\dev\\VirtualChannels\\Client2\\Client2.dll"
"ThreadingModel"="Free"
[HKEY_CLASSES_ROOT\CLSID\{C5EF04CB-63D6-4184-9873-2ADCF6C26EF8}\ProgID]
#="Client2.Plugin"

Unable to register a type library

This is in Delphi XE7. I had an existing type library (for Dynamic Virtual Channels- the client side) and needed to add a method to the interface so an application on the client side could talk to the dll to send messages over the virtual channel. I created a new interface, got a new GUI for it, modified the .idl file (Windows SDK provides the tsvirtualchannels.idl file in the Windows SDK).
I used midl to create the .tlb type library from the .idl and then ran tlibimp (Embarcadero utility) to generate the delphi -tlb.pas
My Delphi class implements the new method. But the new interface wasn't registered with Windows and all attempts using the Embarcadero tregsvr (running in an elevated command prompt) to register the library failed with the message Error accessing the OLE registry
I have tried to register the new interface manually. I'd created my interface similar to IWTSListener and went through the registry finding that key, exporting it, then changing the interface name to mine and the GUID to the new GUID then reimported it. There were four instances.
When the client dll starts, it starts an out of process server and passes it the Agile Reference (of the client dll interface. An agile reference is how a MTA application can talk to an STA). However when I query the interface to get my new interface, I get interface not supported.
I've more or less given up on tregsvr. It provides no details of errors. Is there anything else I need to do to get the new interface registered?
It occurred to me there are one or two things that could prevent this course of action working:
I haven't changed the dll main interface IWTSPlugin to IWTSPlugin2. Would Windows (i.e. mstsc) use IWTSPLUGIN2 for Virtual channels? Adding a new interface to this and not changing it is a mortal sin (I know- mea culpa).
I resolved this eventually. The powers that be had added a policy to Windows so that tregsvr would not register a type library for all users, only if it had the -t -c parameters to register it for the current user. Lots of muttering was heard when I found it out...

Using IOfficeAntiVirus interface in Delphi

Presently I am developing a small security application in Delphi. It is intended to be installed in Windows XP and higher OS-s and almost finished, but I'd like to implement the feature to scan MS Office files while opening. To that end, I'm planning to use IOfficeAntiVirus interface. I am trying to realize using the scan method of the interface based on the article by Serge Perevoznyk (http://www.delphi-central.com/MS_Office_AV_API.aspx).
The original example supposed to display a message box when a file is opened, however it does not, although I tried it on different versions of Windows and Office. I compared this solution with the information on MSDN. It seemed to be correct. I suppose there should be some additional settings in the Windows Registry which I missed to make. Can anyone give me some hint where shall I look for the solution?
You do not use IOfficeAntiVirus, you implement it.
You need to create a new ActiveX Library that contains a new ActiveX Control whose implementation class implements the Scan() method. In the Control's registration code, you have to use ICatRegister to register your Control as using the CATID_MSOfficeAntiVirus category. That way, Office/IE can find your ActiveX Control so it can instantiate it and call its Scan() implementation. The second half of Serge's article shows you how to do that (Serge's example shows Scan() taking a PChar as input, but it actually takes a TMsoavinfo^ instead. Don't pass TMsoavinfo using a PChar).
You then have to register the resulting DLL using Windows' command-line regsvr32.exe app.
If Office/IE is not calling your Scan() implementation, then you are likely not registering your ActiveX control correctly, such as if you are not taking 32bit/64bit and/or UAC issues into account.
Just for information's sake if anyone is interested. Remy's answer is correct, however there is a small bug in the initialization section of the above mentioned example project.
Instead of
TComObjectFactory.Create(ComServer, TMsoTest, Class_MsoTest,
'MsoTest', '', ciMultiInstance, tmApartment);
The correct command is:
TMSOAVFactory.Create(ComServer, TMsoTest, Class_MsoTest,
'MsoTest', '', ciMultiInstance, tmApartment);

How to create a published procedure/function in activeX with Delphi? [duplicate]

This question already exists:
Closed 10 years ago.
Possible Duplicate:
Can't access public function in delphi ActiveX control?
I'm working with an ActiveX control implement by Delphi. In my main class, I have:
type
TezDICOMX = class(TActiveForm, IezDICOMX)
ToolBar1: TToolBar;
OpenBtn: TSpeedButton;
PreviousBtn: TSpeedButton;
....
I add these code to the class.
published
procedure abc; safecall;
After that, I build the project and register the ActiveX server. It generate the ezDICOMax.ocx. I open the visual studio, delete the remain ezDICOM activeX control I've embed before and embed the new one. I drag the activeX control to the design and name it the_ezdicom.
So as I think, I should can call the_ezdicom.abc(), but when I do that, the compiler complains
'AxezDICOMax.AxezDICOMX' does not contain a definition for 'abc' and no extension method 'abc' accepting a first argument of type 'AxezDICOMax.AxezDICOMX' could be found (are you missing a using directive or an assembly reference?)
What I did wrong? How to create a published procedure/function in ActiveX control with Delphi?
If I change an existing function/procedure in the class and do all the register, embed step, the result of that function/procedure when I call from C# change too, so I think that the activeX control is updated to my Delphi source, but I still can't add published procedure/function.
You need to:
Edit the type library (using the type library editor) to add the new method
Refresh the implementation (this can be done automatically by the type library editor, depending on your IDE settings), write your implementation code in the generated method body
Build and re-register your ActiveX server (in case you added new interfaces or data types); run regsvr32 as administrator because it needs access to protected registry branches.
The Delphi visibility of the implementor method is irrelevant in this case: the class is supposed to be used through an interface pointer, not through a Delphi class instance pointer. Therefore I would recommend to keep it protected, as generated by the type library editor.
I found that it is a problem with Visual Studio. Because I change the interface of my activeX control, so I have to delete the reference to activeX control in my project, add it again. If we do not change the interface, just unregister and register the activeX control is enough.

Pegasus Imaging PrintPro ActiveX control gives error when dropped on Delphi form

I'm trying to use the Pegasus Imaging PrintPro v4 ActiveX control with Delphi 7 on a Win2K box. When I drop the ActiveX control on the form I get the extremely helpful error message
"Access violation at address 00000000. Read of address 00000000."
and the component doesn't appear on the form.
There are a bunch of other Pegasus Imaging ActiveX controls installed and they work fine.
Any suggestions on where to start troubleshooting, I'm not very experienced with ActiveX control (I usually go for native VCL only).
Lachlan
If you download the latest changes file it says that "Fixed an issue where the ActiveX DLL would not register on Windows 2000.".
You should try upgrading to the latest version.
Something in the control is not configured properly. You might not be able to "drop" it on the form, but might have to instantiate it manually. The access violation you are experiencing is the attempt to get the value out of a pointer which is null. Most likely the control has a required construction parameter which is not being set by the Delphi ActiveX component wrapper.

Resources