Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WMI / Product Key

Status
Not open for further replies.

AlanArons

Programmer
Aug 1, 2002
91
US
I am using the WMI to extract information about my workstations and the installed software. The piece of information I can't seem to find is the Product Activation Key used by Microsoft products.

Does anyone know the class/object to retrieve this piece of information?

Or, if there is a better way, I am always open for it.

Thanks for your help.

Alan Arons [ponder]
 
Is this what you're loking for?:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualFoxPro\9.0\Registration

You could maybe use the GetPrivateProfileString or GetProfileString API calls to retrieve that info.


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
>>The piece of information I can't seem to find is the Product Activation Key used by Microsoft products.

This seems to be product dependent, and by no means all Microsoft products expose this in any readable form.

In fact VFP is one that does so, and the information is stored in the registry (under the "registration" key in :
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualFoxPro\[VERSION]

Office has a similar key, but stores the "DigitalProductID" as a hex string under:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\[VERSION]

and SQL Server 2000 stores "CD Key, ProductID and DigitalProductID here:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\80\Registration

But SQL Server 2005 uses a different setup :
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\90\ProductID

So there really is no one answer to your question I am afraid



----
Andy Kramek
Visual FoxPro MVP
 
So far, I agree. There seems to be no standard for recording the S/N or Product Keys. Belarc Advisor ( is pulling it from somewhere, however, so the search continues.

In the mean time, I would like to contribute this piece of code that drills down into the registry and displays all the Software registry keys.
Code:
********************************************

#DEFINE HKLM -2147483646   

LOCAL oreg AS "registry" OF HOME()+"samples\classes\registry.prg"

SoftwarePath="Software"

CREATE CURSOR reg (LEVEL i,KEY c(40),NAME c(40),VALUE c(100))

enumreg(SoftwarePath,HKLM,0)

BROWSE LAST


PROCEDURE enumreg(SoftwarePath AS STRING,nhive AS INTEGER,nLevel AS INTEGER)
LOCAL i,oreg,aVals[1,1],aKeys[1]
oreg=NEWOBJECT("registry",HOME()+"samples\classes\registry.prg")
oreg.openkey(SoftwarePath,nhive)
IF oreg.EnumKeyValues(@aVals)=0
	FOR i = 1 TO MIN(ALEN(aVals,1),100)
		INSERT INTO reg VALUES (nLevel,REPLICATE(">",nLevel),aVals[i,1],aVals[i,2])
	ENDFOR
ENDIF
IF oreg.EnumKeys(@aKeys)=0
	FOR i = 1 TO ALEN(aKeys,1)
		INSERT INTO reg VALUES (nLevel,REPLICATE(">",nLevel)+aKeys[i],"","")
		enumreg(SoftwarePath+"\"+aKeys[i],nhive,nLevel+1)
	ENDFOR
ENDIF

RETURN

**************************************

Alan Arons[ponder]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top