Is Powerpoint still a single instance app?

H

Howard Kaikow

All I need to be able to do is detect whether my code needs to create a NEW
PowerPoint.

Then, when deciding whether to Quit, check the number of processes being
used by PPT. This is independent of PPT.

I've been distracted the past few daze, so I've not yet finished the
solution.
Expect to do so by week's end.
 
H

Howard Kaikow

Are you referring to KB article 249169?

Not sure whether that applies.

I'd be using New to create the instance.
Guess I'll find out, but first I will get the code working with PPT 2003,
then test 97, 2000 and 2002.

At worst, if I know that I want to Quit, I should think that I'd be able to
kill the process via the API.
 
M

Mike M.

I was just referring to a co-worker's and my trial and error testing. Lots
of both. Just keep it in mind.

Since there is one and only one process named powerpnt.exe running I am not
sure how enumerating process is going to help. How will you determine what
process created the instance? Or are you looking for the existance of the
PowerPoint GUI?
 
H

Howard Kaikow

Mike M. said:
Since there is one and only one process named powerpnt.exe running I am not
sure how enumerating process is going to help. How will you determine what
process created the instance? Or are you looking for the existance of the
PowerPoint GUI?

I am investigating 2 structures.

PROCESSENTRY32 has a cntUsage member that is supposed to return the "Number
of references to the process". However, thus far, I've only been getting 0,
so I may not be yet correctly using the structure.

MODULEENTRY32 has a member GlblcntUsage which returns the "Global usage
count on the module" for the specified process; and there is a ProccntUsage
member which returns the "Module usage count in the context of the owning
process".

In order to access MODULEENTRY32, I have to use the Module32First and
Module32Next APIs. So far, I've not ben able to get those APIs to return a
success code.

I attacked this problem by attempting to translate C code to VB 6. I've not
done much with C, especially recently, so I likely screwed up somewhere.

My model is the following two articles in the MSDN library. You can find
them by searching for Module32First, among other ways. The articles are
included in the documentation for VS .NET 2003 and in the Oct 2001 MSDN
library.

One article is "Traversing the Module List", the other is "Taking a Snapshot
and Viewing the Process".

I may try plopping the code into VS C++ .NET to see if I can get the pure C
code to work.
 
M

Mike M.

Please keep us informed if one of these works for you. I would like to be
more forgiving when closing PowerPoint as opposed to my, "You are done now"
approach.

Thanks.
 
H

Howard Kaikow

I've really gone overboard.

I recalled that I have an old copy of MSFT Visual C++ 6 learning addition on
another system.

So I went to the MSDN site and downloaded the articles to try to get that C
code to run.

My first discovery was that the article at MSFT's MSDN site is significantly
different than the article I was using, so there was perhaps an error in the
earlier verion of the article that had caused my grief in trying to get the
critter to run in VB 6 and VB .NET.

Well, I managed to get the code to compile in C ++ 6, but I have not a clue
as to how to add a Form in C++ 6 and the output is rather unreadable as I
converted all the printf to std::cout.

So, I then rebooted to my real system and managed to import the workspace
into VS .NET C++.

However, .NET won't let me add a Form unless I convert the project from
Unmanaged to Managed. I have no clue on how to do that. Fortunately, I do
have a C++ book for .NET, so I'll take a look at that.

Of course, I'll still get the C# books (I'm leaning towards getting the
Liberty book and the Step By Step), as I will sill convert the critter to
C#, VB .NET and VB 6.

Hmm, I better hide, I think I see the men in the white coats coming!
 
H

Howard Kaikow

I feel like I belong in a room with padded walls.

In any case, here's where I am at.

1. I downloaded the latest version of the base article that uses C code with
the structures I am investigating. The URLs are::

http://msdn.microsoft.com/library/d...e/taking_a_snapshot_and_viewing_processes.asp


http://msdn.microsoft.com/library/d...s/perfmon/base/traversing_the_module_list.asp

Do NOT use the articles from the earlier MSDN libraries, such as the Oct
2001 library. They differ, so there may have been an error in the earlier
versions.

2. Although, I 've not really used Visual C++ .NET before, I seem to have
gotten the code running in C++ .NET.

One problem tho, the project was automatically created as an unmanaged
project, so I am unable to add a Form to the project, so it is just a
console app, making it very dificult to examine the output.

I may be able to create an empty managed project and copy the code there.
I'll try that later.

I need to buy a book that tells me how to create various C++ .NET projects.
There are way too many combinations available.

3. I've gone this far and still intend to convert the code to C#, VB .NET
and VB 6.

Once I get all those variants, I'll allow others to check out the code to
see whether I've done things right.

Preliminary evidence is that PowerPoint does not make the usage counts
available via the two structures I've been examining, but I do not yet
accept that as a definitive answer.

a. I could have messed up something converting from C to C++.
b. I'd like to get the concurrence of others.
c. There may be another way, of which I am not yet aware, to get the usage
counts.
 
H

Howard Kaikow

i managed to add a Form, by creating a new C++ project and copying the code.

