Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Event Notification...

29 views
Skip to first unread message

Mauro

unread,
Sep 17, 2001, 10:24:13 AM9/17/01
to
Ciao
I have a problem with Event Notification.
I want to be notified when new devices are inserted into the PC. So, the
first
thing I thought about, was of issuing a query:

SELECT * FROM __InstanceCreationEvent WITHIN 10 WHERE TargetInstance ISA
"CIM_LogicalDevice"

As it is issued from a Service, which auto-starts, I noticed following
behaviour:

- when the pc starts, i am notified about every devices is being added
(maybe it's because the providers load infos and notify me)
- after the first 10 seconds I am notified about the creation of all
instances
of Win32_LogicalDisk
- every 10 seconds the floppy drive "makes noise", being accessed.
This is the same behaviour as enumerating Instances of Win32_LogicalDisk.
- If I don't cancelAsynchCall (for example because my program crashes),
the floppy continues to "make noise" every 10 seconds even if the program
is not running anymore.

So is there a way to monitor all new devices without having this noisy
behaviour? In fact monitoring Win32_PNPEntity is a partial solution,
even if it's not complete....
If I monitor just Win32_LogicalDisk, I get the same behaviour...
Some hints?
Thanks in advance,
mauro

Raman (Microsoft WMI Dev Support)

unread,
Sep 19, 2001, 10:35:22 AM9/19/01
to
WMI relies on components called providers (basically com dll's) to
accomplish tasks. Among the different kinds of providers are Event
providers. They supply event notifications to wmi when something interesting
happens to classes they manage. But most classes dont have event providers
associated with them. In that case when you execute an event query, wmi has
to do the work and generate events.

Basically wmi takes snapshots of instances at the beginning and end of the
polling interval (in your case 10 seconds), compares the instances and
generates events if the changes match the event query. Hence the reason you
see your floppy drive being accessed every 10 seconds, since wmi is in
effect enumerating all instances of Win32_LogicalDisk every polling
interval.

If you know of any other method (say win32 api calls) that would give you
these notifications then you could potentially wrap that functionality in a
wmi event provider and generate appropriate notifications.

--
Raman
Microsoft WMI Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. © 2001 Microsoft Corporation. All rights
reserved.

"Mauro" <mauro@me> wrote in message news:edUBuR4PBHA.1568@tkmsftngp03...

Thomas Wenzl

unread,
Sep 19, 2001, 6:20:47 PM9/19/01
to
Hello Raman,

when does WMI "refresh" his repository. New devices are generally
add after a shutdown of the system.

When I restart my system the new components have already been added to the
repository. So I can't get event notifications about new devices, can I?

Am I only be able to get notifications about removed devices? (for example with
__instanceDeletionEvent?)

Thank you very much in advance!!

Bye,

Thomas :-))

"Raman (Microsoft WMI Dev Support)" <graman...@microsoft.com> schrieb im
Newsbeitrag news:epuzShRQBHA.2092@tkmsftngp05...

Raman (Microsoft WMI Dev Support)

unread,
Sep 20, 2001, 11:14:05 AM9/20/01
to
Yes you are right. You most likely wont get event notifications for devices
added after a shutdown. If you add devices while the system is in operation,
then wmi while doing enumerations would notice the new instance and generate
appropriate notifications.

Also you can use __InstanceDeletionEvent if you want to be notified when
devices get deleted.

--
Raman
Microsoft WMI Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. © 2001 Microsoft Corporation. All rights
reserved.

"Thomas Wenzl" <twe...@web.de> wrote in message
news:9ob5lo$bp3ml$1...@ID-91550.news.dfncis.de...

0 new messages