Re: [python-win32] OE/WAB help with VB ...

2008-03-11 Thread Clinton Lee Taylor
Greetings ...

 Thanks again for the quick response ...
>  Clinton Lee Taylor wrote:
>  > I think I get this because com objects have to be "imported" ... But
>  > this ActiveX object does not seem to have a "type lib"? ...
>  It appears the type info is embedded in the dll itself, rather than
>  shipped as a separate .tlb.

>  I get the same error after generating the wrapper from the type info.
>  Try clearing your \win32com\genpy folder, and run it without the
>  EnsureDispatch.  There may be something wrong with the type
>  info, but it would take a lot of digging to find out exactly what.
 Okay, the little library is LGPL and the source is about, would we be
able to get the details from the header files or something else?

Thanks
Mailed
LeeT
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] advice on architecting or program design in python:

2008-03-11 Thread mark.a.brand
>
> hi:
>
> 
> Not that it's necessarily wrong, but it's not clear why you're bothering
> to pull server information from each client separately. It's not as
> though the services running on Server S1 will appear different when
> queried from client C1 and C2. But maybe there's something I'm missing.
> 
>
> sorry - client as in customer
>
> 
> CREATE TABLE
>   processes
> (
>   client VARCHAR (100),
>   server VARCHAR (100),
>   name VARCHAR (100),
>   status VARCHAR (100)
> .
> .
> etc
> )
> 
>
> thats what i have
>
> 
> Now, if what you're saying is: hey, they all seem to have .Caption,
> .Status, .Name attributes; surely some sort of denormalisation applies
> here, then I would say: Beware. It's terribly tempting to create a
> database-within-a-database without any real gain. Unless it's really
> offering you something to create a wmi_objects table with 1:1
> subordinates, don't do it.
> 
>
> no - the db structure you outlined above is fine.
>
> i will try and explain better, but its not quite clear in my mind what is
> achievable ...
>
> so to build up these database tables, i have to have some queries
> happening of the form :
>
> for list in Win32_Process()
>  add instance to table-process
>
> for list in Win32_Service()
>  add instance to table-service
>
> ...
> etc etc for each Win32_* query i wanted to implement.
>
> what I am looking for is an object based / pythonic way to replace all
> those "for loops". it just seemed to me that the "for loops" only differ in
> the Win32_* class they call. so for example would i:
>
> * define a class Service() and a class Process () and put a method in each
> class that contained the above for loop.
> or
>
> * define a class Service() and a class Process() and a class Manager() and
> put the for loops in the Manager class
>
> now both of these ways strike me as being clumsy, so I was looking for a
> better way to represent this behaviour.
>
> thanks for you assistance tim.
>
> cheers
> mark
>
>
>
> On 11/03/2008, Tim Golden <[EMAIL PROTECTED]> wrote:
> >
> > mark.a.brand wrote:
> > > hi:
> > >
> > > i am new to python and wish but am writing a program as both a
> > learning
> > > experience and which may even get used if it is any good.
> >
> >
> > Welcome to the wonderful world of Python :)
> >
> >
> > > purpose of this program:
> > > is to retrieve and store (for historical purposes) system-info for
> > multiple
> > > clients about multiple windows servers using tim golden's
> >
> > > wmiwrapper. broadly the
> >
> > > algorithm is something like this.
> > >
> > > for each client
> > > for each server
> > > get-info(Win32_Process()))
> > > get-info(get-Win32_Service())
> > > ...
> > > ...
> > > write-system-info (to-a-db)
> > > endfor
> > > endfor
> >
> >
> > Not that it's necessarily wrong, but it's not clear why you're bothering
> > to pull server information from each client separately. It's not as
> > though the services running on Server S1 will appear different when
> > queried from client C1 and C2. But maybe there's something I'm missing.
> >
> > [... snip slightly confused post which seems to be mixing
> > RDBMS terminology and class queries ...]
> >
> > I'd love to help you out here, Mark, but it's not entirely clear
> > whether you're asking for advice on RDBMS structures (what tables
> > to use for the data) or class structures (how to fit the data
> > returned into classes).
> >
> > Wearing my database hat for a moment, it seems as though the
> > most obvious table structure from your description above is
> > (Noddy structure - I don't usually create a bunch of V(100 fields):
> >
> > CREATE TABLE
> >services
> > (
> >client VARCHAR (100),
> >server VARCHAR (100),
> >name VARCHAR (100),
> >status VARCHAR (100)
> > .
> > .
> > etc
> > )
> >
> > CREATE TABLE
> >processes
> > (
> >client VARCHAR (100),
> >server VARCHAR (100),
> >name VARCHAR (100),
> >status VARCHAR (100)
> > .
> > .
> > etc
> > )
> >
> > Now, if what you're saying is: hey, they all seem to have .Caption,
> > .Status, .Name attributes; surely some sort of denormalisation applies
> > here, then I would say: Beware. It's terribly tempting to create a
> > database-within-a-database without any real gain. Unless it's really
> > offering you something to create a wmi_objects table with 1:1
> > subordinates, don't do it.
> >
> > As to the class structure within Python, the same sort of caveats apply.
> > Use Python core data structures -- lists, dicts, sets, tuples -- as much
> > as you possibly can. They're simple and well-defined and they're
> > optimized to hell and back (not least since they're used by Python
> > itself as part of its internals). Don't feel you have to go around
> > creating hierarchies of classes just because you can!
> >
> > Anyway, if that wasn't what you were after, or if you want to explain
> > your plans further feel free to post 

Re: [python-win32] advice on architecting or program design in python:

2008-03-11 Thread Tim Golden
mark.a.brand wrote:
> hi:
> 
> i am new to python and wish but am writing a program as both a learning
> experience and which may even get used if it is any good.

Welcome to the wonderful world of Python :)