Now, I think I have to change public stuff to private stuff so I can access
the controls in the code.
this-> does not work in public procedure.
 
M

Mike M.

Sounds like you have your hands full. I only use Visual c++ 6.0. I haven't
been given the opportunity to use .NET yet. In my c++ apps I create a
logging class/function to write all of my debugging info to a file. That is
easier than trying to watch it scroll past in a control or the output
window. You should also be able to compile a debug version and step through
the code. You won't be able to poke into the structures you are looking at
since they are probably COM interfaces. However, you can assign the
structure values returned to local variables and then look at them. If I
wasn't so busy I would try to look at the structures you mentioned. I will
have to wait for some quiet time before I can do that. I anticipate that in
about 25 years. ;-)

Be advised that some of the COM interfaces are somewhat wacky. All of the
help is in VB parlance and you have to sort of guestimate into c++ or look
at the generated .tlh and tli files after including the PowerPoint type
library.

Good luck.
 
H

Howard Kaikow

Mike M. said:
Sounds like you have your hands full. I only use Visual c++ 6.0. I haven't
been given the opportunity to use .NET yet. In my c++ apps I create a
logging class/function to write all of my debugging info to a file. That is
easier than trying to watch it scroll past in a control or the output
window. You should also be able to compile a debug version and step through
the code. You won't be able to poke into the structures you are looking at
since they are probably COM interfaces. However, you can assign the
structure values returned to local variables and then look at them. If I
wasn't so busy I would try to look at the structures you mentioned. I will
have to wait for some quiet time before I can do that. I anticipate that in
about 25 years. ;-)

Be advised that some of the COM interfaces are somewhat wacky. All of the
help is in VB parlance and you have to sort of guestimate into c++ or look
at the generated .tlh and tli files after including the PowerPoint type
library.

Good luck.

What are .tlh and .tli files?
There are no such critters in the .NET project's directories.

Powerpoint, itself, has no effect on the code, other than the code detecting
"powerpnt.exe".

I have possible good news, but first.

I purchased MSFT C/C++, I guess it was version 5, about 7-0 years ago, when
I decideed to try my hand woth WLLs in Office 95.

Very shortly after that purchase, MSFT released/announced Office 97, so I
ditched the idea of using C/C++ and got VB 5 Learning edition, and then VB 6
Enterprise.

I also have MSFT Visual C/C++ 6 Learning edition, indeed I have two copies,
that came with books. This helped because I was abe to compile and then
import the workspace into .NET.

However, I have NO Visual C/C++ 6 books that talk about Forms. Heck one of
the books EXPLICITLY states that ALL examples will be for console
applications.

A difficulty is that the single C++ .NET book I have was for VS .NET 2002
and it had nothing about Windows forms for C++, and almost nothing about
Managed software,

In recent daze, I've been plodding thru MSDN, the KB, the Help, etc..
There's (relatively) very little for C++, everything is for C# and VB .NET.

Yesterday, I ordered Kate Gregory's book, hope that helps in the future, as
I do expect that there will be other times I wish to see how particular
C/C++ works.

I thought about throwing the info into a file, but I wanted to use a Form,
and ever the masochist, I do intend to convert the code to C#, VB .NET and
VB 6.

Now for the good news.

The structures are directly addressable, as are most structures used in the
API. That's the easy part.

As I stated in recent daze, the usage count for powerpnt.exe does not seem
to get updated, but now that I can output to a Form, I can better see the
results.

Many/all of the modules associated with powerpnt.exe do expose usage counts.
I would hope/expect that one of those DLLs will reveal what I've been after.

Now that I better understand what the code does, I'm going to try to do the
following, which is expedited by having a Form.

1. Let the code merrily plod along listing processes in a listbox.
2. When the code finds the powerpoint process, clear the listbox, output the
powerpoint info and terminate the loop.
3. Output the content of the list to a file.
4. Run the program with 1, 2, and 3 powerpoint objects running and hope!
 
M

Mike M.

Howard Kaikow said:
What are .tlh and .tli files?
There are no such critters in the .NET project's directories.

These are include files generated by Visual studio when you import a type
library. They are similar to standard header files that define the
classes, functions and paramaters for the interface (Powerpoint in this
case).
Powerpoint, itself, has no effect on the code, other than the code detecting
"powerpnt.exe".

I have possible good news, but first.

I purchased MSFT C/C++, I guess it was version 5, about 7-0 years ago, when
I decideed to try my hand woth WLLs in Office 95.

Very shortly after that purchase, MSFT released/announced Office 97, so I
ditched the idea of using C/C++ and got VB 5 Learning edition, and then VB 6
Enterprise.

I also have MSFT Visual C/C++ 6 Learning edition, indeed I have two copies,
that came with books. This helped because I was abe to compile and then
import the workspace into .NET.

However, I have NO Visual C/C++ 6 books that talk about Forms. Heck one of
the books EXPLICITLY states that ALL examples will be for console
applications.

A difficulty is that the single C++ .NET book I have was for VS .NET 2002
and it had nothing about Windows forms for C++, and almost nothing about
Managed software,

