CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10
  1. #1
    Join Date
    Oct 2001
    Posts
    6

    wana implement custom validations routine in a dll

    i want to give the user a custom validations interface. the user will implement the interface in his own component. i want to run the custom validations routine. here the catch is that i am not able to get the clsid of the component the user has written

    tom


  2. #2
    Join Date
    Oct 2001
    Location
    Phoenix, AZ
    Posts
    54

    Re: wana implement custom validations routine in a dll

    Yeah, that is a problem. Is the DLL installed in a special location? That would be the best way to solve this. Instead of installing the DLL to System32, install it to something like c:\myapp\plugins\.

    Then, you could scan the directory for DLLs. Since a clsid is a project name, and in VB, the dll name is the project name(usually), you could enumerate the files, parse the names minus the extension, and build your clsid off of that.

    It's is kinda tedious, but since you don't really have any control as to where in the registry your dll is registered, it is probably the quickest solution.

    Software is like sex, it's better when it's free - Linus Torvalds
    Software is like sex, it's better when I get paid for it. - me

  3. #3
    Join Date
    Oct 2001
    Posts
    6

    Re: wana implement custom validations routine in a dll

    This way i don't think it is going to help me 'coz even if i force to register in c:\myapp\plugins\ i need to ensure that client project should implement my class. now i need to take only those projects which has implemented my class



  4. #4
    Join Date
    Oct 2001
    Location
    Phoenix, AZ
    Posts
    54

    Re: wana implement custom validations routine in a dll

    You can. Testing for correct interfaces is why COM is so powerful. If the component in your directory doesn't support the interface, VB will throw error 429. Just handle the error and resume next.


    on error GoTo EH
    Dim myObj as Object
    set myObj = CreateObject("MyTestDLL.MyNewClass")
    set myObj = nothing
    Exit Sub
    EH:
    If Err.Number = 429 then
    set myObj = nothing
    resume next
    else
    MsgBox "error occurred: " & Err.Description & " . " & Err.Number
    set myObj = nothing
    End If





    Software is like sex, it's better when it's free - Linus Torvalds
    Software is like sex, it's better when I get paid for it. - me

  5. #5
    Join Date
    Oct 2001
    Posts
    6

    Re: wana implement custom validations routine in a dll

    Is there any way when the client registers his component there is a mapping created between my interface & his component coz' the round about way is fine and is working



  6. #6
    Join Date
    Oct 2001
    Location
    Phoenix, AZ
    Posts
    54

    Re: wana implement custom validations routine in a dll

    I'm sorry, I don't understand what you mean.

    Software is like sex, it's better when it's free - Linus Torvalds
    Software is like sex, it's better when I get paid for it. - me

  7. #7
    Join Date
    Oct 2001
    Posts
    6

    Re: wana implement custom validations routine in a dll

    i was saying that is there any way finding all the components from the registry that implements my interface


  8. #8
    Join Date
    Oct 2001
    Location
    Phoenix, AZ
    Posts
    54

    Re: wana implement custom validations routine in a dll

    I'm not sure. If there is, I'm not aware of it. If VB allowed for the defining of the self-registration function, you'd be able to register your libraries in a specific location in the registry. I haven't really looked at how an implementation class registers. If it registers with both its own GUID and the interface's IID, you might be able to differantiate between components with your interface definition. If it doesn't, I don't think you'd be able to find them.

    Maybe you could define a naming convention for components that implement your interface. Then you could search the registry for specific prefixed/suffixed CLSIDs.

    I'd be interested in knowing what conclusions you come to.

    Cheers,

    John

    Software is like sex, it's better when it's free - Linus Torvalds
    Software is like sex, it's better when I get paid for it. - me

  9. #9
    Join Date
    Oct 2001
    Posts
    6

    Re: wana implement custom validations routine in a dll

    hi john
    now the concept
    in VC++ there is the concept of component categories, which i am not able to figure out in vb. after defining a component category, in vc++ u can attach a class to that category.

    anybody who implements this interface or puts an entry in the com_map_entry then for him in the registry the component categories regid will be stored in the implemented categories key in the registry

    now comming to how am i plan implements this
    have a configuration file and a UI for that. now if a persone implements my interface let me know that he has implemented through the UI, before i store in my config db i will validate (since i got the progid and the classid).
    in my code when i have the classid i got everything
    one problem with this would be that if the user directly edits this file(i should check this at the run time of my main code)

    anyway thanks for the help


  10. #10
    Join Date
    Oct 2001
    Location
    Phoenix, AZ
    Posts
    54

    Re: wana implement custom validations routine in a dll

    no prob. So far, I haven't seen a way for an implementer to register a category. I doubt that there is a mechanism available to VB for doing so.

    Something else that may interest you. There is a component called Typelib Information that may make some things easier for you.



    Software is like sex, it's better when it's free - Linus Torvalds
    Software is like sex, it's better when I get paid for it. - me

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

Featured