> purpose of this program:
> is to retrieve and store (for historical purposes) system-info for multiple
> clients about multiple windows servers using tim golden's
> wmiwrapper. broadly the
> algorithm is something like this.
> 
> for each client
> for each server
> get-info(Win32_Process()))
> get-info(get-Win32_Service())
> ...
> ...
> write-system-info (to-a-db)
> endfor
> endfor

Not that it's necessarily wrong, but it's not clear why you're bothering
to pull server information from each client separately. It's not as
though the services running on Server S1 will appear different when
queried from client C1 and C2. But maybe there's something I'm missing.

[... snip slightly confused post which seems to be mixing
RDBMS terminology and class queries ...]

I'd love to help you out here, Mark, but it's not entirely clear
whether you're asking for advice on RDBMS structures (what tables
to use for the data) or class structures (how to fit the data
returned into classes).

Wearing my database hat for a moment, it seems as though the
most obvious table structure from your description above is
(Noddy structure - I don't usually create a bunch of V(100 fields):

CREATE TABLE
   services
(
   client VARCHAR (100),
   server VARCHAR (100),
   name VARCHAR (100),
   status VARCHAR (100)
.
.
etc
)

CREATE TABLE
   processes
(
   client VARCHAR (100),
   server VARCHAR (100),
   name VARCHAR (100),
   status VARCHAR (100)
.
.
etc
)

Now, if what you're saying is: hey, they all seem to have .Caption,
.Status, .Name attributes; surely some sort of denormalisation applies
here, then I would say: Beware. It's terribly tempting to create a
database-within-a-database without any real gain. Unless it's really
offering you something to create a wmi_objects table with 1:1
subordinates, don't do it.

As to the class structure within Python, the same sort of caveats apply.
Use Python core data structures -- lists, dicts, sets, tuples -- as much
as you possibly can. They're simple and well-defined and they're
optimized to hell and back (not least since they're used by Python
itself as part of its internals). Don't feel you have to go around
creating hierarchies of classes just because you can!

Anyway, if that wasn't what you were after, or if you want to explain
your plans further feel free to post back.

TJG

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] advice on architecting or program design in python:

2008-03-11 Thread Tim Golden
mark.a.brand wrote:
> sorry - client as in customer

