Professional IronPython



Download 20,35 Mb.
Pdf ko'rish
bet206/453
Sana01.07.2022
Hajmi20,35 Mb.
#723045
1   ...   202   203   204   205   206   207   208   209   ...   453
188

CHAPTER 9
InteractIng wIth cOM Objects
if MyBits.__and__(0x20) == 0x20:
print(‘\tAutorun Disabled for CD-ROM Drives’)
else:
print(‘\tAutorun Enabled for CD-ROM Drives’)
if MyBits.__and__(0x40) == 0x40:
print(‘\tAutorun Disabled for RAM Disk Drives’)
else:
print(‘\tAutorun Enabled for RAM Disk Drives’)
# Pause after the debug session.
raw_input(‘Press any key to continue...’)
This example starts by showing a different kind of 
import
call. In this case, the 
import
retrieves 
only the 
Activator
and 
Type
classes from the 
System
assembly. Using this approach reduces envi-
ronmental clutter. In addition, using this technique reduces the memory requirements for your appli-
cation and could mean the application runs faster. The example also imports the 
time
module.
The first step in this application can seem a little complicated so it pays to break it down into two 
pieces. First, you must get the type of a particular object by using its identifier within the registry 
with the 
Type.GetTypeFromProgID()
method. As previously mentioned, the object used in this 
example is 
Shell.Application
. After the code obtains the type, it can create an instance of the 
object using 
Activator.CreateInstance()
.
The 
Shell.Application
object, 
ShObj
, provides several interesting methods and this example 
works with three of them. The first method, 
ToggleDesktop()
, provides the same service as click-
ing the Show Desktop icon in the Quick Launch toolbar. Calling 
ToggleDesktop()
the first time 
shows the desktop, while the second call restores the application windows to their former appear-
ance. Notice the call to 
time.sleep(2)
, which provides a 2-second pause between the two calls.
The second method, 
GetSetting()
, accepts a constant value as input. Listing 9-4 shows common 
settings you can query using 
GetSetting()
. The example shows the results of three queries about 
Windows Explorer settings for file display. You can see these results (as well as the results for the 
third method) in Figure 9-15.

Download 20,35 Mb.

Do'stlaringiz bilan baham:
1   ...   202   203   204   205   206   207   208   209   ...   453




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish