Någon som vet hur man kan se vilken version av msxml2.dll (2.x eller 3) som används när man försöker parsa xml ? Har den inte installerad så jag kan inte testa koden, men kolla först om det finns egenskap som heter .Version?, alternativt app.verson, app.major och app.minor.msxml parser
/BjörneSv: msxml parser
En annan variant är ett utdrag som jag fann på nätet. Jag översätter den inte men hoppas att du i alla fall kan läsa den och förstå. Om det löser sig, lägg då gärna upp koden i tips & tricks.
Hälsningar
/pelle
------------------------------------
If you go via CLSID, then you must ensure the CLSID is going to be found.
If you open up regedit & browse down to the CLSID for one of the classes in your DLL, you'll find a sub key called InProcServer32 which contains the path to your DLL on that machine. ( It also has a Version number which is the version number of that particular 'class'. )
But how do we get the CLSID ? ( without hard coding it in, and which will require changing anytime you change the classes interface at all, i.e. add a new public property or function, or even just recompile with Project compatibility ) We can use a method somewhat similar to how the OS late binds ...
First, you know what the ProgID will be, this is unlikely to change. EG. MyDLL.MyFirstClass
Next, you pass it to a function somewhat like this
<code>
Private Function msRetrieveCLSID(ByVal vsComponentNm As String) As String
''------------------------------------------------------------------------------
'' Name : msRetrieveCLSID
'' Description : Retrieve the CLSID of the ActiveXServer.Class passed
'' in via vsComponentNm from the registry
'' Date : 28/08/2001
'' PreCondition : Len(vsComponentNm) > 0
'' PostCondition : n/a
'' Input Parameters : vsComponentNm - The component name to look for
'' Output Parameters : n/a
'' Return Value : String - The CLSID of the component we are wanting to document
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim loReg As clsRegistry
On Error GoTo error_handler
msRetrieveCLSID = ""
Set loReg = New clsRegistry
loReg.ClassKey = HKEY_CLASSES_ROOT
loReg.SectionKey = Trim$(vsComponentNm) & "\Clsid"
If loReg.KeyExists Then
loReg.ValueType = REG_SZ
msRetrieveCLSID = loReg.Value
End If
Exit Function
error_handler:
Set loReg = Nothing
Err.Raise Err.Number, "mdlInterface.msRetrieveCLSID" & vbCrLf & Err.Source, Err.Description
End Function
</code>
It's a simple front end for a set of API's used to browse the registry. If you haven't got one already yourself, there's plenty of good code to do the same thing out on the 'net.
Basically, all this does is gets us the CLSID for our ProgID. Next, we want to get the path to the DLL itself, based on the CLSID ( now, remember, that each class in your DLL is going to have a CLSID registered, but they are all going to ( hopefully !! ) point to the same DLL on the system.
To get the path to the DLL use soimething similar to this
<code>
Private Function msRetrievePath(ByVal vsCLSID As String) As String
''------------------------------------------------------------------------------
'' Name : msRetrievePath
'' Description : Retrieve the path of the ActiveXServer ( DLL )
'' from the registry
'' Date : 28/08/2001
'' PreCondition : Len(vsCLSID) > 0
'' PostCondition : n/a
'' Input Parameters : vsCLSID - The CLSID of the Class
'' Output Parameters : n/a
'' Return Value : String - The path for where the registered DLL resides on the
'' local filesystem.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim loReg As clsRegistry
Dim sKeyNames() As String
Dim llKeyCount As Long
Dim llCount As Long
On Error GoTo error_handler
msRetrievePath = ""
Set loReg = New clsRegistry
loReg.ClassKey = HKEY_CLASSES_ROOT
loReg.SectionKey = "CLSID\" & Trim$(vsCLSID) & "\InprocServer32\"
If loReg.KeyExists Then
loReg.ValueType = REG_SZ
msRetrievePath = loReg.Value
End If
Exit Function
error_handler:
Set loReg = Nothing
Err.Raise Err.Number, "mdlInterface.msRetrievePath" & vbCrLf & Err.Source, Err.Description
End Function
</code>
Cool. Now we have the path to the DLL. So, what next ?
Well, either use the code at the link provided by naga1979, or might I suggest also investigating the functionality provided to you by the TypeLib Information DLL ( TlbInf32.dll ) ? Lovely little library this. A guide to using it can be found in its help file which can be downloaded at
http://msdn.microsoft.com/downloads/default.asp?url=/downloads/sample.asp?url=/MSDN-FILES/027/000/255/msdncompositedoc.xml
Anyway, this is all dependant also on which versionnumber you are actually after .... there are two version numbers typically for a DLL, there's the numbers you'll get from using App.MAjor, App.Minor ( which will not increment with each build if you turn off the auto increment button ) or theres the 'internal' version number of the DLL which WILL autoincrement with each build if there have been any changes to any of the classes within the DLL ( oh, and don't forget either that each class will also have its own version number )
To give you an idea, the dump below is a section of a dump file I produce to track changes made to our products DLL's with each build
The DLL in question has an App.Major of 2, an App.Minor of 3
The numbers on the end are the INTERNAL version numbers of the DLL & two of its classes
<code>
DLL,T1S1EPG22.DLL,,{3D2CB102-4E6D-11D5-84E1-00104B1CF34E},,2.1
COCLASS,,CLSS1EPGACADEMICTRANS,{3D2CB104-4E6D-11D5-84E1-00104B1CF34E},{FAB8DEC2-63B4-11D5-84EA-00104B1CF34E},1.0
COCLASS,,CLSS1EPGAUTOGRADUATE,{3D2CB106-4E6D-11D5-84E1-00104B1CF34E},{94BF2EF4-A003-11D5-B5B1-00010307F15C},1.1
COCLASS,,CLSS1EPGPROCESSREQ,{3D2CB108-4E6D-11D5-84E1-00104B1CF34E},{FAB8DEC4-63B4-11D5-84EA-00104B1CF34E},1.0
</code>
So, which version number are you after ??