Ah. I see. (Didn't think of that :)

> i will try and explain better, but its not quite clear in my mind what is
> achievable ...
> 
> so to build up these database tables, i have to have some queries happening
> of the form :
> 
> for list in Win32_Process()
>  add instance to table-process
> 
> for list in Win32_Service()
>  add instance to table-service
> 
> ...
> etc etc for each Win32_* query i wanted to implement.
> 
> what I am looking for is an object based / pythonic way to replace all those
> "for loops". 

Certainly possible at several levels. There are a number
of ORM packages around, but the general favourite is probably
sqlalchemy [1] and its spin-off Elixir [2]. That said, there's
nothing to stop you working straight at the DBAPI [3] level
and calling .executemany against the tables you want.

Certainly you could have your table structure exactly mimic
the "column" structure of the corresponding WMI class and
push things along a bit that way. It's fairly trivial to
turn the WMI attribute values into a dictionary which could
then be passed on to something like Elixir's row-creation.


import os, sys
from elixir import *
import wmi

DB_FILENAME = os.path.abspath ("wmi.db")
metadata.bind = "sqlite:///%s" % DB_FILENAME

class Process (Entity):

   ProcessId = Field (Integer, primary_key=True)
   Caption = Field (Unicode (100))

if __name__ == '__main__':
   setup_all (True)
   c = wmi.WMI ()
   for process in c.Win32_Process (['ProcessId', 'Caption']):
 d = dict ((p, getattr (process, p)) for p in process.properties)
 Process (**d)

   session.flush ()
   session.close ()



Obviously, this is a mere stub but it does at least work
and might be a useful basis. There is definite scope for
factoring things out but you might do better just to have
a function which took -- or inferred -- the relevant class
and table names. YMMV.

> thanks for you assistance tim.

Glad to be of service

:)

TJG

[1] http://sqlalchemy.org
[2] http://elixir.ematia.de/trac/wiki
[3] http://www.python.org/dev/peps/pep-0249/

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] advice on architecting or program design in python:

2008-03-11 Thread mark.a.brand
Hi Tim:

So what you are saying is that it would be perfectly acceptable to have a
"for loop" for each Win32_* query and that  there is no good way to
generalise that behaviour.

eg.

class Process()
   ...
class Product()
  ...
class Event()
  ...
class Service()
   

if __name__ == '__main__':
  setup_all (True)
  c = wmi.WMI ()
  for process in c.Win32_Process (['ProcessId', 'Caption']):
d = dict ((p, getattr (process, p)) for p in process.properties)
Process (**d)

  for product in c.Win32_Products (['ProductId', 'Caption']):
d = dict ((p, getattr (process, p)) for p in product.properties)
Product (**d)

  for event in c.Win32_NTEvent (['EventId', 'Caption']):
d = dict ((p, getattr (event, p)) for p in event.properties)
Event (**d)

  for service in c.Win32_Service (['ServiceId', 'Caption']):
d = dict ((p, getattr (service, p)) for p in service.properties)
Service (**d)


  
  etc etc.
  session.flush ()
  session.close ()

Thanks for your patience.

Cheers
Mark

On 11/03/2008, Tim Golden <[EMAIL PROTECTED]> wrote:
>
> mark.a.brand wrote:
> > sorry - client as in customer
>
>
> Ah. I see. (Didn't think of that :)
>
>
> > i will try and explain better, but its not quite clear in my mind what
> is
> > achievable ...
> >
> > so to build up these database tables, i have to have some queries
> happening
> > of the form :
> >
> > for list in Win32_Process()
> >  add instance to table-process
> >
> > for list in Win32_Service()
> >  add instance to table-service
> >
> > ...
> > etc etc for each Win32_* query i wanted to implement.
> >
> > what I am looking for is an object based / pythonic way to replace all
> those
> > "for loops".
>
>
> Certainly possible at several levels. There are a number
> of ORM packages around, but the general favourite is probably
> sqlalchemy [1] and its spin-off Elixir [2]. That said, there's
> nothing to stop you working straight at the DBAPI [3] level
> and calling .executemany against the tables you want.
>
> Certainly you could have your table structure exactly mimic
> the "column" structure of the corresponding WMI class and
> push things along a bit that way. It's fairly trivial to
> turn the WMI attribute values into a dictionary which could
> then be passed on to something like Elixir's row-creation.
>
> 
> import os, sys
> from elixir import *
> import wmi
>
> DB_FILENAME = os.path.abspath ("wmi.db")
> metadata.bind = "sqlite:///%s" % DB_FILENAME
>
> class Process (Entity):
>
>ProcessId = Field (Integer, primary_key=True)
>Caption = Field (Unicode (100))
>
> if __name__ == '__main__':
>setup_all (True)
>c = wmi.WMI ()
>for process in c.Win32_Process (['ProcessId', 'Caption']):
>  d = dict ((p, getattr (process, p)) for p in process.properties)
>  Process (**d)
>
>session.flush ()
>session.close ()
>
> 
>
> Obviously, this is a mere stub but it does at least work
> and might be a useful basis. There is definite scope for
> factoring things out but you might do better just to have
> a function which took -- or inferred -- the relevant class
> and table names. YMMV.
>
>
> > thanks for you assistance tim.
>
>
> Glad to be of service
>
> :)
>
> TJG
>
> [1] http://sqlalchemy.org
> [2] http://elixir.ematia.de/trac/wiki
> [3] http://www.python.org/dev/peps/pep-0249/
>
>
> ___
> python-win32 mailing list
> python-win32@python.org
> http://mail.python.org/mailman/listinfo/python-win32
>
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] advice on architecting or program design in python:

