473,581 Members | 2,783 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Display Adapter Information from Registry?

Hi All,

I've been working with python for about 6 months now, and have been
very impressed with the size and scope of the libraries. I have,
however, run into a bit of a problem.

I discoverred Marc Hammonds PyWin32 extensions, (whcih are awesome)
and Tim Golden's WMI wrapper for accessing the Windows Management
Instrumentation (Win32_Classes) but now I have been asked to remove
these dependandcies and still obtain machine information from the
registry (Windows only of course) so that we do not have to ship any
extensions to Python with our commercial software.

I need to grab the following information:

CPU(s) Descriptions strings (for multiple processors) (found in
registry)
Display Adapter description string (found in registry)
Display Adapter Memory (found in registry)

What I'm having trouble with is to grab the DISPLAY ADAPTER version
using python and no Win32com client (i.e. pyWin32). I thought about
grabbing the file name of the driver from the registry and then
looking up the file and calculating the version number (by parsing the
binary) but this only works if i can find the file. I tried it out on
a few machines with different video adapters and thsi didn't prove to
be a reliable method.

Any suggestions? Please????

Omer Ahmad.

ps: here is the code i'm using right now (minus all the debug strings)
def main():
"""Retrieve s Machine information from the registry"""

try:
hHardwareReg = _winreg.OpenKey (_winreg.HKEY_L OCAL_MACHINE,
"HARDWARE")
hDescriptionReg = _winreg.OpenKey (hHardwareReg, "DESCRIPTIO N")
hSystemReg = _winreg.OpenKey (hDescriptionRe g, "SYSTEM")
hCentralProcess orReg = _winreg.OpenKey (hSystemReg,
"CentralProcess or")
nbProcessors = _winreg.QueryIn foKey(hCentralP rocessorReg)[0]

for idxKey in range(nbProcess ors):
#get a handle to the processor ID key
hProcessorIDReg = _winreg.OpenKey (hCentralProces sorReg,
str(idxKey))
processorDescri ption =
_winreg.QueryVa lueEx(hProcesso rIDReg,"Process orNameString")[0]
mhz = _winreg.QueryVa lueEx(hProcesso rIDReg, "~MHz")[0]
print "Processor " + str(idxKey) + ": " +
string.lstrip(p rocessorDescrip tion) + " Clock Speed: " + str(mhz)

except WindowsError:
print "Cannot retrieve processor information from registry!"

#get handle to device map, reusing hardware handle

try:
hDeviceMapReg = _winreg.OpenKey (hHardwareReg, "DEVICEMAP" )
hVideoReg = _winreg.OpenKey (hDeviceMapReg, "VIDEO")
VideoCardString =
_winreg.QueryVa lueEx(hVideoReg ,"\Device\Video 0")[0]
#Get Rid of Registry/Machine from the string
VideoCardString Split = VideoCardString .split("\\")
ClearnVideoCard String =
string.join(Vid eoCardStringSpl it[3:], "\\")
#Go up one level for detailed
VideoCardString Root =
string.join(Vid eoCardStringSpl it[3:len(VideoCard StringSplit)-1], "\\")

#Get the graphics card information
hVideoCardReg = _winreg.OpenKey (_winreg.HKEY_L OCAL_MACHINE,
ClearnVideoCard String)
VideoCardDescri ption = _winreg.QueryVa lueEx(hVideoCar dReg,
"Device Description")[0]
VideoCardMemory Size = _winreg.QueryVa lueEx(hVideoCar dReg,
"HardwareInform ation.MemorySiz e")[0]

print "Graphics Card: " + VideoCardDescri ption
print "Memory: " +
str(struct.unpa ck('l',VideoCar dMemorySize)[0])

except WindowsError:
print "Cannot Retrieve Graphics Card Name and Memory Size!"
Jul 18 '05 #1
1 8376
Let's see, there are tools that do what you want but you are
being told not use them? If you use py2exe to bundle up all
your commercial software (with extensions) and then Inno Setup
to create a setup.exe file for setting everything up, nobody
ever knows about Python, extensions, etc. This eliminates the
need to have Python (and any extensions) installed on the
target machines. I (and many others) do this for all my
Windows software that is to be distributed.

Hope information helps.
Larry Bates
Omer Ahmad wrote:
Hi All,

I've been working with python for about 6 months now, and have been
very impressed with the size and scope of the libraries. I have,
however, run into a bit of a problem.

I discoverred Marc Hammonds PyWin32 extensions, (whcih are awesome)
and Tim Golden's WMI wrapper for accessing the Windows Management
Instrumentation (Win32_Classes) but now I have been asked to remove
these dependandcies and still obtain machine information from the
registry (Windows only of course) so that we do not have to ship any
extensions to Python with our commercial software.

I need to grab the following information:

CPU(s) Descriptions strings (for multiple processors) (found in
registry)
Display Adapter description string (found in registry)
Display Adapter Memory (found in registry)

What I'm having trouble with is to grab the DISPLAY ADAPTER version
using python and no Win32com client (i.e. pyWin32). I thought about
grabbing the file name of the driver from the registry and then
looking up the file and calculating the version number (by parsing the
binary) but this only works if i can find the file. I tried it out on
a few machines with different video adapters and thsi didn't prove to
be a reliable method.

Any suggestions? Please????

Omer Ahmad.

