Page 1 of 1 1
Topic Options
#139029 - 2005-05-02 09:48 PM Find declared Dlls
Jose Offline
Seasoned Scripter
*****

Registered: 2001-04-04
Posts: 693
Loc: Buenos Aires - Argentina
Hi guys:
I have a weird new task wich is to find where the declared dlls are stored in normal M$ OS (Nt/2000/XP) and take note of M$ ones in particular. I know this is weird but is weird for me to believe me.
Is there a place where they are? I would say the registry but dunno.

Thanks.
_________________________
Life is fine.

Top
#139030 - 2005-05-02 10:08 PM Re: Find declared Dlls
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Hey Joser, what you mean by "declared dlls" ? Most DLL's are located in system32 but that aint always the case. COM DLL's (and OCX's) are "declared" (registered) in the registry (as COM objects) ...
Top
#139031 - 2005-05-02 10:12 PM Re: Find declared Dlls
Jose Offline
Seasoned Scripter
*****

Registered: 2001-04-04
Posts: 693
Loc: Buenos Aires - Argentina
I am sorry Shawn I havent specified very well.
What I mean is every dll that has been registered with regsr32 M$.dll independently if they are in the system32 folder or not.
Thanks for the answer Big man
_________________________
Life is fine.

Top
#139032 - 2005-05-02 10:46 PM Re: Find declared Dlls
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
This would be a pretty good start:

Enum all the keys here:

HKEY_CLASSES_ROOT\CLSID

Look specifically at this value in keyname:

HKEY_CLASSES_ROOT\CLSID\<keyname>\InprocServer32

This will point you to the DLL, the PROGID is also there (the one that is used for CreateObject())

Not every COM object has a InprocServer32 ... the other one (iirc) is RemoteServer for DCOM type objects (DLL's running on remote servers).

-Shawn

Top
#139033 - 2005-05-02 11:08 PM Re: Find registered dlls - Solved
Jose Offline
Seasoned Scripter
*****

Registered: 2001-04-04
Posts: 693
Loc: Buenos Aires - Argentina
IŽll do that Shawn. If I have any problem I tell you.
Thanks very much man!!


Edited by Jose (2005-05-02 11:28 PM)
_________________________
Life is fine.

Top
#139034 - 2005-05-03 01:49 AM Re: Find registered dlls - Solved
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
That other value I forgot was LocalServer32 ... these are for servers that are EXE's ... like InternetExplorer.Application. And btw - an OCX is just a DLL with a fancy name.

-Shawn

Top
#139035 - 2005-05-03 05:24 PM Re: Find registered dlls - Solved
Jose Offline
Seasoned Scripter
*****

Registered: 2001-04-04
Posts: 693
Loc: Buenos Aires - Argentina
Thanks for the tip Shawn.
Here is my code, added some XML writing to see results.

Code:
  
WriteRegisteredDlls("D:\Temp\@WKSTA.xml")


Function WriteRegisteredDlls($XMLFile)
$ArchivoXML=$XMLFile
$xml = LoadXml($ArchivoXML)
$RootKey = "HKEY_CLASSES_ROOT\CLSID\"
$Index = 0
:Loopo
$KeyName = EnumKey("HKEY_CLASSES_ROOT\CLSID\", $Index)
If @ERROR = 0
If KeyExist($RootKey + $KeyName + "InprocServer32")=0
$Inproc=$RootKey + $KeyName + "\InprocServer32"
$DllName = ReadValue($Inproc, "")
If Exist ( $DllName )
$FileLocation=$DllName
$CompanyName=GetFileVersion($DllName,"CompanyName")
$BinFileVersion=GetFileVersion($DllName,"BinFileVersion")
$FileDescription=GetFileVersion($DllName,"FileDescription")
$FileVersion=GetFileVersion($DllName,"FileVersion")
$Languaje=GetFileVersion($DllName,"Language")
$Name=GetFileVersion($DllName,"OriginalFilename")
$ProductName=GetFileVersion($DllName,"ProductName")
?$DllName
If $CompanyName="Microsoft Corporation"
$Path="Microsoft/Dlls/$Name/CompanyName"
$= WriteXmlValue($xml, $Path, $CompanyName)
$Path="Microsoft/Dlls/$Name/BinFileVersion"
$= WriteXmlValue($xml, $Path, $BinFileVersion)
$Path="Microsoft/Dlls/$Name/FileDescription"
$= WriteXmlValue($xml, $Path, $FileDescription)
$Path="Microsoft/Dlls/$Name/FileVersion"
$= WriteXmlValue($xml, $Path, $FileVersion)
$Path="Microsoft/Dlls/$Name/Languaje"
$= WriteXmlValue($xml, $Path, $Languaje)
$Path="Microsoft/Dlls/$Name/ProductName"
$= WriteXmlValue($xml, $Path, $ProductName)
$Path="Microsoft/Dlls/$Name/Path"
$= WriteXmlValue($xml, $Path, $DllName)
EndIf

EndIf
EndIf
$Index = $Index + 1
GoTo Loopo
EndIf
SaveXml($xml, $ArchivoXML)
$xml = 0
EndFunction


;**********************************
; XML
;**********************************
Function FormatXML($objXMLDOM)
Dim $,$strXSL,$objXSL
$strXSL = " Chr(34) + "UTF-8" + Chr(34) + "?>" + @CRLF
$strXSL = $strXSL + " " xmlns:xsl=" + Chr(34) + "http://www.w3.org/1999/XSL/Transform" +
Chr(34) + ">" + @CRLF
$strXSL = $strXSL + " " version=" + Chr(34) + "1.0" + Chr(34) + " encoding=" + Chr(34) +
"UTF-8" + Chr(34) + " indent=" + Chr(34) + "yes" + Chr(34) + "/>" + @CRLF
$strXSL = $strXSL + " Chr(34) + ">" + @CRLF
$strXSL = $strXSL + ""+ @CRLF
$strXSL = $strXSL + ""+ @CRLF
$strXSL = $strXSL + "
"+ @CRLF
$strXSL = $strXSL + "
"+ @CRLF
$strXSL = $strXSL + "
"
$objXSL = CreateObject("Microsoft.XMLDOM")
$objXSL.async = false
$=$objXSL.loadXML($strXSL)
$objXMLDOM.TransformNodeToObject ($objXSL, $objXMLDOM)
$formatXML = $objXMLDOM
EndFunction

Function LoadXML($filename)
Dim $, $rootNode, $objNewPI, $strType
$loadXml = CreateObject("Microsoft.XMLDOM")
$loadXml.async = False
$loadXml.preserverwhitespace = True
If NOT $loadXml
Return
EndIf
$ = $loadXml.Load($filename)
EndFunction

Function SaveXML($xml, $filename)
$xml = FormatXML($xml)
$SaveXml = $xml.Save($filename)
EndFunction

Function WriteXMLValue($source, $path, $value)
Dim $, $p, $rootNode, $sectionNode, $parentNode, $childNode, $node, $xml
If VarType($source) = 9
$xml = $source
Else
If InStr($source,"<")=0
$xml = LoadXML($source)
Else
$xml = CreateObject("Microsoft.XMLDOM")
$xml.async = false
$=$xml.loadXML($source)
EndIf
EndIf
$sectionNode = $xml.SelectSingleNode($path);
If NOT $sectionNode
$parentNode = $xml
For Each $node In Split($path,"/")
$p = $p + $node
$sectionNode = $xml.SelectSingleNode($p)
If NOT $sectionNode
$sectionNode = $xml.CreateElement($node)
$parentNode = $parentNode.AppendChild($sectionNode)
Else
$parentNode = $sectionNode
EndIf
$p = $p + "/"
Next
EndIf
If $sectionNode
$sectionNode.Text = $value
EndIf
If VarType($source) = 9
$WriteXMLValue = $xml
Else
If InStr($source,"<")=0
SaveXML($xml, $source)
Else
$WriteXMLValue = $xml
EndIf
EndIf
EndFunction

_________________________
Life is fine.

Top
#139036 - 2005-05-03 06:55 PM Re: Find registered dlls - Solved
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
What about using ISDECLARED ?

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#139037 - 2005-05-03 09:09 PM Re: Find registered dlls - Solved
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
Kent...

Where or what portion of the code do you ask this about? Guess I'm missing what your intent or meaning is.


Quote:

IsDeclared( )
 
Action: Indicates whether of not a variable has been declared.





Top
#139038 - 2005-05-03 09:11 PM Re: Find registered dlls - Solved
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
Jose... Can you recode to remove the GOTO code and use DIM in the functions and ensure they support SetOption('NoVarsInStrings','On')
Top
#139039 - 2005-05-03 09:18 PM Re: Find registered dlls - Solved
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
Error when I ran the code.

ERROR : IDispatch pointers not allowed in expressions!
Script: C:\SCRIPTS\GetDLLValues.kix
Line : 119

LINE:119
$parentNode = $parentNode.AppendChild($sectionNode)

Also all output is on screen even when call is set like this.

Dim $DLLCheck
$DLLCheck = WriteRegisteredDlls('c:\temp\' + @WKSTA + '.xml')

Top
#139040 - 2005-05-03 09:21 PM Re: Find registered dlls - Solved
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Quote:


Where or what portion of the code do you ask this about? Guess I'm missing what your intent or meaning is.





Doh..

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#139041 - 2005-05-03 09:22 PM Re: Find registered dlls - Solved
Jose Offline
Seasoned Scripter
*****

Registered: 2001-04-04
Posts: 693
Loc: Buenos Aires - Argentina
I think Kent that IsDeclared should be used only for variables not for dlls.

BTW Shawn.....How should I look for in order to serch for other dlls than Microsoft? Cause the ones stored in 'HKEY_CLASSES_ROOT\CLSID\' are mostly Microsoft ones and now I have been asked to search for others apps.

Thanks
_________________________
Life is fine.

Top
#139042 - 2005-05-03 09:23 PM Re: Find registered dlls - Solved
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Thanks Jose.. I realized my mistake.

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#139043 - 2005-05-03 09:25 PM Re: Find registered dlls - Solved
Jose Offline
Seasoned Scripter
*****

Registered: 2001-04-04
Posts: 693
Loc: Buenos Aires - Argentina
Thanks for the answer Kent.

DOC I am on it now, I mean after the error. Thanks DOC.


Edited by Jose (2005-05-03 09:29 PM)
_________________________
Life is fine.

Top
#139044 - 2005-05-03 11:55 PM Re: Find registered dlls - Solved
Jose Offline
Seasoned Scripter
*****

Registered: 2001-04-04
Posts: 693
Loc: Buenos Aires - Argentina
DOC have made some corrections to the script above, here is it.

Code:
  
Break On
Dim $SO
$SO=SetOption('Explicit','On')
$SO=SetOption('NoVarsInStrings','On')

Dim $DLLCheck
$DLLCheck = GetRegisteredDlls

Function GetRegisteredDlls()
Dim $RootKey,$Index,$KeyName,$Inproc,$DllName,$FileLocation
Dim $CompanyName,$BinFileVersion,$FileDescription,$FileVersion,$Languaje
Dim $Name,$ProductName
$RootKey = "HKEY_CLASSES_ROOT\CLSID\"
$Index = 0
While @ERROR = 0
$KeyName = EnumKey("HKEY_CLASSES_ROOT\CLSID\", $Index)
If KeyExist($RootKey + $KeyName + "InprocServer32")=0
$Inproc=$RootKey + $KeyName + "\InprocServer32"
$DllName = ReadValue($Inproc, "")
If Exist ( $DllName )
$FileLocation=$DllName
$CompanyName=GetFileVersion($DllName,"CompanyName")
$BinFileVersion=GetFileVersion($DllName,"BinFileVersion")
$FileDescription=GetFileVersion($DllName,"FileDescription")
$FileVersion=GetFileVersion($DllName,"FileVersion")
$Languaje=GetFileVersion($DllName,"Language")
$Name=GetFileVersion($DllName,"OriginalFilename")
$ProductName=GetFileVersion($DllName,"ProductName")
? "-----------------------------------------"
? 'File index number: ' + $Index
? 'Path: ' + $DllName
? 'Company: ' + $CompanyName
? 'BinFile version: ' + $BinFileVersion
? 'File version: ' + $FileVersion
? 'File description: ' + $FileDescription
? 'Language: ' + $Languaje
? 'Original name: ' + $Name
? 'Product name: ' + $ProductName
EndIf
EndIf
$Index = $Index + 1
Loop
Exit @ERROR
EndFunction



It is still missing the storage part, due to XML functions not ready I will look fordward in doing it into an MDB.

Thanks DOC.
_________________________
Life is fine.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 774 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.071 seconds in which 0.028 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org