2008-03-11 Thread mark.a.brand
Hi Tim:

Thanks, that was what I was after, but maybe you are right a couple of extra
for loops is not looking too bad after all.

Cheers
Mark

On 11/03/2008, Tim Golden <[EMAIL PROTECTED]> wrote:
>
> Tim Golden wrote:
> [... snip Elixir-based solution ...]
>
> I realise, rereading my post that it doesn't really solve
> your concern about multiple loops etc. I doubt it's really
> a problem, but in the spirit of the question, here's a raw
> sqlite solution, again Noddy and untested.
>
> You've said you're newish to Python and while
> there's no black magic here, I am being fairly free with
> generator expressions and getattr-fu. If you think the
> approach might be useful and need further explanation
> feel free to ask.
>
> 
> import os, sys
> import sqlite3
> import wmi
>
> os.remove ("c:/temp/wmi.db")
> db = sqlite3.connect ("c:/temp/wmi.db")
> classes_wanted = ["Win32_Process", "Win32_Service"]
>
> #
> # Generate a dictionary of class name -> WMI class
> #
> c = wmi.WMI ()
> wmi_classes = dict (
>(class_wanted, getattr (c, class_wanted)) \
>  for class_wanted in classes_wanted
> )
>
> #
> # Create a simplistic Sqlite table for each WMI
> # class with one (untyped) column per attribute.
> #
> for class_name, wmi_class in wmi_classes.items ():
>db.execute ("CREATE TABLE %s (%s)" % (
>  class_name,
>  ", ".join (p for p in wmi_class.properties)
>))
>
> db.commit ()
>
> #
> # For each WMI class, add all its instances as
> # rows to the corresponding sqlite table.
> #
> for class_name, wmi_class in wmi_classes.items ():
>db.executemany (
>  "INSERT INTO %s (%s) VALUES (%s)" % (
>class_name,
>", ".join (p for p in wmi_class.properties),
>", ".join ("?" for p in wmi_class.properties)
>  ),
>  [[getattr (c, p) for p in c.properties] for c in wmi_class ()]
>)
>
> db.commit ()
>
> 
>
> ___
> python-win32 mailing list
> python-win32@python.org
> http://mail.python.org/mailman/listinfo/python-win32
>
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] advice on architecting or program design in python:

2008-03-11 Thread Tim Golden
Tim Golden wrote:
[... snip Elixir-based solution ...]

I realise, rereading my post that it doesn't really solve
your concern about multiple loops etc. I doubt it's really
a problem, but in the spirit of the question, here's a raw
sqlite solution, again Noddy and untested.

You've said you're newish to Python and while
there's no black magic here, I am being fairly free with
generator expressions and getattr-fu. If you think the
approach might be useful and need further explanation
feel free to ask.


import os, sys
import sqlite3
import wmi

os.remove ("c:/temp/wmi.db")
db = sqlite3.connect ("c:/temp/wmi.db")
classes_wanted = ["Win32_Process", "Win32_Service"]

#
# Generate a dictionary of class name -> WMI class
#
c = wmi.WMI ()
wmi_classes = dict (
   (class_wanted, getattr (c, class_wanted)) \
 for class_wanted in classes_wanted
)

#
# Create a simplistic Sqlite table for each WMI
# class with one (untyped) column per attribute.
#
for class_name, wmi_class in wmi_classes.items ():
   db.execute ("CREATE TABLE %s (%s)" % (
 class_name,
 ", ".join (p for p in wmi_class.properties)
   ))

db.commit ()

