|
Use #import[^] to import TypeLibrary(.TLB file)
Sohail
modified 21-Apr-21 21:01pm.
|
|
|
|
|
Thanks Sohail,
Thanks for the good article.
I will implement and see.
Thanks
JK
|
|
|
|
|
OK. Let me know if you have further problems with this.
Cheers,
Sohail
modified 21-Apr-21 21:01pm.
|
|
|
|
|
You have to import the tlb file to ur VC++
I declare it in header file.
#import "C:\myDll\mydll.tlb" raw_interface_only
...
..
public Void INiComObj()
{
CoInitialize(NULL);
HRESULT hr = CocreateInstance(CLSID...)
}
|
|
|
|
|
Hi Sohail,
Thanks for the good article.
And thanks to pnp for giving the sample code.
I did import my tlb file with raw_interface_only option.
#import "C:\temp\Mytlb.tlb" raw_interface_only
I am facing following compilation error in *.tlh file.
error C2504: 'AnyObject' : base class undefined
When I see my tlh file my class is deriving from AnyObject base class.
I am not sure why it is deriving from AnyObject?
Is there any base class "AnyObject" in C++? If yes what are the include files i need to include? Please help me.
Thanks in advance.
Regards
JK
|
|
|
|
|
Hi All,
I found out the solution for error C2504: 'AnyObject' : base class undefined
My tlb is dependent on some other tlb so, what i did is I #import the base tlb before importing my tlb. It complies fine. There are no errors.
But, I am not able to get pointer to my COM object, when I am running following sample code
CoInitialize(NULL);
IMyComObject pObject(_uuidof(MyComObjectName));
I am getting following error in CoCreateInstance method
0x80040154 Class Not Registered
I checked the registry, there is an entry for my typelib.
I am not sure why it is not able find the class.
Any suggestions/help please..
Thanks in advance
JK
|
|
|
|
|
Jahnson K wrote: I am getting following error in CoCreateInstance method
0x80040154 Class Not Registered
The TLB describes the all data of COM server, but there is no code in TLB. You should also register COM server, i.e. EXE or DLL executable module.
With best wishes,
Vita
|
|
|
|
|
Thank you all,
I am able to get the COM object.
There was couple of mistates I was doing while creating CoCreateInstance.
Now it works fine.
Thanks
JK
|
|
|
|
|
there are two ways
1)Use #import <typelibrary.tlb>
second you can use the class wizard and refer the tlb file, the wizard will generate the .cli and .clh file containing the wrapper around your COM component
Regards,
Sunil Tonger
|
|
|
|
|
Hello friends,
I am working on CRM application that uses the 3rd party TAPI OCX(topTAPI).
All the features related to call control like call answer,call end,call
hold,call unhold works good.But the transfer and conferencing functions
of this ocx doesn't working.If anyone of you guys had used topTAPI ocx
earlier then kindly tell me the problem.I've read its documentation
properly and it doesn't allow me to initialize any of the conferencing
related functions.
OR
If anyone has the solution apart from topTAPI please let me know.
The sample code would be appreciated.
Thanks in Advance.
ritz1234
|
|
|
|
|
Hi all
I'm calling IPersistFile:Save on my local machine logged in with administrator rights and I'm getting a security error any ideas would be very welcome.
I'm using VS2005 on XP SP2
Here's the code, it's basically pulled out of the VS documentation:
HRESULT CShellLink::CreateLink(LPCSTR lpszPathObj, LPCSTR lpszPathLink, LPCSTR lpszDesc, LPCSTR lpszArgs)
{
HRESULT hres;
IShellLink* psl;
::CoInitialize(NULL);
hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
IID_IShellLink, (LPVOID*)&psl);
if (SUCCEEDED(hres))
{
IPersistFile* ppf;
psl->SetPath(lpszPathObj);
psl->SetDescription(lpszDesc);
psl->SetArguments(lpszArgs);
hres = psl->QueryInterface(IID_IPersistFile, (LPVOID*)&ppf);
if (SUCCEEDED(hres))
{
WCHAR wsz[MAX_PATH];
if ( ! MultiByteToWideChar(CP_ACP, 0, lpszPathLink, -1, wsz, MAX_PATH)) {
DisplayLastError();
} else {
hres = ppf->Save(wsz, TRUE);
if ( ! SUCCEEDED(hres)) {
DisplayLastError();
}
}
ppf->Release();
}
psl->Release();
}
return hres;
}
Cheers
Tom
Philosophy: The art of never getting beyond the concept of life.
Religion: Morality taking credit for the work of luck.
|
|
|
|
|
TClarke wrote: I'm calling IPersistFile:Save on my local machine logged in with administrator rights and I'm getting a security error any ideas would be very welcome.
I'm using VS2005 on XP SP2
Since it is a security error, I think it is important to know where you are saving to. Even as an administrator, there are parts of the system you aren't allowed to modify.
Nathan
|
|
|
|
|
I'm getting the same error on W7 using VS 2008 and the same sample code. I am writing to a temp folder with security set to all access for "Everyone" from a shell running with Administrator priviledge. It still doesn't work.
Probably, as usual, MS sample code is incomplete, or not even wrong.
-Geoff
|
|
|
|
|
Hello all, I know the experts on codeproject can deal with any of my sneaky questions... try this one:
What .tlb is the definition of IDataObject in?
Why do I need it: I have my own interface with IDataObject as an argument of one of its methods. The type library compiled from that .idl contains beside my own interface also IDataObject and a couple of others, which are referenced by it. As a consequence, the proxy for that interface is wrong and drag and drop stops functioning in my app . I tried to find a type library to put in importlib("") statement, but did not find it. There must be something obvious I am overlooking.
Thanks for any advice
|
|
|
|
|
Vlasta_ wrote: Why do I need it: I have my own interface with IDataObject as an argument of one of its methods. The type library compiled from that .idl contains beside my own interface also IDataObject and a couple of others, which are referenced by it. As a consequence, the proxy for that interface is wrong and drag and drop stops functioning in my app . I tried to find a type library to put in importlib("") statement, but did not find it. There must be something obvious I am overlooking.
I can think of a couple other options. One is to provide custom marshaling for your method. Another is to just pass an IUnknown and query for IDataObject in your code. I tried to find the tlb for IDataObject and I couldn't find it either.
Nathan
|
|
|
|
|
Thanks, I may end with the IUnknown workaround, but I am still hoping to locate the tlb somwhere.
|
|
|
|
|
Look at ...\Microsoft Visual Studio\Common\IDE\IDE98\VJEXT.TLB
With best wishes,
Vita
|
|
|
|
|
I've a component(dll) has developed in vb. I can able to refer the dll and the method can be called in vb. I've checked its working fine. But in asp I've created object using Server.CreateObject and when I call the same method, it shows "permission denied" error. If anybody having idea pls. help me.
Rishihar S
WinCrs
|
|
|
|
|
|
Hi,
I have one MDI application TrialApp.exe and a COM exe MathOperation.exe.COM exe was generated through ATL.Now from a modeless dialog in TrialApp.exe i am accessing a model dialog in MathOperation.exe.
1.Run TrialApp.exe
2.Modeless dialog pops up.
3.Enter the input values.
4.Press a button->calculate.
5.Pops up a dialog from MathOperation.exe
6.Now without closing the dialog(from MathOperation.exe) just click on the modeless dialog(TrialApp.exe)
7.Shows server busy message.
This happens in XP and Vista.If i make the dialog model in TrialApp.exe then the message is not coming.Please help.
Thankyou
modified on Wednesday, March 19, 2008 1:30 AM
|
|
|
|
|
I may not be correct here because I don't know how your COM server is implemented (design/architecture)
I believe your TrialApp.exe dialog is making a blocking call to MathOperation.exe (specifically it's waiting for MathOperation.exe method to return, but this method has an active Modal dialog).
Sohail
modified 21-Apr-21 21:01pm.
|
|
|
|
|
I wrote an ActiveX Control, I hope it can show different picture every 10 seconds. So I start a work thread, it prepairs the picture's data and calls the control's FireViewChange method every 10 seconds.
Now it seems like that FireViewChange call does not work because the picture that control shows out won't change until I resize the test web page.
My control is apartment thread mode and I call CoInitialize(NULL) in my work thread.
What changes should I do to make my control work as I want? Thank you.
|
|
|
|
|
Hello samfromcn,
It is possible that you have not marshalled the ActiveX's event interface (which contains the FireViewChange() method) to your worker thread.
- Bio.
|
|
|
|
|
Thank Bio,
Someone said that FireViewChange interact with the container, then the container tells the control to redraw. It's a little complicated for me. Now I create a hide window in main thread, work thread send user message to the window, the window call control's FireViewChange. This is easy to implement and it works well^_^.

|
|
|
|
|
Hello samfromcn,
>> Someone said that FireViewChange interact with the container...
Yes, the "container" is actually what we know of as the "apartment". It is a good analogy.
>> Now I create a hide window in main thread, work thread send user message to the window, the window call control's FireViewChange...
This will certainly work. It also works similarly to the actual industrial practice of firing an event from across a separate thread via a proxy to the event interface of the ActiveX marshalled in from the main thread.
However, samfromcn, it is better to learn event interface marsalling in the long run.
Best of luck,
- Bio.
|
|
|
|