|
chq12 wrote:
another used to implement rules. But how to realize it.
Sorry,what do you mean by rules?
I have sample code that work with ADO objects in a COM object,and pass from client to server.Yuo can tell me your email to send it for you.
If you want to use first COM object in second one use CreateInstance() in the Method you to use it and create first object in second one and here you can access to Methods and properties of first object.Imagine second COM object as a simple client application and first one is a regular COM onject.
You can pass _ConnectionPtr,_CommandPtr as parameter I don't THINK there is limitation for it,whats your problem for that?
Again use CreateInstance() to initialize them and pass it to COM object.In my application I pass strings to COM object and use those strings for _ConnectionPtr or _CommandPtr ,I think this really safer and better than passig the _ConnectionPtr and _CommandPtr themselves. I think its waste time and codes to create two object and use one for only pass those objects,you can pass simple strings and use them in one object.
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
Thanks, Mazdak. I think I can use parameter to transfer _ConnectionPtr and _CommandPtr. I want to this because i want to create a database access object which including method to get conncetion with database and some common used method such as create a parameter,then other objects can access it to get connection with database. So it is much easier to extend program and mantain it.
My email address is: dav258@hotmail.com, I am a new learner and want to get some examples. if you are convinent, please send me your sample code to me.
Thanks again.
Qiang
|
|
|
|
|
dear someone,
I wrote a ActiveX Server Component using ATL in VC6. It was meant for and intranet mailing system and was supposed to read and write my own email files(.eml).
When I test the COMp using an MFC exe, everything works fine..., but when I test the same with ASP script, it works fine for the first 2 times. Then the web service is stopped and the Management Console gets frozen.
I tried using the CCriticalSection's lock and unlock.
I also tried by terminating the FILE I/O in the OnEndPage function.
The same component works fine if I am not letting it to read or write to any FILE.
As I am a novice in COM, I would like to know how and where exaclty the problem is....
Please help me sort out this problem at the earliest...n' i'LL BE VERY GRATEFUL TO YOU
hAmMeR tHe MaDdOg
tHe pArAnOiDaL pRogRaMmEr
|
|
|
|
|
I also tried the ATL, ASP Component for Search Engine in that i had experience that ATL Component is not freeing the memory after using it in ASP Script.
So as many times you use component it is unable to free memory although your OnStartPage and OnEndPage works happily.
For that check out the TaskManager in that dllhost or inetinfo.exe takes lot of memory.
ravi
|
|
|
|
|
Looking for a good book on COM. The ideal book would be on a slightly higher level than Inside COM (Rogerson) and would give a thorough description of the apartment models and marshalling. It would also be nice with something on COM with ATL (another book?).
Thought about Inside OLE 2 (Brookschmidt). Is that one still of immediate interest?
Any suggestions appreciated.
Thanks
/moliate
|
|
|
|
|
Definitely, Learning Dcom from OReilly is what you want, very good explainations of com apartment models, marshaling , pure com and MFC and ATL programming, after thisyou can try the atl books.
Check my aswer to Nish about the other books that I recommend:
http://www.codeproject.com/lounge.asp?forumid=1159&select=96575&tid=96534#xx96575xx">http://www.codeproject.com/lounge.asp?forumid=1159&select=96575&tid=96534#xx96575xx
Learning Dcom amazon link
Note1: Don't consider the bad reviews, are just no sense, the book is good , it's easier to understand than the bible on COM "Essential COM" by Don Box.
I own 8+/- books on COM and ATL and I assure you for what you are asking you are not going to be disappointed !
Cheers,
Cheers,
Joao Vaz
|
|
|
|
|
Thank you for your recommendation!
Got the book today and it looks good. Also a reasonable price - you really saved me some money today...
/moliate
|
|
|
|
|
How can I find out who is calling my VC++ DCOM object?
It is running as a service logged on as a local user.
Still a newbee!
|
|
|
|
|
I have a C++ dll that interfaces with a main VB program. This VB program always has an ADO connection open. The dll also needs to use a connection to the same database.
How can I pass the open ADO connection from VB to the c++ dll (through COM) so i can use the connection in c++?
Cheers,
Dave
|
|
|
|
|
Anonymous wrote:
I have a C++ dll that interfaces with a main VB program
What is that dll? Is that one of standard dll's like msado15.dll or you wrote it yourself?
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
I wrote the dll myself, it has a specific (and time consuming) processing task, that the VB program utilises.
-dave
|
|
|
|
|
ADO connection is an string.you can pass it as simple string to your dll,But all of it depends on how you implement yout methods.
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
I mean, the actual ADO Connection object (in vb, dim connObj as ADODB.Connection for example of the object i'm talking about.)
The current situation is: both the vb code and the dll using the same database (out of necessity), each connecting separately. I would like to let vb create an open ado database connection (supply it a connection string and go .open), then have the vb code pass the open connection COM object (or a pointer to it?) to the C++ dll.
Cheers,
Dave
|
|
|
|
|
Ok, I've not tried this, but import the ADO type library doing something like this...
#import "c:/program files/common files/system/ado/msado15.dll" no_namespace rename("EOF", "EndOfFile")
Then you need an input parameter to hold the pointer to it. I suppose you could use an IUnknown pointer, but then why not just use a _Connection pointer instead (you'll see it at the top of the msado15.tlh).
So, in your IDL should be a line like...
[id(2), helpstring("method GetField")] HRESULT GetField([in] _Connection * pAdoCn, [in] BSTR bsFieldname, [out, retval] BSTR * pbsVal);
Then you can just use that pointer. (Attach the COM Smart Pointer to it though and your life will be easier... ConnectionPtr.Attach(...))
In the event that that doesn't work though, try it with IUnknown * pUnk instead, then do a QueryInterface() on it, passing the Connection Interface to it.
Good luck,
S
|
|
|
|
|
I am trying the first _Connection method you suggest, so what should i pass from the vb side?
If i implemented your suggestion, would the vb side be something like this?
dim fred as new adodb.connection
fred.open blah blah blah
somestring = getfield(fred, anotherstring)
Cheers,
Dave
|
|
|
|
|
Dave,
Yes, that should do the trick. If it fails then you have a few options including...
1) Making it IUnknown in C++ then in VB do this
dim fred as new adodb.connection
dim oFred as Object
fred.open blah blah blah
set oFred = fred
somestring = getfield(oFred, anotherstring)
(Set in VB is much akin to QueryInterface in C++)
2) Make it a Variant in C++ containing either IUnknown or IDispatch then do the same as above but Dim oFred as a Variant instead.
I haven't done exactly this before (I've done it with my own custom objects) but the principal should be the same.
Also, make sure that you do a _Connection.AddRef() at the beginning and .Release() at the end of your processing in C++ as you will be a COM Client in this case. Not doing this may yield all sorts of nastiness if VB decides it can let go of the Connection in the mean time.
Good luck,
Sam
|
|
|
|
|
This may not be a true COM question, but I am trying every source I can find to try to solve this one:
I am completely frustrated!
I have read from several sources, that you can use the GetIRichEditOle() function to get to the ITextDocument interface for a CRichEditCtrl.
I am using VC 6, and the RichEdit version looks like it is 3.0.
I am using the following code:
ITextDocument *pTextDoc = NULL;
IRichEditOle * ire = m_RichEdit.GetIRichEditOle();
if ((ire == NULL) || (ire->QueryInterface(IID_ITextDocument, (void**) &pTextDoc) != S_OK) || (pTextDoc == NULL)){
DWORD dwErr = GetLastError();
if (ire != NULL)
ire->Release();
TRACE("Failed ITextDoc\n");
}
The pTextDoc is always NULL. The GetLastError() returns 0.
I have also tried the method specified in MSDN, but it fails also. The method they use is very similar to the above code, so that's no surprise.
I am getting desperate! I need to get the ITextDocument interface to do some things like set the line spacing.
Please, if anyone knows how to do this, let me know.
Thank you very much,
David
|
|
|
|
|
I want to create search engine which will be used for searching xls,ppt,txt,htm,pdf,doc files base on search keyword.
For this specification i would like to create component as inprocess server and it should operate on companies intranet. So anybody guide me how to create the component weather by using IFilter index server of microsoft. If you have any guidance about IFilter or any other will be very useful for me.
|
|
|
|
|
I want to build three objects, one is common and want to be used by other two objects. How can i access from one object to another object
|
|
|
|
|
Reusing COM objects
.
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
Can you tell me something in detail. I want to access from one object to other objects.
What mechanism it is and What API i need?
|
|
|
|
|
I suggest you Containment that is easier.Do you know how to use your COM object in client application?Thats exactly the same.Use CreateInstance() in your second component to iniatilize the first component.If you have any problem to use it just ask.
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
Mazdak, Thank you very much. I'll try on it.
|
|
|
|
|
Hi,
I'm having a problem in COM EXE.
I create a new worker thread that loops and listens to messages. during shut down I release pointers defined in its scope, and call CoUninitialize.
but it seems to get stuck there. (The function who stops the thread waits until the worker thread is signaled, that happens only after couninitialize, which is the last line in the worker thread)
is there any deadlock associated with it? or I have not released everything? I checked and it seems i have released all.
can you supply me with directions for thought what is wrong there?
Thanks.
Sefi p.
|
|
|
|
|
Hi all,
in the code below, hToken is an impersonation token which I
duplicate into a primary token in order to use with
CreateProcessAsUser. I ask the new token to have the
DELEGATION level of impersonation but I get error 1346 :
ERROR_BAD_IMPERSONATION_LEVEL. NTLM is running on W2K as
the SSP provider, but it seem that delegation is not supported. Is it possible to have the impersonation level with CLOAKING enabled with NTLM ? does this provide a
one hop machine-cross delegation level (which is sufficient for my server) ? All this is done with a calling from an ASP page, how can i set the impersonation level for the client ?. All this confuse me, thank to bring some light ...;)
if ( !DuplicateTokenEx(
hToken, // handle to token to duplicate
TOKEN_ALL_ACCESS | TOKEN_QUERY |
TOKEN_ASSIGN_PRIMARY | TOKEN_DUPLICATE,
NULL,
SecurityDelegation,
TokenPrimary,
&hDup ) ) {
err = GetLastError();}
|
|
|
|