Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Registering OCX

Registering OCX

Registering OCX

I've got a network application on our server which needs access to the MS DatePicker control.  I've got the following code at the top of my main program:

LOCAL lcCommand
lcCommand = "RUN RegSvr32.exe  C:\windows\system\MsComct2.ocx /s"
RELEASE lcCommand

First, it's not "silent".  

Second, it's running every time the program starts.  How can I detect if the control is already registered and only run this registration when the application is run for the first time on a different workstation?

RE: Registering OCX

Normally you'd install/register this and any other control in the SETUP.EXE for your application, then you wouldn't have to worry about it in the application itself.

You'll need to read the registry to see if it's registered. Minimally you'll need to check for this key: "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\mscomct2.ocx".


RE: Registering OCX


Doesn't the OCX need to be on the local workstation machine?  If so, then an installation (SETUP.EXE) file won't help.  It'll be registered on the server and not where it needs to be.  


RE: Registering OCX

Absolutely, while I didn't make it clear, I meant an application Workstation install. Since the example he gave was on "C:", I assumed that was what he was talking about.


RE: Registering OCX

Hi Steve,

The OCX can remain in your server directory, as long as it's properly register. However, it really should be placed in the user's local windows\system directory.

Now, to address your two questions. Define exactly what you mean by it's not "silent". The /s switch passed to regsvr32 will prevent the confirmation messagebox from appearing, which is where I presume you derived the term silent. If you're referring to the flash of the DOS console include the nowait switch with a minimize attribute for the RUN command:
RUN /N7 regsvr32 c:\windows\system\mscomct2.ocx /s

AFA determining if the control is already registered, attempt to create an instance:
ON ERROR llNotInstalled = .T.
oDatePick = CreateObject("MSComCt2.DTPicker.2")
IF llNotInstalled
  *copy the ocx from network path to local windows\sys dir
  *register ocx

FWIW, if the OS is NT-based, the local path will be WinNT\System32.

Jon Hawkins

RE: Registering OCX

Sorry, but the oleclass for the datetime picker is MSComCtl2.DTPicker.2 - I should've consulted the docs prior to posting. So the line that reads:

oDatePick = CreateObject("MSComCt2.DTPicker.2")

should read:

oDatePick = CreateObject("MSComCtl2.DTPicker.2")

And for clarification, Rick's suggestion of using a SETUP application is the proper way for distributing/registering ActiveX controls.

Jon Hawkins

RE: Registering OCX

I do like your CreateObject() / error handling much better than mucking around in the registry. The strange thing is that I'd used that technique before, but forgot about it - probably because it works so good!


RE: Registering OCX

Rick & John:

I've consolidated all of the above into a class that will check the registration status.  If not registered, it will copy it local and then register it.  Once I get the code "cleaned up" I'll post the class in the FAQ section.  

Thanks for the guidance!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close