Hi,

    I don't whant add new code or method to Win32::GUI but make change in my
Win32::GUI::AxWindow XS code.
    You advice about Dynaloader it's very usefull.
    I can found dll handler with it. It test it with PAR and it's work nice.

void
GetOLE (container)
   CContainer*  container
CODE:
{
#ifdef PERL_5005
  typedef SV* (*MYPROC)(CPERLarg_ HV *, IDispatch *, SV *);
#else
  typedef SV* (*MYPROC)(pTHX_ HV *, IDispatch *, SV *);
#endif

  HMODULE hmodule;
  MYPROC pCreatePerlObject;
  IDispatch * pDispatch;

  ST(0) = &PL_sv_undef;
  // Try to find OLE.dll
  hmodule = GetModuleHandle("OLE");
  if (hmodule == 0) {
    // Try to find using Dynaloader
    AV* av_modules = get_av("DynaLoader::dl_modules", FALSE);
    AV* av_librefs = get_av("DynaLoader::dl_librefs", FALSE);
    if (av_modules && av_librefs) {
      // Look at Win32::OLE package
      for (I32 i = 0; i < av_len(av_modules); i++) {
        SV** sv = av_fetch(av_modules, i, 0);
        if (sv && SvPOK (*sv) &&
            strEQ(SvPV_nolen(*sv), "Win32::OLE")) {
          // Tahe
          sv = av_fetch(av_librefs, i, 0);
          hmodule = (HMODULE) (sv && SvIOK (*sv) ? SvIV(*sv) : 0);
          break;
        }
      }
    }
  }

  if (hmodule != 0) {
    pCreatePerlObject = (MYPROC) GetProcAddress(hmodule,
"CreatePerlObject");
    if (pCreatePerlObject != 0)  {
      HV *stash = gv_stashpv("Win32::OLE", TRUE);
      pDispatch = container->GetIDispatch();
      pDispatch->AddRef();
#ifdef PERL_5005
      ST(0) = (pCreatePerlObject)(PERL_OBJECT_THIS_ stash, pDispatch, NULL);
#else
      ST(0) = (pCreatePerlObject)(aTHX_ stash, pDispatch, NULL);
#endif
    }
  }
}
My code is now :
void
GetOLE (container)
   CContainer*  container
CODE:
{
#ifdef PERL_5005
  typedef SV* (*MYPROC)(CPERLarg_ HV *, IDispatch *, SV *);
#else
  typedef SV* (*MYPROC)(pTHX_ HV *, IDispatch *, SV *);
#endif

  HMODULE hmodule;
  MYPROC pCreatePerlObject;
  IDispatch * pDispatch;

  ST(0) = &PL_sv_undef;
  // Try to find OLE.dll
  hmodule = GetModuleHandle("OLE");
  if (hmodule == 0) {
    // Try to find using Dynaloader
    AV* av_modules = get_av("DynaLoader::dl_modules", FALSE);
    AV* av_librefs = get_av("DynaLoader::dl_librefs", FALSE);
    if (av_modules && av_librefs) {
      // Look at Win32::OLE package
      for (I32 i = 0; i < av_len(av_modules); i++) {
        SV** sv = av_fetch(av_modules, i, 0);
        if (sv && SvPOK (*sv) &&
            strEQ(SvPV_nolen(*sv), "Win32::OLE")) {
          // Tahe
          sv = av_fetch(av_librefs, i, 0);
          hmodule = (HMODULE) (sv && SvIOK (*sv) ? SvIV(*sv) : 0);
          break;
        }
      }
    }
  }

  if (hmodule != 0) {
    pCreatePerlObject = (MYPROC) GetProcAddress(hmodule,
"CreatePerlObject");
    if (pCreatePerlObject != 0)  {
      HV *stash = gv_stashpv("Win32::OLE", TRUE);
      pDispatch = container->GetIDispatch();
      pDispatch->AddRef();
#ifdef PERL_5005
      ST(0) = (pCreatePerlObject)(PERL_OBJECT_THIS_ stash, pDispatch, NULL);
#else
      ST(0) = (pCreatePerlObject)(aTHX_ stash, pDispatch, NULL);
#endif
    }
  }
}

> > For correct this problem, i need to enumerate all dll attached to
> > current process and try to found renamed OLE.dll.
>
> try this command: "set PERL_DL_DEBUG=1" and then launch your exe. this
> should give you some hint about the dll that are being loaded. try
> "perldoc DynaLoader" for more information on the subject.
>
> > I found some source code for do this but it's not easy ;o) because don't
> > exist a standard API for all Windows system.
> > http://www.alexfedotov.com/articles/enumproc.asp
> >
> >     I try to add this in next release.
>
> no please. Win32::GUI is not the place for this stuff. probably
> Win32::Process is the correct place, if it's not implemented already.
>
> cheers,
> Aldo
>


Reply via email to