#
# For each WMI class, add all its instances as
# rows to the corresponding sqlite table.
#
for class_name, wmi_class in wmi_classes.items ():
   db.executemany (
 "INSERT INTO %s (%s) VALUES (%s)" % (
   class_name,
   ", ".join (p for p in wmi_class.properties),
   ", ".join ("?" for p in wmi_class.properties)
 ),
 [[getattr (c, p) for p in c.properties] for c in wmi_class ()]
   )

db.commit ()


___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] advice on architecting or program design in python:

2008-03-11 Thread Tim Golden
mark.a.brand wrote:
> Hi Tim:
> 
> Thanks, that was what I was after, but maybe you are right a couple of extra
> for loops is not looking too bad after all.

The code looks a little scary at first sight but it's
not that bad ;)

It's one of those things everyone learns to weigh up when
they're putting together code / data. How "clever" do I
try to be. Sometimes there's clear benefit (or at least
no clear disadvantage). Other times it's the result of
overengineering -- and often up front. You may find, for
example, that the .executemany in the sqlite example gives
a performance benefit over Elixir's more explicit looping,
but you might not (or it might not be significant). Go
with what's clearest first, then look for optimisations where
you really need them.

[One of] The great thing[s] about Python is that refactoring
is usually really easy. The two solutions I outlined did
(broadly) the same thing. You could make them even more
similar with a little work. Each one is only a couple of
dozens of lines of code. If you started with one and decided
later that the other was preferable, it would be really simple
to swap one out and the other in. Obviously, it's not always
that easy but it's certainly easi*er*.

Good luck with the project. Do come back for more help
(or hindrance).

TJG
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] advice on architecting or program design in python:

2008-03-11 Thread mark.a.brand

Python is that refactoring is usually really easy.


thats a good thing to know.

i was originally going to just start out the naive way and refactor as
python became more familiar. i think that approach may work  best for me -
take baby steps and refactor as i my knowledge and experience grows.

thanks again
mark





On 12/03/2008, Tim Golden <[EMAIL PROTECTED]> wrote:
>
> mark.a.brand wrote:
> > Hi Tim:
> >
> > Thanks, that was what I was after, but maybe you are right a couple of
> extra
> > for loops is not looking too bad after all.
>
>
> The code looks a little scary at first sight but it's
> not that bad ;)
>
> It's one of those things everyone learns to weigh up when
> they're putting together code / data. How "clever" do I
> try to be. Sometimes there's clear benefit (or at least
> no clear disadvantage). Other times it's the result of
> overengineering -- and often up front. You may find, for
> example, that the .executemany in the sqlite example gives
> a performance benefit over Elixir's more explicit looping,
> but you might not (or it might not be significant). Go
> with what's clearest first, then look for optimisations where
> you really need them.
>
> [One of] The great thing[s] about Python is that refactoring
> is usually really easy. The two solutions I outlined did
> (broadly) the same thing. You could make them even more
> similar with a little work. Each one is only a couple of
> dozens of lines of code. If you started with one and decided
> later that the other was preferable, it would be really simple
> to swap one out and the other in. Obviously, it's not always
> that easy but it's certainly easi*er*.
>
> Good luck with the project. Do come back for more help
> (or hindrance).
>
> TJG
>
> ___
> python-win32 mailing list
> python-win32@python.org
> http://mail.python.org/mailman/listinfo/python-win32
>
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] embedding IPython in a windows dll

2008-03-11 Thread mani sabri