ps: here is the code i'm using right now (minus all the debug strings)
def main():
"""Retrieve s Machine information from the registry"""

try:
hHardwareReg = _winreg.OpenKey (_winreg.HKEY_L OCAL_MACHINE,
"HARDWARE")
hDescriptionReg = _winreg.OpenKey (hHardwareReg, "DESCRIPTIO N")
hSystemReg = _winreg.OpenKey (hDescriptionRe g, "SYSTEM")
hCentralProcess orReg = _winreg.OpenKey (hSystemReg,
"CentralProcess or")
nbProcessors = _winreg.QueryIn foKey(hCentralP rocessorReg)[0]

for idxKey in range(nbProcess ors):
#get a handle to the processor ID key
hProcessorIDReg = _winreg.OpenKey (hCentralProces sorReg,
str(idxKey))
processorDescri ption =
_winreg.QueryVa lueEx(hProcesso rIDReg,"Process orNameString")[0]
mhz = _winreg.QueryVa lueEx(hProcesso rIDReg, "~MHz")[0]
print "Processor " + str(idxKey) + ": " +
string.lstrip(p rocessorDescrip tion) + " Clock Speed: " + str(mhz)

except WindowsError:
print "Cannot retrieve processor information from registry!"

#get handle to device map, reusing hardware handle

try:
hDeviceMapReg = _winreg.OpenKey (hHardwareReg, "DEVICEMAP" )
hVideoReg = _winreg.OpenKey (hDeviceMapReg, "VIDEO")
VideoCardString =
_winreg.QueryVa lueEx(hVideoReg ,"\Device\Video 0")[0]
#Get Rid of Registry/Machine from the string
VideoCardString Split = VideoCardString .split("\\")
ClearnVideoCard String =
string.join(Vid eoCardStringSpl it[3:], "\\")
#Go up one level for detailed
VideoCardString Root =
string.join(Vid eoCardStringSpl it[3:len(VideoCard StringSplit)-1], "\\")

#Get the graphics card information
hVideoCardReg = _winreg.OpenKey (_winreg.HKEY_L OCAL_MACHINE,
ClearnVideoCard String)
VideoCardDescri ption = _winreg.QueryVa lueEx(hVideoCar dReg,
"Device Description")[0]
VideoCardMemory Size = _winreg.QueryVa lueEx(hVideoCar dReg,
"HardwareInform ation.MemorySiz e")[0]

print "Graphics Card: " + VideoCardDescri ption
print "Memory: " +
str(struct.unpa ck('l',VideoCar dMemorySize)[0])

except WindowsError:
print "Cannot Retrieve Graphics Card Name and Memory Size!"

Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1665
by: pothik05 | last post by:
Hi: I have created a custom Attribute for the assembly and lets call it AssemblyAbc. I want it to be displayed with the other Assembly Information. If you right click the dll, click Properties > Version > Other Version Information: I want my attribute to be listed here. I help will be highly appreciated.
1
1303
by: jm001 | last post by:
Hi, I am creating a database that will hold contact information plus additional information on different tables. ID on contact will auto assign. I want to have the system prompt for ID and then display the contact name on forms when a user opens a form. If there is no match on ID then it should display a message to create contact. If...
1
1346
by: JL | last post by:
Hi all, I want to display a processing result after processed by popup windows, for example, i want to display the login name and login password in pop up window after user applied the new account, which method can use in ASP.net environment? Thanks a lot
0
1563
by: AbdullahWMGhaleb | last post by:
--Dear All, Using WMI, I managed to get information about device ID and manufacturer of my USB Bluetooth adapter. However, I CANNOT GET Blueooth Device Screen Name ! ------------------------------------------------------------------------ (I tried with many diffrent WMI classes by the follwing code foreach(ManagementObject mo in new...
2
3751
by: Stephen | last post by:
Hi, Suppose there is a column in the dataset that is a very large field (say varchar(500)) and i want to display partial information with (....) so that the user can click on it to view for more. (I dont want to truncate any info in the dataset...) How can display partial information in a datagrid? Thanks, Stephen
0
1065
by: sos | last post by:
I am new to VBasic - I understand that forms are used to enter data, but it would be nice for the person entering to see some summarizing information derived from all inputted data on the screen (form) as they are entering. Is this possible - to display values on the form via variables? And if so, is there a special command? Thank you!
1
2277
by: Benny Ng | last post by:
Dear All, Now I met one problem in the development of my one application. I have one ASP.NET page. It's for disply the information of customer. But now I have one new requirement. It's to combine the "Edit" and "Display" funtions into this page. (It means if user want to edit the customer information, this page would provided editing page...
12
7346
by: Lahiru778 | last post by:
I require to appear the Name which i click on the "new.php" page in the "Window_open.php" page..I use some Java Script also to accomplish this but I couldn't.. Could you pleas Help ...!!! ----------The Code in "Window_open.php" ------------------- <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
1
1810
by: stepup | last post by:
I am making a program for a train ticket. I have done it up until the program needs to display the completed ticket. The completed ticket has the following: BOARDED AT Stop no. _____ Stop name __________________ No. Adults _____ No. of Children ___ No. of OAP’s ____ Adult fare _____ Child fare ___...
0
7804
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8156
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8310
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8180
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5681
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5366
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3809
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1409
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1144
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.