Results 1 to 6 of 6

Thread: how to make a change in a dll?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 1999
    Location
    flanders, nj 07836
    Posts
    110

    how to make a change in a dll?

    I don't know how to explain this well so I'll state the situation.
    I want a variable that's changeable within a dll from another program. Meaning say their is a variable called LIVESERVER*string, how can I set (in any way) what populates that variable? The reason is I want a fail safe on the dll that if one server doesn't work, it access the other server, however I won't always know that other server name. I tried using registry changes or simple ascii files but I might have soomething wrong but nothing works.

    Basically from a DLL if I could access a resgitry key for a server name to access that could work because a 'monitor' program will set that value depending on what is the better server.

    got I hope that makes sense

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    you could make a property or public variable in the class that you can change. Problem is..will this dll be accessed my more than one exe? If so, only the exe that set that new value can read that new value from the instance it creates. The others would only see the default value since you generally cannot use GetObject with VB dll's. There is a workaround, but it may just be easier to set a registry entry, ini file entry, or xml file entry with the active server name that can them be read from the file by the dll.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 1999
    Location
    flanders, nj 07836
    Posts
    110
    Well it gets better.. the dll will be access by IIS5 on 2000AdvServ

    I tried getting something from the registry and it didn't work. When I try opening a ini file that does work but I was cheap and used open .. should I try the FileScript Obj?

  4. #4
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    i would suggest xml

    make a file called server.xml..put this in it

    Code:
    <active>
       <servername>Put servername here</servername>
    </active>
    access it is VB like this
    this is assuming the msxml component is on ther server..Add a reference to Microsoft XML

    this to get the value
    Code:
    Dim xmlDoc As MSXML.DOMDocument
    Dim xmlRoot As MSXML.IXMLDOMNode
    Dim strServer As String
    
    ' Populate General Tab from XML
    Set xmlDoc = New MSXML.DOMDocument
    xmlDoc.async = False
    xmlDoc.Load App.Path & "\server.xml"
    Set xmlRoot = xmlDoc.selectSingleNode("active")
    
    strServer= xmlRoot.selectSingleNode("serverName").Text
    now to change that value

    Code:
    Dim xmlDoc As MSXML.DOMDocument
    Dim xmlRoot As MSXML.IXMLDOMNode
    Dim strServer As String
    
    ' Populate General Tab from XML
    Set xmlDoc = New MSXML.DOMDocument
    xmlDoc.async = False
    xmlDoc.Load App.Path & "\server.xml"
    Set xmlRoot = xmlDoc.selectSingleNode("active")
    
    xmlRoot.selectSingleNode("serverName").Text = "whatever"
    xmlDoc.save app.path & "\server.xml"
    that is how i would do it.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  5. #5

    Thread Starter
    Lively Member
    Join Date
    May 1999
    Location
    flanders, nj 07836
    Posts
    110
    what would the app path be for a iisdll? the diretory it's registerd?

  6. #6
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    it should be wherever to dll is located, so keep the xml file in the same directory...
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width