>-Original Message-
>From: [EMAIL PROTECTED] [mailto:python-win32- 
>[EMAIL PROTECTED] On Behalf Of Tim Roberts mani sabri wrote:
>> I want to run a Python shell from a DllMain() function.
>
>It isn't safe to do this much processing in a DllMain.  There is a 
>thing called the "loader lock" that is held while DllMain is called, 
>and it can prevent you from loading other DLLs.  You might try spinning 
>off a thread to do your real work.
>
>

Wow thanks,I'll difinitly use a thread. Do have any link to a sample code or
some keywords for google?

>>  freopen("CONOUT$","w",stdout);
>>  freopen("CONIN$","w",stdin);
>>  freopen("CONERR$","w",stderr);
>>
>
>Do you really think "w" is correct for all three of those?
>
>>  FILE* afile = fopen("CONOUT$", "w+");
>>  FILE* bfile = fopen("CONIN$", "w+");
>
>Again, do you really think you want "w+ for both of these?  How much 
>writing will you do to stdin?
>
>>  PySys_SetObject("stdin", PyFile_FromFile(bfile, "CONIN$","wb", 
>> fclose));
>
>Again, you're probably going to want to read from stdin, not write to 
>it.

Thanks a lot. I'm sure I'll never forget that.

>  And you don't really need to do the fopen yourself:
>
>PyFileObject* xout = PyFile_FromString( "CONOUT$", "wb" );
>PyFileObject* xin = PyFile_FromString( "CONIN$", "rb" );
>PySys_SetObject( "stdout", xout );
>PySys_SetObject( "__stdout__", xout );
>PySys_SetObject( "stdin", xin );
>PySys_SetObject( "__stdin__", xin );

And this, I was not able to compile it[1] until I changed it a little
bit[2].

[1] It was 6 errors, first and seconed line of the kind:
expertsample.cpp(85) : error C2440: 'initializing' : cannot convert from
'PyObject *' to 'PyFileObject *'
Types pointed to are unrelated; conversion requires reinterpret_cast,
C-style cast or function-style cast

And the remaining four of the kind:
expertsample.cpp(87) : error C2664: 'PySys_SetObject' : cannot convert
parameter 2 from 'PyFileObject *' to 'PyObject *'
Types pointed to are unrelated; conversion requires reinterpret_cast,
C-style cast or function-style cast

[2] So I changed the code to:

PyFileObject* xout = (PyFileObject*)PyFile_FromString("CONOUT$","wb");
PyFileObject* xin = (PyFileObject*)PyFile_FromString( "CONIN$", "rb" );
PySys_SetObject( "stdout", (PyObject*)xout ); PySys_SetObject( "__stdout__",
(PyObject*)xout ); PySys_SetObject( "stdin", (PyObject*)xin );
PySys_SetObject( "__stdin__", (PyObject*)xin );

But still no output after a PyRun_SimpleString("print 'Hello from
python'\n");

>--
>Tim Roberts, [EMAIL PROTECTED]
>Providenza & Boekelheide, Inc.

Best regards,
Mani

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] How to create a com_record?

2008-03-11 Thread Kevin Patterson
Old thread, but I got a little more data on the function. The function
actually has a REFIID as the first parameter. This apparently is a standard
structure for C COM code.  I'm not entirely sure why the win32com changes
the REFIID to be a VT_RECORD. Does the following definition of the functions
help at all (they are from the IDL file)

HRESULT GetInterface( [in] REFIID riid, [out, retval, iid_is(riid)]
IUnknown** ppUnknown);
should be same as:
HRESULT GetInterface( [in] GUID* pGuid, [out, retval, iid_is(pGuid)]
IUnknown** ppUnknown);


On Mon, Feb 4, 2008 at 6:44 PM, Mark Hammond <[EMAIL PROTECTED]>
wrote:

> > guid = win32com.client.Record("GUID", some_ob)
>
> > I don't have the some_obj that allows me to build "GUID".
>
> It should be any object from the same typelib - almost certainly whatever
> object you intend passing this record to.
>
> > VB.NET (GetType) and C++ (__uuid) both already know that a GUID is a
> record.
>
> C++ doesn't know it is a COM record.  A COM record is something quite
> different to a C/C++ struct or from .NET types.  A COM record is
> specifically designed to be cross-language.
>
> > It seems the python CLSID is the same thing, but i don't know what to
> call
>
> > to get a CLSID that is a com_record type.
>
> As I've explained, we are looking for the COM record definition you are
> trying to use.  A C++ struct definition for a GUID is *not* what you are
> looking for - you are looking for the COM record definition of a GUID.  I
> see now that you simply copied me a C++ struct you found, which is not at
> all useful in this context.
>
> To clarify: in a *typelib* you will find a struct definition that you are
> trying to use.  Finding a struct definition of the same name somewhere
> else
> is not suitable.
>
> > Am I understanding the win32com.client.Record call correctly? It needs
> GUID to be defined by the
> > COM right?
>
> Not "defined by COM", but "defined using COM" - the author of a typelib
> must
> have defined it somewhere.
>
> > Its odd b/c the GIUD (python's CLSID) is all over the COM definitions
> its
> just type
> > VT_RECORD type that I'm not understanding how to convert to.
>
> Yes, I'm afraid you are confused.  All existing GUID or CLSID definitions
> you can find are useless - there is only 1 that is relevant, and that will
> be defined in a typelib.
>
> I think the confusion is such that you need to find basic docs for the
> object, so we can get back to square 1.
>
> Mark
>
>
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] win32gui.EnumWindows, documentation?

2008-03-11 Thread Julius
Hi,

im new to python in generell and was wondering where i would find the
api to win32gui.EnumWindows?
I know one of its arguments is a callback function, but i cant find any
information how it should look like?

Is this another win32 python implementation or is the site just called
activestate? Ive installed Mark Hammond's win32 extensions
http://aspn.activestate.com/ASPN/docs/ActivePython/2.2/PyWin32/win32gui__EnumWindows_meth.html




Julius

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] win32gui.EnumWindows, documentation?

