Visual studio .NET integrated windows installer : self registering of a dll (vsdrfCOMSelfReg)

In my application I use SQLDMO to have acces to the same possibilities as in the SQL Enterprise Manager (sqldmo.dll)
My application must run on PC's with already MSDE/SQL Server installed or PC's without MSDE/SQL Server installed (even no installed SQL Client software).
Microsoft has a knowledge paper with the steps to follow what to install for being able to run SQLDMO on a client machine without SQL client software.
You must install several dlls and one dll (sqldmo.dll) must be registered.
In a windows installer project (Visual Studio .NET) you can set the proporty REGISTER of this dll to vsdrfCOMSelfReg.
After running my installer my application was running on all machines (it worked  :-) )
But there is a 'BUT' :
The installer is not detecting that the dll is already installed and registered on machines with SQL Server. It will overwrite the existing settings and if my application is removed, the Enterprise Manager for example will not work anymore because the sqldmo.dll is not registered anymore (the deinstaller removed the registering...)

How do I tell the installer to not register the dll if this dll is already registered. It must only register the dll on 'clean' machines.
I'v searched already the net for an answer, but no luck for the moment...
ericvbAsked:
Who is Participating?
 
rovermCommented:
eric, this is what I have so far.

I've build a recursive function which will scan for the registry key.
This works just fine and is even quit fast (depending on your computer of course).
However, I can NOT access the last value of a key. Didn't find that yet.
But posting this anyway, so you can try as well.

You need to import this:

Imports Microsoft.Win32.Registry

Then the function:

    Private Function SearchKey(ByVal strStart As String, ByVal strSearchFor As String) As String
        Try
            Dim ky As Microsoft.Win32.RegistryKey = CurrentUser.OpenSubKey(strStart, False)
            If ky Is Nothing Then Return ""
            Dim arr() As String = ky.GetSubKeyNames()
            Dim arrd() As String
            Dim arrValues() As String
            Dim strResult As String
            Dim kyval As Microsoft.Win32.RegistryKey
            Dim i As Int32 = 0
            If arr Is Nothing Then Return ""
            If arr.Length = 0 Then
                arr = ky.GetValueNames()
                If arr.Length > 0 Then
                    kyval = CurrentUser.GetValue(ky.Name)
                End If
            End If
            For Each strKeyName As String In arr
                If strKeyName.ToUpper = "CLSID" Then
                    'Stop
                End If
                ky = ClassesRoot.OpenSubKey(strStart & "\" & strKeyName, False)
                If Not ky Is Nothing Then
                    arrValues = ky.GetValueNames()
                    For Each s As String In arrValues
                        'If s = "" Then s = "(Default)"
                        kyval = CurrentUser.OpenSubKey(strStart & "\" & strKeyName & "\" & s, False)
                        If Not kyval Is Nothing Then arrd = kyval.GetSubKeyNames()
                    Next
                    i = arrValues.IndexOf(arrValues, strSearchFor)
                    If i > -1 Then
                        Stop
                        Return "Found It!"
                    End If

                    arrValues = ky.GetSubKeyNames()
                    For Each strSubKeyName As String In arrValues
                        If strSubKeyName.ToUpper = strSearchFor.ToUpper Then
                            Stop
                        End If
                        strResult = SearchKey(strStart & "\" & strKeyName & "\" & strSubKeyName, strSearchFor)
                        If strResult <> "" Then
                            Stop
                            Return "Found it!"
                        End If
                    Next
                End If
            Next
        Catch ex As Exception
            Stop
        End Try
    End Function

Finally, to call it:

SearchKey("AppEvents\EventLabels\AppGPFault", "sqldmo.dll")

As you can see, pass the start key and what to search for.

Let me know what you think.

D'Mzz!
RoverM
0
 
rovermCommented:
What about installing all DLL's WITHOUT registrating them using a ProjectInstaller, then write some code in the 'AfterInstall' event to check whether that 1 dll is already registrated. If not: run regsvr32.exe to register it.

D'Mzz!
RoverM
0
 
ericvbAuthor Commented:
Yes, I thought about it also, but how do I test if a dll is already registered?
Till now I didn't find a line of code in C# to test this.
I could also look manually in the registry, but is there no other way, using the .NET environment, for example?
I didn't find anything in the MSDN library, but I'm overlooking it maybe
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
rovermCommented:
I think (*know*) it can be done using some API's. But I don't have my api collection here.
I can take a look for you this evening it you want.
0
 
ericvbAuthor Commented:
I should be gratefully if you want to do this.
I know also that it must be possible, but I do not find it for the moment :-((
It drives me crazy, it looks so simple...
0
 
rovermCommented:
Ok, I looked for the api and I guess I was wrong. At least, I can't find it ;-)
However, I got another idea.

I am building a 'registry scanner' which scans for the dll.
Got it all working except for the last stage...the reading of the value.

Still working on it ;-)
0
 
Bob LearnedCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

PAQ with points refunded

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

TheLearnedOne
EE Cleanup Volunteer
0
 
rovermCommented:
Woah, forgot on this one. Do you still need a scanner?
0
 
ericvbAuthor Commented:
Yes, of course  :-)
The problem is still there, I didn't find a solution.
I must admit, that I putted this problem aside, didn't have the time to put more time in it.
0
 
rovermCommented:
Ok, I've build it for a great part, I only need to finish it...
0
 
Computer101Commented:
PAQed, with points refunded (200)

Computer101
E-E Admin
0
 
rovermCommented:
Computer101, please read the last 2 comments. I was still working on this one!

ericvb, do you agree to open the question?
0
 
ericvbAuthor Commented:
I agree to let this question open
0
 
rovermCommented:
ericvb, it seems that C101 has forgotten about us.
I can reopen this question as well. Do you remember how many points you set on it? Then I can set it again.
0
 
ericvbAuthor Commented:
Hello RoverM,

Computer101 said : 'PAQed, with points refunded (200)', so I suppose that I setted it to 200 points? I don't know it anymore....

Thanks for your function, I will test it and let you know if it helps me.
(It will take me, maybe, some time, because I'v never worked with VB : must translate to C# or include this VB code in C# (I know it is possible, but did never do this before...))

Thanks,
Eric
0
 
rovermCommented:
Else add a VB module or class to your project.
Then you can copy/paste it into that and call it from C#.
0
 
rovermCommented:
Eric, any progress?
0
 
ericvbAuthor Commented:
Sorry Roverm,

I did not have the time yet to test your solution and I don't know if I shall have the time in the weeks to come.
The company who I work for is taken over by another company, so I must know spend my time to coordinate this takeover.

I know that you have administrator rights, so I propose that you take already 50% of the points on your count.
I thank you very match for your help, and I hope to test your solution soon.

Regards,
Eric
0
 
rovermCommented:
Hi Eric,
No need to apologize.

I'm sorry to say that I don't longer have admin rights (I am no longer the PE of .NET) but even if I had then I wouldn't have done that.
Let's wait and see when you have time again.

Good luck with the take over.

D'Mzz!
RoverM
0
 
ericvbAuthor Commented:
Hi Roverm,

I didn't have the time yet to test your solution, but as thank for answering my question, I will give you the points.

Thanks,
Eric
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.