|
-
Sep 10th, 2002, 01:47 PM
#1
Thread Starter
Fanatic Member
GetOBject for my own DLL
Helo everybody.. we have all seen the getObject function work on apps like excel and word. Now.. I want to use it for my own DLL. So far I created the DLL ActiveX. Then in another project I create an instance of that DLL. Then in a third project I use the getObject function to grab a reference of that DLL created in the second project... but it tells me it cannot create the activex....
what am I missing?
Thanks
"The difference between mad and genius is the success"
-
Sep 10th, 2002, 01:49 PM
#2
hold on a few minutes..let me dig up the code.
-
Sep 10th, 2002, 01:50 PM
#3
Thread Starter
Fanatic Member
thanks!
"The difference between mad and genius is the success"
-
Sep 10th, 2002, 01:52 PM
#4
put this code in every class that you need to use GetObject on in your dll and change VegaCOMM.clsSocket to yourprojectname.classname
That should do it.
Code:
' Declares needed to register object in the ROT
Private Const ACTIVEOBJECT_STRONG = 0
Private Const ACTIVEOBJECT_WEAK = 1
Private Declare Function CLSIDFromProgID Lib "ole32.dll" (ByVal ProgID As Long, rclsid As GUIDs) As Long
Private Declare Function CoDisconnectObject Lib "ole32.dll" (ByVal pUnk As IUnknown, pvReserved As Long) As Long
Private Declare Function RegisterActiveObject Lib "oleaut32.dll" (ByVal pUnk As IUnknown, rclsid As GUIDs, ByVal dwFlags As Long, pdwRegister As Long) As Long
Private Declare Function RevokeActiveObject Lib "oleaut32.dll" (ByVal dwRegister As Long, ByVal pvReserved As Long) As Long
Private OLEInstance As Long
Private Sub Class_Initialize()
Dim typGUID As GUIDs
Dim lp As Long
OLEInstance = 0
' This code is responsible for creating the entry in the rot
lp = CLSIDFromProgID(StrPtr("VegaCOMM.clsSocket"), typGUID)
If lp = 0 Then
lp = RegisterActiveObject(Me, typGUID, ACTIVEOBJECT_WEAK, OLEInstance)
End If
End Sub
Private Sub Class_Terminate()
' Once we are done with the main program, lets clean up the rot
' by removing the entry for our ActiveX Server
If OLEInstance <> 0 Then
RevokeActiveObject OLEInstance, 0
End If
CoDisconnectObject Me, 0
End Sub
-
Sep 10th, 2002, 01:56 PM
#5
Thread Starter
Fanatic Member
It sends me an error in the third line saying the data type hasent been defined....
do you knwo why?
I am looking for it...
"The difference between mad and genius is the success"
-
Sep 10th, 2002, 01:58 PM
#6
oopss sorry forgot one part
Code:
Private Type GUIDs
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(0 To 7) As Byte
End Type
-
Sep 10th, 2002, 02:01 PM
#7
Thread Starter
Fanatic Member
Thanks... it runs with no error.. but I still cant get the reference....
would it be too much to ask if you have an example?
Thanks
"The difference between mad and genius is the success"
-
Sep 10th, 2002, 02:01 PM
#8
Thread Starter
Fanatic Member
wait.. I am such an idiot.. I havent replaces my class name...
ooppps
"The difference between mad and genius is the success"
-
Sep 10th, 2002, 02:03 PM
#9
well there is really no example. beause all you have to do is
Dim myobj As Object
Set myobj = GetObject(,"yourproject.classname")
-
Sep 10th, 2002, 02:04 PM
#10
Originally posted by Andreex
wait.. I am such an idiot.. I havent replaces my class name...
ooppps
-
Sep 10th, 2002, 02:06 PM
#11
Thread Starter
Fanatic Member
it works better than bread and butter!!!
nice work man!
"The difference between mad and genius is the success"
-
Sep 10th, 2002, 02:07 PM
#12
coolness..you are lucky. It took me 7 months to find that code.
-
Nov 13th, 2019, 09:28 AM
#13
New Member
Re: GetOBject for my own DLL
I know this post is really old, but I'm trying to implement this in VB.net. Several of the items are no longer supported in VB.net. Has anyone done something similar in VB.net??
-
Nov 13th, 2019, 03:28 PM
#14
Re: GetOBject for my own DLL
you would probably be better to post a new thread in the .net forum,, with a link to this old thread
a moderator will probably do this for you
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Nov 13th, 2019, 04:30 PM
#15
Re: GetOBject for my own DLL
Actually, I think what would be best here is just to start the thread yourself and add a link to this thread if you feel it is appropriate. The question asked lacks enough information without this thread for it to stand on its own, so just moving it would result in a thread that required people to read this thread just to understand what was being asked. Further, this thread is so old that things have likely changed in the intervening 17 years.
So, start a new thread on the topic, it would be the best way to get an answer.
Also, I guess I should add that I'm not quite clear what it is that you want to implement. This thread could be read as talking about a plugin system, which would have a different, though straightforward implementation in .NET. On the other hand, the specifics of the question might have a different implementation.
My usual boring signature: Nothing
 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|