2008-03-11 Thread Rickey, Kyle W
I like using lambda for this, but you could also put it into a function.

windows = []
win32gui.EnumWindows(lambda hwnd, resultList: resultList.append(hwnd),
windows)

This will populate windows with all the hwnds.

-Kyle Rickey

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Julius
Sent: Tuesday, March 11, 2008 5:00 PM
To: python-win32@python.org
Subject: [python-win32] win32gui.EnumWindows, documentation?

Hi,

im new to python in generell and was wondering where i would find the
api to win32gui.EnumWindows?
I know one of its arguments is a callback function, but i cant find any
information how it should look like?

Is this another win32 python implementation or is the site just called
activestate? Ive installed Mark Hammond's win32 extensions
http://aspn.activestate.com/ASPN/docs/ActivePython/2.2/PyWin32/win32gui_
_EnumWindows_meth.html




Julius

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] win32gui.EnumWindows, documentation?

2008-03-11 Thread Julius
My fault(already got that one running), i meant the 
win32gui.EnumChildWindows(currentHwnd, windowEnumerationHandler,
childWindows)
function.

from what i understand the purpose of this function is to return the
childwindows from a top window - if this is right why not just pass a
topwindow as argument and return a list of childwindows?



On Tue, 2008-03-11 at 17:04 -0500, Rickey, Kyle W wrote:
> I like using lambda for this, but you could also put it into a function.
> 
> windows = []
> win32gui.EnumWindows(lambda hwnd, resultList: resultList.append(hwnd),
> windows)
> 
> This will populate windows with all the hwnds.
> 
> -Kyle Rickey


> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Julius
> Sent: Tuesday, March 11, 2008 5:00 PM
> To: python-win32@python.org
> Subject: [python-win32] win32gui.EnumWindows, documentation?
> 
> Hi,
> 
> im new to python in generell and was wondering where i would find the
> api to win32gui.EnumWindows?
> I know one of its arguments is a callback function, but i cant find any
> information how it should look like?
> 
> Is this another win32 python implementation or is the site just called
> activestate? Ive installed Mark Hammond's win32 extensions
> http://aspn.activestate.com/ASPN/docs/ActivePython/2.2/PyWin32/win32gui_
> _EnumWindows_meth.html
> 
> 
> 
> 
> Julius

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] win32gui.EnumWindows, documentation?

2008-03-11 Thread Tim Roberts
Julius wrote:
> My fault(already got that one running), i meant the 
> win32gui.EnumChildWindows(currentHwnd, windowEnumerationHandler,
> childWindows)
> function.
>
> from what i understand the purpose of this function is to return the
> childwindows from a top window - if this is right why not just pass a
> topwindow as argument and return a list of childwindows?
>   

Windows APIs don't ever return lists of things, because it present a 
memory management difficulty.  Who allocates, who owns, who releases, 
etc.  Instead, they all use the "enumeration callback" concept.  That 
way, if you want a list, you can construct and maintain it yourself.

If you just want the list of handles, you can do something like this:
childlist = []
win32ui.EnumChildWindows( hwnd, lamba hwnd,oldlist: oldlist.append( 
hwnd ), childlist )

-- 
Tim Roberts, [EMAIL PROTECTED]
Providenza & Boekelheide, Inc.

___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] win32gui.EnumWindows, documentation?

