07010521.txt 01-Jul-00


Subject: Registering ActiveX
From: DEarl@NewYorker.DE (David Earl)

I've got an OCX, which I would like to register at runtime.
  Is there some function (or group) that gives a result like
  CoRegisterServer("MyServer.OCX")?

TIA,
David

Subject: Re: Registering ActiveX
From: "Willie Moore" <williem@wmconsulting.com>

David,

You might want to contact Rod Da Silva. I know that he can
  do this at runtime and I have seen something posted on it
  before. but, I do not have a copy of the post anymore.

Regards,
Willie


Subject: Re: Registering ActiveX
From: DEarl@NewYorker.DE (David Earl)

Thanks Willie,

I'll try Rod's CSi address.  All that I've found so far is
  to do something very roughly like:
Func GiveMeThatControl!!( _cFileName)
  IF S_OK#GetClassFile( _cFileName)
    LoadLibrary( _cFileName)
    ..call DllRegisterServer for the loaded lib
    FreeLibrary...
  ENDIF
RETURN

David


Subject: Re: Registering ActiveX
From: "Dirk Lesko [dLESKO[" <support@delete.this.funcky.com>

David,

A call to OleInitialize(NULL) shoud be made prior to calling
  DllRegister() since many times, the MS generated
  registration routines expect that this has already been
  done... blanace it on the way ouw with OleUnitialize().
int DllRegister(char* Name)
{
  HRESULT (_stdcall *pDllRegister)( void );
  HRESULT r = E_UNEXPECTED;
  HANDLE  hLib = NULL;
  OleInitialize(NULL);
  hLib = LoadLibrary(Name);
  if(hLib != NULL)
  {

    (FARPROC&) pDllRegister =
      (FARPROC)GetProcAddress(hLib, "DllRegisterServer");
    if(pDllRegister != NULL)
    {
      r = (pDllRegister)();
    }
    FreeLibrary(hLib);
  }
  OleUninitialize();
return (int)r;
}
Here's some C code from FUNCky for VO you can snarf... feel
  free to convert to VO... it works well (as long as the DLL
  is self registering...)

Dirk


Subject: Re: Registering ActiveX
From: DEarl@NewYorker.DE (David Earl)

Thanks, both for the reminder on OLEInitialize(), and the
  code,

David.


Subject: Re: Registering ActiveX
From: "Geoff Schaller" <geoffsch@bigpond.net.au>

David,

PMFJI but it is generally not wise (nor necessary) to free a
  library. All the MS literature says this. As long as you
  get the pointers to the correct dll required, it won't
  matter.

Geoff


Subject: Re: Registering ActiveX
From: nswong@maxis.net.my (Wong)

Hi Geoff,

By freeing a library, sometime it will reveal hidden
  problem, this will help us to narrow down to a particular
  library at deveIopment time, instead of let maintainance
  guy struggle with it after project completed. We encounter
  a fews case few month ago, I can't show you now due to
  we(or me :-) ) does not write down the detail, and
  currently we are doing other part. But in future, if we
  come across again, I will tried to make it reproducable
  and post it here.
MS does not recomment to free a library maybe by this way,
  this sort of memory related problem will not end up as
  GPF. But I simply does not feel right to let problem cover
  under the carpet, this may end up become a more
  complicated problem. I maybe wrong, but this is my
  prefered way.

I'm not good at debate with other, if you think I'm wrong,
  then ...
You  win!  :-)

Regards,
Wong


Subject: Re: Registering ActiveX
From: "Geoff Schaller" <geoffsch@bigpond.net.au>

Wong,

I don't agree. Once the library is no longer in reference,
  it is "inert" in memory. It has no ability to create GPFs
  or cause any action of its own.
However, you may in fact generate more problems because of
  trying to remove the library at the wrong moment (ie too
  early). It causes no harm or problems just sitting there
  in memory. Windows will kick it out when it wants the
  space <g>.

Geoff


Subject: Re: Registering ActiveX
From: nswong@maxis.net.my (Wong)

Hi Geoff,

>
I don't agree. Once the library is no longer in reference,
  it is "inert" in memory. It has no ability to create GPFs
  or cause any action of its own.
<
What I tried to said are, if I do call FreeLibrary(), I will
  receive a GPF. And this GPF will not occurs if I donot
  call FreeLibrary(). I suspect this is the GPF what
  sometime people encounter when application ending, in this
  case, I prefer to use FreeLibrary() to reveal which DLL to
  be blame.
And we have some diagnostic routine will run after
  FreeLibrary() to check for side effect cause by any DLL,
  without FreeLibrary(), the checking will not be accurate.
Writing English are not a easy task for me, I chose
  surrender instead of debate using English with other. :-)

Regards,
Wong


Subject: Re: Registering ActiveX
From: "Geoff Schaller" <geoffsch@bigpond.net.au>

Wong,

You prove my point. You MUST NOT try to delete the library
  until you are absolutely certain every reference and every
  class has been removed. I think this is one of the
  benefits behind _VOFreeLibrary(). I think it clears up VO

  classes properly, whatever that means <g>. But no, it
  cannot be the cause of a GPF on exit. Otherwise, this
  would be perfectly reproducable and I don't think it is. I
  say again, a dormant, unreferenced DLL cannot have any
  effect on anything.
>
Writing English are not a easy task for me, I chose
  surrender instead of debate using English with other. :-)
<
I think you're doing great and I appreciate the effort it
  must take.

Cheers,

Geoff


Subject: Re: Registering ActiveX
From: DEarl@NewYorker.DE (David Earl)

Were this a library, which VO was opening/closing, I would
  agree.
However, I'm generating the reference to the library, and I
  find it dirty programming not to clean up after myself.
  In this particular case, server registration should be an
  inline process, to my way of thinking...IOW, the function
  doesn't return until its job is done.

David.


Subject: Re: Registering ActiveX
From: "Ross Chappell" <RossChappell@electricpeople.com>

VO Tools includes a function called DLLRegister() which can
  be used to register in-proc DLL's and OCX controls on the
  fly. It also includes a function called DLLUnRegister()
  which can be used to unregister controls when you are done
  with them.
If you want to give it a try so that you can see if this is
  what you need, you can download an evaluation version at
  http://www.electricpeople.com

HTH,
Ross