In recent daze, I've been plodding thru MSDN, the KB, the Help, etc..
There's (relatively) very little for C++, everything is for C# and VB ..NET.

Yesterday, I ordered Kate Gregory's book, hope that helps in the future, as
I do expect that there will be other times I wish to see how particular
C/C++ works.

I thought about throwing the info into a file, but I wanted to use a Form,
and ever the masochist, I do intend to convert the code to C#, VB .NET and
VB 6.

Now for the good news.

The structures are directly addressable, as are most structures used in the
API. That's the easy part.

As I stated in recent daze, the usage count for powerpnt.exe does not seem
to get updated, but now that I can output to a Form, I can better see the
results.

Many/all of the modules associated with powerpnt.exe do expose usage counts.
I would hope/expect that one of those DLLs will reveal what I've been after.

Now that I better understand what the code does, I'm going to try to do the
following, which is expedited by having a Form.

1. Let the code merrily plod along listing processes in a listbox.
2. When the code finds the powerpoint process, clear the listbox, output the
powerpoint info and terminate the loop.
3. Output the content of the list to a file.
4. Run the program with 1, 2, and 3 powerpoint objects running and hope!
When I want to use a form I let MFC do the work. In Visual Studio you view
the workspace (explorer like area on left) and click on the resources tab.
Expand that, right click the item Dialog and then select new. This adds a
modal dialog that you can reference and show and place controls on.

Good luck.
 
H

Howard Kaikow

Mike M. said:
These are include files generated by Visual studio when you import a type
library. They are similar to standard header files that define the
classes, functions and paramaters for the interface (Powerpoint in this
case).

I've not seen any of those with C++ .NET.
When I want to use a form I let MFC do the work. In Visual Studio you view
the workspace (explorer like area on left) and click on the resources tab.
Expand that, right click the item Dialog and then select new. This adds a
modal dialog that you can reference and show and place controls on.

I guess that's for pre C++ .NET.

Ran into a major issue trying to use ofstream.

I just could not get code running in C++ .NET 2003 yesterday.
Today, I found out, the hard way, why.

I created a project in C++ V6, np problem getting code running.
I then import into C++ .NET 2002, no problem getting code running, but, and
I do have a big butt, there was a warning that the stream stuff was
deprecated.

I then impor the c++ .NET 2002 into C++ .NET 2003.
Code no longer works.
I found an article that points out that, among others, fstream.h and
iostream.h have to be replaced without the ".h", but that's not enough.

I posed a query in the .NET C newsgroup.

In addition to Kate Gregory's book, I ordered C++ Step by Step, maybe the
answers will lie there.
Probably requires some sort of namespace hanky panky.
You'd think that for such a serious deprecation/removal of a library,
there'd be a clear example of a BEFORE and an AFTER. If tere is, I've not
yet found it.
 
H

Howard Kaikow

Eureka, I think!

I believe that I can demonstrate how to detect whether there is 1, or more
than 1, use of Powerpoint, but I want to convert the code to C#, then VB
..NET, then VB 6 before I post a test.

This was interesting, but exhausting.
 
M

Mike M.

Yes. That deserves a nice pint. And now we can digress to a discussion on
which is better, English ales or Australian lagers. With lots of taste
testing everyone comes out a winner. ;-)

Cheers Howard.
 
H

Howard Kaikow

Steve Rindsberg said:
Whether it works or not, extra points and a Gold Persistence Pin to you for
gnawing at it this long!

I just started convberting the C++ to C#, not as easy as I thought it would
be.

I'm going to dumb out my brain by watching Charlie's Angels on TV tonight!
 
H

Howard Kaikow

Mike M. said:
Yes. That deserves a nice pint. And now we can digress to a discussion on
which is better, English ales or Australian lagers. With lots of taste
testing everyone comes out a winner. ;-)

I've not had a drink since May 1994.

FYI:

When a second use of PPT is started the PPT thread count increases by 1
and, most interestingly, one of the previous threads is replaced by two
threads. This does not change if a 3rd use is started, so it would appear
that one thread is associated with the actual PPT instance, whilst the other
monitors the (other) uses.

Usage counts are not changed,
 
M

Mike M.

Hmm, that sounds somewhat nebulous. It will be surprising if the different
versions of PPT work the same way.
 
H

Howard Kaikow

Mike M. said:
Hmm, that sounds somewhat nebulous. It will be surprising if the different
versions of PPT work the same way.

Actually, it makes perfect sense.
In time, we'll find out.

PPT has to have SOMETHING monitoring the uses.
Usage counts are changed on oleaut32.dll and msi.dll and userenv.dll, but
only when the 2nd use is added, not the 3rd. Of course, one cannot use those
usage counts because they apply to other than PPT as well.
 
H

Howard Kaikow

I'm going to dumb out my brain by watching Charlie's Angels on TV tonight!

Egad!

I'd forgotten that I had already seen the Charlie's Angels move and just how
bad it was.
I've seen few movies that were worse.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top