|
I do not have enough information to answer your question. I don't really know what your question is.
Is Object *po; a global variable?
What is CreateInstance? Where is it called.
When you mention po->QueryInstance , do you mean QueryInterface?
If you can give me a little more information, I will try to help you.
Checkout my Guide to Win32 Paint for Intermediates
|
|
|
|
|
As kilowatt said your code is not clear,but I know one thing,You have to type cast the IUnknown interface to your proper interface.
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 have a function in my COM object, written on C++ Foo(int *retval1, int *retval2) . All I need now is to call this from VB. But something wrong goes here. VB says "ByRef type mismatch". What type of parameters should I have in my C++ function, to make it available for VB?
I need to return some values in those parameters. It is simple integers, but how to declare it?
Philip Patrick
Web-site: www.saintopatrick.com
"Two beer or not two beer?" Shakesbeer
Need Web-based database administrator? You already have it!
|
|
|
|
|
Just guess:
You don't need to change your C++ functions.In your VB code use CInt
this is from MSDN:
Dim MyDouble, MyInt
MyDouble = 2345.5678 ' MyDouble is a Double.
MyInt = CInt(MyDouble) ' MyInt contains 2346.
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
|
|
|
|
|
Yeah, found it too. The problem was *laughs* I dunno why, but VB treats Long and Integer as a different types, and int in C++ is actually Long in VB.... I'd say this is very strange, don't see any logic, lol
Philip Patrick
Web-site: www.saintopatrick.com
"Two beer or not two beer?" Shakesbeer
Need Web-based database administrator? You already have it!
|
|
|
|
|
Hi, Mazdak:
I am still some confused about how to access object from other objects.
For example, I want to biuld two objects, one is used to access database ( some private variables such as _connentionPtr _CommandPtr were used), another used to implement rules. But how to realize it. How to pass pointer such as _ConnectionPtr, _CommandPtr from data access object to rules realization object.
If you are convinient, can you send me some examples by email. I am a new learner and find it is very difficult to find such exmaples in website.
Thank you very much for your consideration.
Qiang
|
|
|
|
|
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
|
|
|
|