|
I like the way to use COM wrapper class which the ClassWizard produce for me, but I cannot figure out how to implement the connection point through it. The COM events are all been commented out saying
// method 'ExecutionOver' not emitted because of invalid return type or parameter type ,...
kind of boring, anyone has some idea?
thanks in advance
|
|
|
|
|
I'm trying to set a property in the following class:
Public Class CEventObj
Member of mshtml
The property is:
Public Property returnValue As Object
Member of mshtml.CEventObj
When I try:
Dim objevent As New mshtml.CEventObjClass() OR
Dim objevent As New mshtml.CEventObj() OR
Dim objevent As New CEventObjClass() OR
Dim objevent As New CEventObj()
I get the following error, also the CSLID from the Object Browser of 3050F558-98B5-11CF-BB82-00AA00BDCE0B is different from the COMException error message
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in Test Form .exe Additional information: COM object with CLSID {3050F48A-98B5-11CF-BB82-00AA00BDCE0B} is either not valid or not registered.
The Registry states the CSLID 3050F48A-98B5-11CF-BB82-00AA00BDCE0B from COMError message is the following:
HKEY_CLASSES_ROOT\CLSID\{3050F48A-98B5-11CF-BB82-00AA00BDCE0B}...
default(not set)
HKEY_CLASSES_ROOT\CLSID\{3050F48A-98B5-11CF-BB82-00AA00BDCE0B}\InprocServer32...
Assembly(Microsoft.mshtml, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
Class(mshtml.CEventObjClass)
Runtime version(v1.0.3705)
The Registry states the CSLID 3050F558-98B5-11CF-BB82-00AA00BDCE0B from the Object Browser view is the following:
HKEY_CLASSES_ROOT\Interface\{3050F558-98B5-11CF-BB82-00AA00BDCE0B}
default(DispCEventObj)
HKEY_CLASSES_ROOT\Interface\{3050F558-98B5-11CF-BB82-00AA00BDCE0B}\ProxyStubClsid...
default(00020420-0000-0000-C000-000000000046)
HKEY_CLASSES_ROOT\Interface\{3050F558-98B5-11CF-BB82-00AA00BDCE0B}\ProxyStubClsid32...
default(00020420-0000-0000-C000-000000000046)
HKEY_CLASSES_ROOT\Interface\{3050F558-98B5-11CF-BB82-00AA00BDCE0B}
TypeLib(3050F1C5-98B5-11CF-BB82-00AA00BDCE0B)
Just to be sure I ran regsvr32 mshtml.dll sucessfully
What is going on? the CSLId from the COMException InprocServer32 points to Class(mshtml.CEventObjClass). H E L P!
Thanks, GregC
|
|
|
|
|
Hi all,
I have a Windows 2000 Service that can be accessed via a COM interface. In fact I used the "DrawServ" example from the MSDN as a pattern for this. Talking to the service with this COM object works fine, like this (VB in an Excel sheet):
Dim myService As CMyServ
Set myService = New CMyServ
test = myService.getLong() 'simply returns a long
Now I tried to create a more complex method call that should return another COM object.
Dim doc As CMyDocument
doc = myService.getDocument()
For this I had to create a new type in the IDL but using the ATL wizard delivered many errors (missing header files, etc.). So I decided to make all type declarations / definitions for CMyDocument manually (IDL is appended below).
Now my first question is: Where shall I create the document object?
In VB like this?:
Dim doc As CMyDocument
Set doc = New CMyDocument
doc = myService.getDocument()
Or in the implementation of getDocument() using CoCreateInstance()?
Anyway (and I tried both ways!) whenever I'm asking for memory for a CMyDocument the appropriate call needs about 15 seconds only to tell me that "something went wrong". In Basic I get a runtime error without an error code, in VC++ I get CO_E_SERVER_EXEC_FAILURE (=0x80080005L) as a result index.
This leads me to my second question: What's wrong?
Of course all necessary registration and initialization has been done, has it? I'm checking this the whole day...
Any help is appreciated,
thanks in advance,
Tobias
Here is an excerpt (only the important lines) of my IDL:
[
object,
uuid(3CB0E4BF-675A-4d5a-BC23-440F2B92BF5A),
dual,
helpstring("IMyDocument Interface"),
pointer_default(unique)
]
interface IMyDocument : IDispatch
{
import "oaidl.idl";
[propget, id(1), helpstring("property ID")] HRESULT ID([string, out, retval] char ** pVal);
[propput, id(1), helpstring("property ID")] HRESULT ID([string, in] char * newVal);
}
[
object,
uuid(330E9E75-DF48-11CF-8E2C-00A0C90DC94B),
dual,
helpstring("IMyServ Interface"),
pointer_default(unique)
]
interface IMyServ : IDispatch
{
import "oaidl.idl";
[
id(3),
helpstring("method getLong")
]
HRESULT getLong([out,retval] long* result);
[
id(4),
helpstring("method getLastUsedDocuments")
]
HRESULT getDocument([out,retval] IMyDocument** document);
};
[
uuid(330E9E73-DF48-11CF-8E2C-00A0C90DC94B),
version(1.0),
helpstring("MyServ 1.0 Type Library")
]
library MySERVLib
{
importlib("stdole32.tlb");
[
uuid(330E9E79-DF48-11CF-8E2C-00A0C90DC94B),
helpstring("MyServ1 Class")
]
coclass CMyServ
{
[default] interface IMyServ;
};
[
uuid(554B6D8F-C8CC-487f-892D-EBF500107242),
helpstring("MyDocument Class")
]
coclass CMyDocument
{
[default] interface IMyDocument;
}
};
|
|
|
|
|
Well, I fixed it finally. Or let's say: I found out.
First of all I decided to try it with the ATL wizard again, removing all errors it created - and that was a long walk...
Anyway the main problem remained.
By chance (!) I found that all works fine, if all char's are declared as unsigned char's. Mmhh...
But that just opened another problem: VB could not deal with it! The property ID of a CMyDocument could be set but not read. Finally I figured that out, too: You need to declare strings as BSTR in the IDL.
Conclusion: OK, I'm really not too experienced with COM and VBA and with transferring data from VB to C++. But for those out there who knows Eclipse: I hope for your sake that you never ever have to work with the .NET IDE. The wizards there are full of black magic...
Bye,
Tobias
|
|
|
|
|
Hi,
I've got a problem, calling via remoting, a COM+ which activation is type library. I configure the client application and the web.config file, then I make the call, and that's ok. The problem appears because my COM+ application has to read information from a configuration file. My first attempt to solve this, was to introduce this information in the web.config file, but it doesn't work. The fact is that the configuration file which it's been read is aspnet_wp.exe.config, instead web.config.
I am creating the COM+ through a wrapper. When I call the wrapper, it is executed in one AppDomain, but when the wrapper creates the instance of the component, the AppDomain is changed to the Default AppDomain, changing also the configuration file used.
I hope to give enough information (and understable!!!;P) If you need further information, please, don't hesitate asking me.
Thanks,
Ivan.
Iván Fernández
|
|
|
|
|
i want to get some information about remote machine.
so wmi(Windows Managment Instruments) can provide what i want.but i don't if it can access wmi on remote machine outside of lan network by ip.
who can tell me?thanks?
Habbit--Beginner In MFC
|
|
|
|
|
Hi,
is there anyone who knows how to catch
outlook events by using the dipinterface and
the typlibraries from outlook (msoutl9.olb - OLE-Viewer)
Thanks a lot !
|
|
|
|
|
class CFriendSession is derived from class CCmdTarget
In CFriendSession constructor call:
BOOL bRet = AfxConnectionAdvise(m_ISession, IID_ISessionEvents, m_session_sink, FALSE,&m_session_cookie);
In CFriendSession destructor call:
BOOL bRet = AfxConnectionUnadvise(m_ISession, IID_ISessionEvents, m_session_sink, FALSE,m_session_cookie);
terminate the connection.
when class CFriendSession is directly generated and freed by some process,process could quit normally.
When class CFriendSession embeded in some Dll, generated and freed by the process which load the Dll,process could not quit completely.
Why?
I need help.
|
|
|
|
|
Sounds like your not calling Release on some interface. The DLL would not be unloaded until the ref count for each COM object is 0, which means the process probably won't exit.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Maybe you are right.
But the problem is that I have called Release on all interfaces used.
And you know, the process runs ok when it use connection point directly
but not in Dll.
But when use connection point in Dll, problem occurs.
I can tell you the details.
class CFriendSession is in Dll.
In constructor of CFriendSession I use:
---------------------------------------------------------------------------
OleInitialize( NULL );
COleException *e = new COleException;
try
{
HRESULT hr = m_ISession.CreateDispatch(CLSID_JabberSession, e);
ASSERT(SUCCEEDED(hr));
}
catch( COleDispatchException * e )
{
e->Delete();
}
//Get a pointer to sinks IUnknown, no AddRef.
m_session_sink = GetIDispatch(FALSE);
BOOL bRet = AfxConnectionAdvise(m_ISession,IID_ISessionEvents, m_session_sink, FALSE,&m_session_cookie);
e->Delete();
-------------------------------------------------------------------
in the destructor of CFriendSession, I use:
------------------------------------------------------------------
BOOL bRet = AfxConnectionUnadvise(m_ISession, IID_ISessionEvents, m_session_sink, FALSE, m_session_cookie);
m_ISession.ReleaseDispatch();
------------------------------------------------------------------
I found when I call m_ISession.CreateDispatch, the problem will occure.
But I do call m_ISession.ReleaseDispatch() in destructor of CFriendSession.
So, I couldn't find which interface I did not release.
I want to know your opinion.
Also, thanks for your kind help.
|
|
|
|
|
You said the problem occurs when you call m_ISession.CreateDispatch . What is the HRESULT that is returned, though? You could also try catching CException to make sure that you catch every error that occured and, while debugging, check out the information about the exception. Perhaps more information about the problem will be available.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hello Everyone,
I need your sincere help in finding the suitable header file
for the wsnprintf() method. For finding the Domain Users in
Microsoft Active Directory Services(ADSI), i called the ADSI API i.e. FindUsers() to fetch the list of user objects
from a container or directory tree. For that the FindUser()
API code has used the method i.e. wsnprintf() for adding the filter.
RESULT FindUsers(IDirectorySearch *pContainerToSearch, // IDirectorySearch pointer to the container to search.
LPOLESTR szFilter, // Filter for finding specific users LPOLESTR *pszPropertiesToReturn, // Properties to return user objects found.
BOOL bIsVerbose)
This FindUsers() is the API where the definition of the ADSI API calls the wsnprintf() method like as below : DWORD
#define MAX_PATH 520
dwLength = MAX_PATH*2;
// Create search filter.
LPOLESTR pszSearchFilter = new OLECHAR[dwLength];
// Add the filter.
wsnprintf(pszSearchFilter, dwLength, L"(&(objectClass=user)(objectCategory=person)%s)",szFilter);
Please help me out in giving me the details about the header file and the .lib file to make the code compilable.
Thanks,
Derik
|
|
|
|
|
The MSDN page that you copied the FindUsers() code from looks like it contains a typo.
Try changing wsnprintf to _snwprintf[^]
make sure you have _UNICODE defined
Roger Stewart
"I Owe, I Owe, it's off to work I go..."
|
|
|
|
|
I've worked with Microsoft Office development , now I have next problem .
I 've created new Word XP document - E-mail message and try to set programmicaly value of suc fields as Subject,Recepient also add File Attachment . But I can't get access for this fields . I've found that this fields are included in the command bar Envelope that has type msoControlPane . How can I know that class from Microsoft Word Type library 10.0 correspond for this Pane control (_CommandBarButton,_CommandBarActiveX,... or something else) and how can I get access for fields that included in this Pane . Also how can I add extended fields as File Attachment or something else .
|
|
|
|
|
Have anyone ever implemented Drag&Drop using OLE but not MFC ??? How??? Tutorials, Articles, Documentation, Source Code, anything will help... Thanks
K-ballo.
|
|
|
|
|
search for Drag drop at code project there are good article releated to this, one of the best one is from Micheal Dunn
The World is getting smaller and so are the people.
|
|
|
|
|
Hi..
I have built a dll file using Visual Basic 6.0 and registered it in
Component Services as a Server Component. Because the dll will run
for more than 1 hour (approximately in about 85 minutes). The
component can be called by ASP or EXE (built using VB also).
The problem will come if there is more than one client application
(could be ASP or EXE) call the component at the same time (for
example 2 ASP request and 2 EXE file). Each client application will
need to call the dll file and process the data (either
insert/delete/retrieve records) based on their own data submitted by
the user, so the data for first client application should not be
processed by the second client application.
But after doing the testing, I realized that somehow the first client
will processed the data for second client application. And also
another strange thing is the latest caller will be processed and
finished first. For example, If the component is called by first EXE,
then 2 seconds later there is another call from second EXE. The
second EXE will be processed and finished first, the first EXE will
wait until the second EXE finished to continue the process.
Does anyone have same experience before? Or is this a limitation of
component built using VB? Also what is the advantage of registering the component (dll file) in multiple Application (Package).
Any suggestions will be appreciated.
Thanks,
Andy
|
|
|
|
|
VB6 can only create STA components, and in my opinion is worthless for web development.
Second: something wrong with your design don't you think? When web component takes 85 minutes to complete?
Brian
|
|
|
|
|
Hi..
The web will only shell (asynschronous) a VB component. The web page do not need to wait until the component finished. SO, the web component is just to trigger only.
Does it mean that there is no way to solve the problem because of thread limitation in VB?
|
|
|
|
|
I would like to extract the content and format from a Word document (in MFC/C++ 6.0).
I have been struggling with the examples. I have the "Word2XML" Microsoft example but find it difficult to decode the VB to MFC/C++. Is TOM a solution ? (TOM does not have any examples in the documentation.) Where can I find a example of its use?
|
|
|
|
|
Hi, I've got a question about a com interface that is a bit slow, so I've put it into a worker thread that seems to go ok. The trouble is this interface takes a connection point interface to report events. By the time the thread has terminated, and thus unitializes com for the thread, not all the events have been fired for the com interface. I was wondering what's the best way to get all the events before the thread returns.
Thanks.
Festina, vita breve est!
|
|
|
|
|
I worked it out, the CoInitialize() call was putting the thread in an STA, but there was no Message pump to process messages and so COM sat around waiting for ever. Who says MSDN help can't be useful sometimes?
Festina, vita breve est!
|
|
|
|
|
Hi,
I Have a custom com object which I want to use as a class member for an implemantation of another COM interface.
This is what I have done and the trouble I am having:
I place the COM object (my own one) as a class member in my class that Implements IExtension. (since all my other objects get a reference to the IExtension to see if it is active or not). I have created two functions which preform operations on the Custom COM object.
This is where I come unstuck. I figured I had to QueryInterface to my own implementation of IExtension which has the methods defined. I don't know how to call my custom functions as I get compilation errors saying:
error C2039: 'GetTargetName' : is not a member of '_NoAddRefReleaseOnCComPtr<struct IMyExtension>'
Error executing cl.exe.
I have no idea why this is happening and cannot work out why. If I have defined my extensions and objects as follows....
The only thing I can think of is that I am breaking one of the RULES of COM. I cannot see which one.
Do I have to explicitly define the QI, AddRef, Release methods in my class? From all the example on here... I didn't think I did... here is a reference to an example: http://www.codeproject.com/com/hellocom.asp[^]
your help would be greatly appreciated.
cheers
Bryce
<br />
class ATL_NO_VTABLE CMyExtension : <br />
public CComObjectRootEx<CComSingleThreadModel>,<br />
public CComCoClass<CMyExtension, &CLSID_MyExtension>,<br />
public ISupportErrorInfo,<br />
public IMyExtension,<br />
public IExtension,<br />
public IExtensionConfig<br />
{<br />
public:<br />
CMyExtension()<br />
{<br />
const CLSID CLSID_TargetLayer = {0x2CEBA738,0x0533,0x4F68,{0xB1,0xC5,0x88,0xB3,0xD9,0x5B,0xA3,0xE3}};<br />
const IID IID_ITargetLayer = {0xD149DEA4,0xBB32,0x4D9A,{0x88,0xC7,0xA2,0x61,0x43,0x7D,0xC8,0xBA}};<br />
<br />
HRESULT hr = CoCreateInstance(CLSID_TargetLayer, NULL, <br />
CLSCTX_INPROC_SERVER,IID_ITargetLayer,<br />
(LPVOID*) &m_ipTargetLayer);<br />
if (SUCCEEDED(hr))<br />
{<br />
}<br />
}<br />
<br />
DECLARE_REGISTRY_RESOURCEID(IDR_MYEXTENSION)<br />
<br />
DECLARE_PROTECT_FINAL_CONSTRUCT()<br />
<br />
BEGIN_COM_MAP(CMyExtension)<br />
COM_INTERFACE_ENTRY(IHistoryExtension)<br />
COM_INTERFACE_ENTRY(ISupportErrorInfo)<br />
COM_INTERFACE_ENTRY(IExtension)<br />
COM_INTERFACE_ENTRY(IExtensionConfig)<br />
END_COM_MAP()<br />
<br />
BEGIN_CATEGORY_MAP(CMyExtension)<br />
IMPLEMENTED_CATEGORY( __uuidof(CATID_MxExtension))<br />
END_CATEGORY_MAP()<br />
<br />
STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);<br />
<br />
public:<br />
STDMETHOD(get_Name)(BSTR * extensionName);<br />
<br />
STDMETHOD(Startup)(VARIANT * initializationData);<br />
<br />
STDMETHOD(Shutdown)();<br />
<br />
STDMETHOD(get_ProductName)(BSTR * Name);<br />
STDMETHOD(get_Description)(BSTR * Description);<br />
STDMETHOD(get_State)(esriExtensionState * State);<br />
STDMETHOD(put_State)(esriExtensionState State);<br />
<br />
<br />
HRESULT SetTargetName(BSTR Name);<br />
HRESULT GetTargetName(BSTR *Name);<br />
<br />
private:<br />
esriExtensionState m_ExtensionState;<br />
IApplicationPtr m_ipApp;<br />
BSTR m_szTargetLayer;<br />
ITargetLayer *m_ipTargetLayer;
};<br />
<br />
<br />
<br />
<br />
<br />
HRESULT CMyExtension::SetTargetName(BSTR Name)<br />
{<br />
return this->m_ipTargetLayer->PutTargetLayerName(Name);<br />
}<br />
<br />
HRESULT CMyExtension::GetTargetName(BSTR *Name)<br />
{<br />
BSTR tmp;<br />
HRESULT hr = this->m_ipTargetLayer->GetTargetLayerName(&tmp);<br />
if(SUCCEEDED(hr)){<br />
*Name = tmp;<br />
return S_OK;<br />
}<br />
<br />
return E_FAIL;<br />
}<br />
<br />
<br />
<br />
<br />
<br />
STDMETHODIMP CMyCommand::get_Enabled(VARIANT_BOOL * Enabled)<br />
{<br />
if (Enabled == NULL)<br />
return E_POINTER;<br />
<br />
HRESULT hr;<br />
long selectionCount;<br />
IExtensionPtr pExtension;<br />
IExtensionConfigPtr pExtConfig;<br />
esriExtensionState state;<br />
<br />
hr =this->m_ipMxDoc->get_FocusMap(&(this->m_ipMap));<br />
if(FAILED(hr)){return hr;}<br />
hr = this->m_ipMap->get_SelectionCount(&selectionCount);<br />
if(FAILED(hr)){return hr;}<br />
<br />
hr = this->m_ipApp->FindExtensionByName(::SysAllocString(L"My Extension"), &pExtension);<br />
if(FAILED(hr)){return hr;}<br />
<br />
pExtConfig = pExtension;<br />
pExtConfig->get_State(&state);<br />
if(FAILED(hr)){return hr;}<br />
<br />
<br />
CComPtr<IMyExtension> pHistExt;<br />
const CLSID CLISID_MyExtension = {0x442A8EAF,0x8723,0x4FED,{0xA8,0xA9,0x6D,0x2B,0x65,0x77,0x26,0x61}};<br />
hr = pExtension->QueryInterface(CLISID_MyExtension, (void **)&pHistExt);<br />
<br />
CComBSTR szTName;<br />
<br />
hr = pHistExt->GetTargetName(&szTName);
if(FAILED(hr)){return hr;}<br />
<br />
<br />
<br />
esriEditState pState;<br />
hr = this->m_ipEditor->get_EditState(&pState);<br />
if(FAILED(hr)){return hr;}<br />
<br />
if(selectionCount>0 && (state == esriESEnabled) && (pState == esriStateEditing) ){<br />
*Enabled = VARIANT_TRUE;<br />
}else{<br />
*Enabled = VARIANT_FALSE;<br />
}<br />
<br />
return S_OK;<br />
}<br />
|
|
|
|
|
I am attempting to pass in an empty collection object (MerchandiseCol) defined in VB to a C++ dll. Once C++ recieves the object, I want to fill it with records from a database, and then return it to the VB executable.
Here is what I have...
<br />
extern "C" void __stdcall GetMerchandiseCol(IDispatch* pMerchandiseCol)<br />
{<br />
HRESULT hr = CoInitialize(0);<br />
if (SUCCEEDED(hr))<br />
{<br />
dbMerch dbM;
_clsMerchandise* pMerch;
_colMerchs* pMerchCol;
<br />
hr = pMerchandiseCol->QueryInterface(__uuidof(_colMerchs), (void **) &pMerchCol);<br />
<br />
if(SUCCEEDED(hr))<br />
{<br />
if(dbM.Open())<br />
{<br />
VARIANT varItem;<br />
CComPtr<IUnknown> pUnk;<br />
CComPtr<IUnknown> pMerchandise;<br />
CComQIPtr<IEnumVARIANT, &IID_IEnumVARIANT> pNewEnum;<br />
if (SUCCEEDED(pMerchCol->get_NewEnum(&pUnk)) && pUnk != NULL)<br />
{<br />
pNewEnum = pUnk;<br />
hr = pNewEnum->QueryInterface(__uuidof(_clsMerchandise), (void **) &pMerch); <br />
<br />
_NoAddRefReleaseOnCComPtr<T>* operator->() const<br />
{<br />
ATLASSERT(p!=NULL);<br />
return (_NoAddRefReleaseOnCComPtr<T>*)p;<br />
}<br />
<br />
|
|
|
|
|
Hi all,
I am facing a strange situation where I am supposed to use an idl which has constants and import it into multiple files. The scenario is like this:
// AAA.idl
module XXXX
{
const DWORD JUNK_1 = 0x20;
...............................................
}
// My1.idl
import AAA.idl;
...........
// My2.idl
import AAA.idl;
As shown above, I need to import the AAA.idl into multiple IDL files and since constants cannot be defined in multiple cpp files within the same project, I am getting "already defined" linker errors (LNK 2001). I cannot avoid importing the AAA.idl into multiple files since I need other interfaces defined within the AAA.idl in several places, how can I overcome this error of redefinitions?
Another point to note is that the AAA.idl file is supplied by someone else, so I cannot modify before using it since it will be a continuous maintenance nightmare. I am mainly looking for options such as ignoring the module XXXX while importing the AAA.idl.
Any help to solve this problem is very much appreciated.
Thanks in advance,
Srikanth
|
|
|
|
|