2008-03-11 Thread Tim Golden
Julius wrote:
> Hi,
> 
> im new to python in generell and was wondering where i would find the
> api to win32gui.EnumWindows?
> I know one of its arguments is a callback function, but i cant find any
> information how it should look like?
> 
> Is this another win32 python implementation or is the site just called
> activestate? Ive installed Mark Hammond's win32 extensions
> http://aspn.activestate.com/ASPN/docs/ActivePython/2.2/PyWin32/win32gui__EnumWindows_meth.html

There's a worked example here:

http://timgolden.me.uk/python/win32_how_do_i/find-the-window-for-my-subprocess.html

(which may or may not ease your problems!)

TJG
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] How to create a com_record?

2008-03-11 Thread Kevin Patterson
I found the comtypes equivalent if that helps any. The generated comtypes
file looks like this:

   COMMETHOD([dispid(1610743812), helpstring(u'GetInterface() method')],
HRESULT, 'GetInterface',
  ( ['in'], POINTER(GUID), 'riid' ),
  ( ['retval', 'out'], POINTER(POINTER(IUnknown)), 'ppUnknown'
)),

With the above, I'm able to use the comtypes.GUID.GUID structure to pass the
information over through the COM. Unfortunately I still can't find the
win32com equivalent of passing my structure through the COM.

The win32com generated py file is saying that it expects a VT_RECORD, but
from above, maybe it should really be expecting a POINTER ? or VT_POINTER ?
I tried to modify the win32com generated file to take a VT_PTR but that
didn't seem to help. I really don't want to redo my infastructure in
comtypes, so if anyone knows the win32com equivalent, that would be awesome.

In the meantime, I'll keep digging, and will post if I find more.


On Tue, Mar 11, 2008 at 12:58 PM, Kevin Patterson <[EMAIL PROTECTED]>
wrote:

> Old thread, but I got a little more data on the function. The function
> actually has a REFIID as the first parameter. This apparently is a standard
> structure for C COM code.  I'm not entirely sure why the win32com changes
> the REFIID to be a VT_RECORD. Does the following definition of the functions
> help at all (they are from the IDL file)
>
> HRESULT GetInterface( [in] REFIID riid, [out, retval, iid_is(riid)]
> IUnknown** ppUnknown);
> should be same as:
> HRESULT GetInterface( [in] GUID* pGuid, [out, retval, iid_is(pGuid)]
> IUnknown** ppUnknown);
>
>
>
> On Mon, Feb 4, 2008 at 6:44 PM, Mark Hammond <[EMAIL PROTECTED]>
> wrote:
>
> > > guid = win32com.client.Record("GUID", some_ob)
> >
> > > I don't have the some_obj that allows me to build "GUID".
> >
> > It should be any object from the same typelib - almost certainly
> > whatever
> > object you intend passing this record to.
> >
> > > VB.NET (GetType) and C++ (__uuid) both already know that a GUID is a
> > record.
> >
> > C++ doesn't know it is a COM record.  A COM record is something quite
> > different to a C/C++ struct or from .NET types.  A COM record is
> > specifically designed to be cross-language.
> >
> > > It seems the python CLSID is the same thing, but i don't know what to
> > call
> >
> > > to get a CLSID that is a com_record type.
> >
> > As I've explained, we are looking for the COM record definition you are
> > trying to use.  A C++ struct definition for a GUID is *not* what you are
> > looking for - you are looking for the COM record definition of a GUID.
> >  I
> > see now that you simply copied me a C++ struct you found, which is not
> > at
> > all useful in this context.
> >
> > To clarify: in a *typelib* you will find a struct definition that you
> > are
> > trying to use.  Finding a struct definition of the same name somewhere
> > else
> > is not suitable.
> >
> > > Am I understanding the win32com.client.Record call correctly? It needs
> > GUID to be defined by the
> > > COM right?
> >
> > Not "defined by COM", but "defined using COM" - the author of a typelib
> > must
> > have defined it somewhere.
> >
> > > Its odd b/c the GIUD (python's CLSID) is all over the COM definitions
> > its
> > just type
> > > VT_RECORD type that I'm not understanding how to convert to.
> >
> > Yes, I'm afraid you are confused.  All existing GUID or CLSID
> > definitions
> > you can find are useless - there is only 1 that is relevant, and that
> > will
> > be defined in a typelib.
> >
> > I think the confusion is such that you need to find basic docs for the
> > object, so we can get back to square 1.
> >
> > Mark
> >
> >
>
___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32