Solved

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

Posted on 2003-11-26
23
1,770 Views
Last Modified: 2007-12-19
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...
0
Comment
Question by:ericvb
23 Comments
 
LVL 12

Expert Comment

by:roverm
ID: 9824274
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
 

Author Comment

by:ericvb
ID: 9824309
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
 
LVL 12

Expert Comment

by:roverm
ID: 9824320
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
 

Author Comment

by:ericvb
ID: 9824334
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
 
LVL 12

Expert Comment

by:roverm
ID: 9827819
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
 
LVL 96

Expert Comment

by:Bob Learned
ID: 10277253
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
 
LVL 12

Expert Comment

by:roverm
ID: 10278697
Woah, forgot on this one. Do you still need a scanner?
0
 

Author Comment

by:ericvb
ID: 10278763
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
 
LVL 12

Expert Comment

by:roverm
ID: 10279528
Ok, I've build it for a great part, I only need to finish it...
0
 
LVL 1

Expert Comment

by:Computer101
ID: 10337537
PAQed, with points refunded (200)

Computer101
E-E Admin
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 12

Expert Comment

by:roverm
ID: 10340040
Computer101, please read the last 2 comments. I was still working on this one!

ericvb, do you agree to open the question?
0
 

Author Comment

by:ericvb
ID: 10341888
I agree to let this question open
0
 
LVL 12

Expert Comment

by:roverm
ID: 10360652
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
 
LVL 12

Accepted Solution

by:
roverm earned 200 total points
ID: 10360718
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
 

Author Comment

by:ericvb
ID: 10370004
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
 
LVL 12

Expert Comment

by:roverm
ID: 10370258
Else add a VB module or class to your project.
Then you can copy/paste it into that and call it from C#.
0
 
LVL 12

Expert Comment

by:roverm
ID: 10463377
Eric, any progress?
0
 

Author Comment

by:ericvb
ID: 10463498
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
 
LVL 12

Expert Comment

by:roverm
ID: 10463849
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
 

Author Comment

by:ericvb
ID: 10956649
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

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now