473,323 Members | 1,589 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

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():
"""Retrieves Machine information from the registry"""

try:
hHardwareReg = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,
"HARDWARE")
hDescriptionReg = _winreg.OpenKey(hHardwareReg, "DESCRIPTION")
hSystemReg = _winreg.OpenKey(hDescriptionReg, "SYSTEM")
hCentralProcessorReg = _winreg.OpenKey(hSystemReg,
"CentralProcessor")
nbProcessors = _winreg.QueryInfoKey(hCentralProcessorReg)[0]

for idxKey in range(nbProcessors):
#get a handle to the processor ID key
hProcessorIDReg = _winreg.OpenKey(hCentralProcessorReg,
str(idxKey))
processorDescription =
_winreg.QueryValueEx(hProcessorIDReg,"ProcessorNam eString")[0]
mhz = _winreg.QueryValueEx(hProcessorIDReg, "~MHz")[0]
print "Processor " + str(idxKey) + ": " +
string.lstrip(processorDescription) + " 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.QueryValueEx(hVideoReg,"\Device\Video0")[0]
#Get Rid of Registry/Machine from the string
VideoCardStringSplit = VideoCardString.split("\\")
ClearnVideoCardString =
string.join(VideoCardStringSplit[3:], "\\")
#Go up one level for detailed
VideoCardStringRoot =
string.join(VideoCardStringSplit[3:len(VideoCardStringSplit)-1], "\\")

#Get the graphics card information
hVideoCardReg = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,
ClearnVideoCardString)
VideoCardDescription = _winreg.QueryValueEx(hVideoCardReg,
"Device Description")[0]
VideoCardMemorySize = _winreg.QueryValueEx(hVideoCardReg,
"HardwareInformation.MemorySize")[0]

print "Graphics Card: " + VideoCardDescription
print "Memory: " +
str(struct.unpack('l',VideoCardMemorySize)[0])

except WindowsError:
print "Cannot Retrieve Graphics Card Name and Memory Size!"
Jul 18 '05 #1
1 8335
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():
"""Retrieves Machine information from the registry"""

try:
hHardwareReg = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,
"HARDWARE")
hDescriptionReg = _winreg.OpenKey(hHardwareReg, "DESCRIPTION")
hSystemReg = _winreg.OpenKey(hDescriptionReg, "SYSTEM")
hCentralProcessorReg = _winreg.OpenKey(hSystemReg,
"CentralProcessor")
nbProcessors = _winreg.QueryInfoKey(hCentralProcessorReg)[0]

for idxKey in range(nbProcessors):
#get a handle to the processor ID key
hProcessorIDReg = _winreg.OpenKey(hCentralProcessorReg,
str(idxKey))
processorDescription =
_winreg.QueryValueEx(hProcessorIDReg,"ProcessorNam eString")[0]
mhz = _winreg.QueryValueEx(hProcessorIDReg, "~MHz")[0]
print "Processor " + str(idxKey) + ": " +
string.lstrip(processorDescription) + " 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.QueryValueEx(hVideoReg,"\Device\Video0")[0]
#Get Rid of Registry/Machine from the string
VideoCardStringSplit = VideoCardString.split("\\")
ClearnVideoCardString =
string.join(VideoCardStringSplit[3:], "\\")
#Go up one level for detailed
VideoCardStringRoot =
string.join(VideoCardStringSplit[3:len(VideoCardStringSplit)-1], "\\")

#Get the graphics card information
hVideoCardReg = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,
ClearnVideoCardString)
VideoCardDescription = _winreg.QueryValueEx(hVideoCardReg,
"Device Description")[0]
VideoCardMemorySize = _winreg.QueryValueEx(hVideoCardReg,
"HardwareInformation.MemorySize")[0]

print "Graphics Card: " + VideoCardDescription
print "Memory: " +
str(struct.unpack('l',VideoCardMemorySize)[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
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...
1
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...
1
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...
0
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 !...
2
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...
0
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...
1
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...
12
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 ...!!! ...
1
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.