|
If you have timelimits in learning and implementing the task, you better should use a high-level COM-Wrapper like MFC oder ATL, then you must not implement the standard-interfaced like IUnknown or IDispatch youself. I think there must be lots of examples on codeproject. The error-message tells you to implement the function OnShowMessageDlg(). This is a function call from the com-server into your com-client, so you need an implementation.
|
|
|
|
|
If you have timelimits in learning and implementing the task..
This is the main problem.
The COM server I must use is an .exe file. Is it the easiest way to create an new ATL project? Is there any Wizard with that I can implement the code from the .exe file / COM server in this new project? Until now I use OleView to create the .idl file from the COM server. Can I then use the files from the ATL project in my C++ project?
|
|
|
|
|
The easiest way to use a COM server that has a type library (which should be most of them) is to use #import[^].
The easiest way to implement a connection point sink (a.k.a. an event sink) is to use ATL and create a class derived from IDispEventSimpleImpl. See this post[^] of mine for an example that handles an event raised by Excel.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi All,
I am writing some shell extension that use COM object and faced with the following issue. I need to call some method from COM object but I get this error: "hResult 0x80070542 Either a required impersonation level was not provided, or the provided impersonation level is invalid. HRESULT" The same code works fine in console app, because I manually CoInitializeSecurity before call the method, but in shell extension I cannot call CoInitializeSecurity by myself becase I get error that it was already called. How can I setup neccessery permision for this COM object?
Thanks.
|
|
|
|
|
Hi All,
I’m an absolutely newbie in the COM technology and I have a little tricky question. I hope there’s someone out there who can help me with my problem. I have an .idl / .h / .c file and I integrated them in my VisualStudio 2005 C++ project. After that I’ve searched on the MSDN Library how I can connect an COM Server from my project. I’ve found a little example (http://msdn.microsoft.com/en-us/magazine/cc163361.aspx) and tried to do it on the same way. I’ve created an Csink class and tried to create an instance of this sink object to pass to the server. But the problem now I get from my compiler is the following error message: „error C2259: 'CSink': cannot instantiate abstract class due to following members: 'HRESULT IUnknown::QueryInterface(const IID &,void **)' : is abstract“. The thing I need is that I must call the „ OnShowMessageDlg “ and the „ OnConfigurationApply “ functions out of the .idl file in my main c++ function. I’ve put all the code here below this entry that could help you to become an overview about my problem. Is the solution I’ve tried with the sink object correct or should I use another way to do this?
Please let me know if you need any other information.
Thanks for ANY help.
*************************************************************************************************
.idl file
.
.
.
// TLib : // TLib : OLE Automation : {00020430-0000-0000-C000-000000000046}
importlib("stdole2.tlb");
// Forward declare all types defined in this typelib
interface ITEST2;
dispinterface ITESTEvents;
.
.
.
[
uuid(6775FB91-B5BE-11D6-A996-0050BA24C7B9),
version(1.1),
helpstring("Event dispatch interface for TEST")
]
dispinterface ITESTEvents {
properties:
methods:
[id(0x00000001)]
void OnConfigurationApply([in, out] VARIANT_BOOL* pAccept);
[id(0x00000002)]
void OnShowMessageDlg(
[in] IMsgDlg* pIMsg,
[out, retval] VARIANT_BOOL* Result);
};
.
.
.
.
coclass TESTv2 {
[default] interface ITEST2;
[default, source] dispinterface ITESTEvents;
};
*************************************************************************************************
.h file
.
.
.
EXTERN_C const IID DIID_ITESTEvents;
#if defined(__cplusplus) && !defined(CINTERFACE)
MIDL_INTERFACE("6775FB91-B5BE-11D6-A996-0050BA24C7B9")
ITESTEvents : public IDispatch
{
};
#else /* C style interface */
typedef struct ITESTEventsVtbl
{
BEGIN_INTERFACE
HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
ITESTEvents * This,
/* [in] */ REFIID riid,
/* [iid_is][out] */ void **ppvObject);
.
.
.
*************************************************************************************************
.c file
.
.
.
MIDL_DEFINE_GUID(IID, IID_ITEST2,0xF560F761,0x2948,0x11D7,0xA9,0xBF,0x00,0x50,0xBA,0x24,0xC7,0xB9);
MIDL_DEFINE_GUID(IID, DIID_ITESTEvents,0x6775FB91,0xB5BE,0x11D6,0xA9,0x96,0x00,0x50,0xBA,0x24,0xC7,0xB9);
MIDL_DEFINE_GUID(CLSID, CLSID_TESTv2,0xF560F763,0x2948,0x11D7,0xA9,0xBF,0x00,0x50,0xBA,0x24,0xC7,0xB9);
.
.
.
*************************************************************************************************
.c++ file
class CSink : public ITESTEvents
{
private:
DWORD m_dwRefCount;
public:
CSink::CSink() {m_dwRefCount = 0;}
CSink::~CSink() {}
void OnConfigurationApply(VARIANT_BOOL* pAccept);
void OnShowMessageDlg(IMsgDlg* pIMsg, VARIANT_BOOL* Result);
};
void main(){
.
.
.
CSink *pSink;
pSink = new CSink(); // ERROR MESSAGE
.
.
}
*************************************************************************************************
|
|
|
|
|
You need to implement the methods of the interfaces that ITESTEvents inherits from - that's going to be IDispatch, which in turn inherits from IUnknown. That's a fair bit of work...
There are a couple of CodeProject articles that might be of use: here[^] and here[^].
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks for your reply. I think, now the next step can be done.
|
|
|
|
|
Hello friend !!
I want to do show/hide of custom toolbar. I can do it in Windows XP by updating registry, but how can do this in windows 2000 with IE6.There are no menu for manage for add ons in IE6 with Win2000. So what is alternative way to manage add ons in windows 2000?
Thanks
ABM
|
|
|
|
|
When I loged in a site and clicked the url link in a webbrowser,
system launched a new IE windows but let me login again,
the cookies in the new windows has been lost.
How to pass session in a new IE process?
thanks.
There is some code below.
void CWebSee::OnNewWindow2Explorer1(LPDISPATCH FAR* ppDisp, BOOL FAR* Cancel)
{
TRACE("NewWindow");
*Cancel = FALSE;
IWebBrowser2* m_pWebBrowser2=NULL;
HRESULT hr = CoCreateInstance(CLSID_InternetExplorer, NULL,
CLSCTX_LOCAL_SERVER, IID_IWebBrowser2,
(void**)&m_pWebBrowser2);
if (hr == S_OK)
*ppDisp = (IDispatch*)m_pWebBrowser2;
hr = m_pWebBrowser2->put_StatusBar(VARIANT_FALSE);
hr = m_pWebBrowser2->put_ToolBar(VARIANT_TRUE);
hr = m_pWebBrowser2->put_MenuBar(VARIANT_FALSE);
hr = m_pWebBrowser2->put_Visible(VARIANT_TRUE);
...
|
|
|
|
|
Hi
I want to hide my custom toolbar on IE(all versions). I can hide standard IE toolbar by using
HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Internet Explorer\Toolbars\Restrictions
NoToolBar" Value = 1
which hides all standard button from IE. But i want to hide my Toolbar whenever browser starts and show it at particular site. So is there any way to hide by regedit by knowing the guid of toolbar.
Thanks
abc
|
|
|
|
|
Hello ,
I want to use #import "c:\program files\common files\myfile.dll for Windows XP and
#import "c:\WINNT\common files\myfile.dll for windows 2000.
if I use two statement at a time , compiler gives me error as "no such file". So how can I use both statement at a time.
Thanks
ABC
|
|
|
|
|
The location you use for #import depends on the OS you're building the project on - do you anticipate building the project on both Windows 2000 AND XP?
Alternatively, use the #import "libid:library UUID" syntax.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Yes , I want to build project on both Windows 2000 and Windows XP.
Thanks
abc
|
|
|
|
|
Well then, as I said, use the #import "libid:library UUID" syntax
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi Stuart !!
Thanks for ur reply ..
Can u give me about how to use above syntax with
#import "c:\Windows\System32\cdosys.dll" raw_interfaces_only
#import "c:\WINNT\system32\cdosys.dll" raw_interfaces_only
Thanks
abc
|
|
|
|
|
Same thing - open cdosys.dll in the OLE-COM Viewer (you'll find it either in your Visual Studio directory or in your Microsoft SDKs directory, both of which are in c:\Program Files) and look for the library's GUID.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi,
I am getting crash while copying a VARIANT type to _variant_t type. Can anybody help me with the possible reason?
|
|
|
|
|
How are you doing the copying?
If you're creating a new object you just use the constructor to do it.
VARIANT v;
_variant_t vt(v);
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Hi,
I used SHGetDesktopFolder to get IShellFolder of desktop. How can i use this interface to get IShellView of an different folder(eg:- C:\Test).I need this interface to select multiple items from the 'Test' folder.
Please advice.
Regards,
J
|
|
|
|
|
|
we are using any VB 6.0 com component through interop in asp.net web application. surprisingly it works fine
with the visual studio web server but does not work with IIS webserver. we also impersonate the machine user with highest privilages and other access permission but it still does not work and throw the COM interop exception.
Any help in this would be highly appreciated.
|
|
|
|
|
Hello,
I have been trying to find some resources for hosting a .NET winform control in a MFC \ COM app written in C++ 2003 (7.1). I could find help for .NET 2.0 and C++ 2005 but none for C++ 2003. Could anybody help?
Thanks in advance.
|
|
|
|
|
How to do the CoCreateInstance,when You have only the DLL path and name
say for example I have a Dll named xyz.dll
I just #import it and register it now how I will get its Class ID to do the CoCreateInstance.
Pleae HELP
|
|
|
|
|
There will be a structure in the code generated by the #import statement that represents the class. You can do __uuidof(that struct) to get its CLSID. Look at the example I have here using Excel:
#import "libid:00020813-0000-0000-C000-000000000046" version("1.6") auto_search no_dual_interfaces rename("DialogBox", "excelDialogBox") rename("RGB", "excelRGB") rename("DocumentProperties", "excelDocumentProperties") rename("SearchPath", "excelSearchPath") rename("CopyFile", "excelCopyFile") rename("ReplaceText", "excelReplaceText")
int _tmain(int argc, _TCHAR* argv[])
{
CoInitializeEx(0, COINIT_MULTITHREADED);
{
Excel::_ApplicationPtr xl;
if (SUCCEEDED(xl.CreateInstance(__uuidof(Excel::Application))))
{
}
}
}
HTH!
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thank You very much
But can you please tell me that how to get the IID our we get it in the similar manner.
m_pIDocument.CreateInstance(__uuidof(Excell::IApplication));
|
|
|
|