COM :: VARIANT -eek

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Matt Smith

    COM :: VARIANT -eek

    Hi, all.

    Just a quick question, when setting a COM process to read a value from
    a pre-defined register index, I think, I have to change the variable
    that the value will be returned to (as I have to do for the same
    function in perl), into a VARIANT, However when i run the variant
    code....

    'serialIndex = win32com.client .pythoncom.VT_V ARIANT'

    no matter what extension I use (i.e. VT_I4 or VT_BOOL etc etc) it
    still returns a type mismatch error. I may be doing something wrong or
    getting confused with variant processes in python. I do know the code
    I use in perl to do this works but I dont know how to translate this,
    fully, into python.

    perl code for variant =
    Win32::OLE::Var iant::Variant(W in32::OLE::Vari ant::VT_VARIANT |Win32::OLE::VA RIANT::VT_BYREF ,
    0)

    Cheers in advance,
    Matt
  • Mark Hammond

    #2
    Re: COM :: VARIANT -eek

    Matt Smith wrote:[color=blue]
    > Hi, all.
    >
    > Just a quick question, when setting a COM process to read a value from
    > a pre-defined register index, I think, I have to change the variable
    > that the value will be returned to (as I have to do for the same
    > function in perl), into a VARIANT, However when i run the variant
    > code....
    >
    > 'serialIndex = win32com.client .pythoncom.VT_V ARIANT'
    >
    > no matter what extension I use (i.e. VT_I4 or VT_BOOL etc etc) it
    > still returns a type mismatch error. I may be doing something wrong or
    > getting confused with variant processes in python. I do know the code
    > I use in perl to do this works but I dont know how to translate this,
    > fully, into python.
    >
    > perl code for variant =
    > Win32::OLE::Var iant::Variant(W in32::OLE::Vari ant::VT_VARIANT |Win32::OLE::VA RIANT::VT_BYREF ,
    > 0)[/color]

    Unfortunately, you really can't do this in a clean way. The best thing
    to do is to ensure "makepy" has been run for your COM object, and the
    right magic should always happen.

    Mark.

    Comment

    • Matt Smith

      #3
      Re: COM :: VARIANT -eek

      Mark Hammond <mhammond@skipp inet.com.au> wrote in message news:<bha8cu$2q 3l$1@arachne.la byrinth.net.au> ...[color=blue]
      > Matt Smith wrote:[color=green]
      > > Hi, all.
      > >
      > > Just a quick question, when setting a COM process to read a value from
      > > a pre-defined register index, I think, I have to change the variable
      > > that the value will be returned to (as I have to do for the same
      > > function in perl), into a VARIANT, However when i run the variant
      > > code....
      > >
      > > 'serialIndex = win32com.client .pythoncom.VT_V ARIANT'
      > >
      > > no matter what extension I use (i.e. VT_I4 or VT_BOOL etc etc) it
      > > still returns a type mismatch error. I may be doing something wrong or
      > > getting confused with variant processes in python. I do know the code
      > > I use in perl to do this works but I dont know how to translate this,
      > > fully, into python.
      > >
      > > perl code for variant =
      > > Win32::OLE::Var iant::Variant(W in32::OLE::Vari ant::VT_VARIANT |Win32::OLE::VA RIANT::VT_BYREF ,
      > > 0)[/color]
      >
      > Unfortunately, you really can't do this in a clean way. The best thing
      > to do is to ensure "makepy" has been run for your COM object, and the
      > right magic should always happen.
      >
      > Mark.[/color]

      Hi, thanks for the reply,

      My problem is now this, when i go to makepy tool in pythonwin, it does
      not see/recognise the type library file I want it to convert. Is there
      anyway to add the file to the list of .tlb files it does does?

      Cheers,
      Matt.

      p.s. How do I include the generated makepy file into my code ?

      Comment

      • Mark Hammond

        #4
        Re: COM :: VARIANT -eek

        Matt Smith wrote:[color=blue]
        > Mark Hammond <mhammond@skipp inet.com.au> wrote in message news:<bha8cu$2q 3l$1@arachne.la byrinth.net.au> ...[/color]
        [color=blue]
        > My problem is now this, when i go to makepy tool in pythonwin, it does
        > not see/recognise the type library file I want it to convert. Is there
        > anyway to add the file to the list of .tlb files it does does?[/color]

        These type libraries are in the registry. You may be able to pass the
        filename on the commandline to makepy.
        [color=blue]
        > p.s. How do I include the generated makepy file into my code ?[/color]

        In generaly, you just need to generate the file and do nothing else. At
        runtime, Python will see these generated files and automatically use them.

        I don't know how that will go with your type library though.

        Mark

        Comment

        • Matt Smith

          #5
          Re: COM :: VARIANT -eek

          Mark Hammond <mhammond@skipp inet.com.au> wrote in message news:<bhefuk$2g vi$1@arachne.la byrinth.net.au> ...[color=blue]
          > Matt Smith wrote:[color=green]
          > > Mark Hammond <mhammond@skipp inet.com.au> wrote in message news:<bha8cu$2q 3l$1@arachne.la byrinth.net.au> ...[/color]
          >[color=green]
          > > My problem is now this, when i go to makepy tool in pythonwin, it does
          > > not see/recognise the type library file I want it to convert. Is there
          > > anyway to add the file to the list of .tlb files it does does?[/color]
          >
          > These type libraries are in the registry. You may be able to pass the
          > filename on the commandline to makepy.
          >[color=green]
          > > p.s. How do I include the generated makepy file into my code ?[/color]
          >
          > In generaly, you just need to generate the file and do nothing else. At
          > runtime, Python will see these generated files and automatically use them.
          >
          > I don't know how that will go with your type library though.
          >
          > Mark[/color]

          Hi again,

          I had to register the .tlb file (as it didnt do it automatically at
          installation [don't know why]) using a vb .tlb registration script,
          which worked fine and now I have a lovily makepy.py generated file for
          my .tlb file.

          My problem is now this, When I try to run the file (in pythonwins
          interactive window) using the code:

          from win32com.client include gencache
          gencache.Ensure Module('{AF6849 23-D245-11D3-8DE8-00A024ACAB85x0x 1x0}',
          0, 1, 0)

          pythonwin returns the error:

          ImportError: No module named
          gen_py.AF684923-D245-11D3-8DE8-00A024ACAB85x0x 1x0

          I have tested it with other makepy.py generated files and they all
          return the same error. Do I need to tell python where to find these
          makepy files? or is there some other reason as to why it does not want
          to use ANY makepy.py files

          thanks for all the help,
          matt.

          Comment

          • Matt Smith

            #6
            Re: COM :: VARIANT -eek

            hi again, sorry about all these updates but cant remember what I
            posted in the last message and google ahsnt updated yet :/.

            My current probelm is that I have generated a makepy file and then run
            ensureModule on it to ensure early binding. However when I came to run
            Dispatch it still ran with late binding :(. If i ran the script with
            ensureDispatch would that help (instead of normal client.Dispatch that
            is)

            thanks again,
            matt.

            p.s. forgot to post the .tlb register website address here it is:


            Comment

            Working...