|
Hi,
I have this code (from a tutorial by Vipul Bansal here)
which calls a method via ms soap .
<br />
...<br />
VARIANT retval;<br />
<br />
hr = pSoapClient->Invoke( dispid, IID_NULL, <br />
LOCALE_USER_DEFAULT, DISPATCH_METHOD,<br />
&dispparams, &retval , &excepinfo, &uArgErr);<br />
The thing is that the method this code invokes, returns an object with data
that I need later in my code, but since the return value is of the VARIANT
data type, I don't know how to (propertly) convert it to the class I need or maybe set the return object in the dispparams type ?!
Here is a piece of the .wsml file.
<br />
<operation name="CreateID"><br />
<execute uses="...." method="CreateID" dispID="1"><br />
<parameter callIndex="-1" name="returnval" elementName="Result" /> <br />
<parameter callIndex="1" name="User" elementName="User" /> <br />
<parameter callIndex="2" name="Password" elementName="Password" /> <br />
</execute><br />
</operation><br />
|
|
|
|
|
wsml:
<pre>
<operation name="CreateID">
<execute uses="..." method="CreateID" dispID="1">
<parameter callIndex="-1" name="returnval" elementName="Result" />
<parameter callIndex="1" name="User" elementName="User" />
<parameter callIndex="2" name="Password" elementName="Password" />
</execute>
</operation>
</pre>
|
|
|
|
|
Take a look at the MSDN docs on VARIANT , and its three fields vt , punkVal and pdispVal . I assume you know COM/IUnknown , then it'll be clear to you how to get the object. If not, then I think you should get a book on COM as well.
--
Arigato gozaimashita!
|
|
|
|
|
Hi All.
I am Completely new with COM/DCOM/COM+ concepts.
I am A VB6.0 developer and wanna to learn about them....
I search withing Codeproject.com but could not find any sample bout creating and using A COM/COM+ program with VB6.0
could you please help me?
Thank you
|
|
|
|
|
hi
I am developing an ActiveX control in which i have placed a dialog box and and on that dialog box there are some controls like button control,edit control etc (its working fine). But when i add registered controls like flex grid control (from project>Add to project...>components and controls ...) on the dialog, the dialog box's m_hWnd member becomes NULL.
Does any one know how to solve this problem.its urgent please.
regards
Azam
|
|
|
|
|
Does your ActiveX control assert failure with a message saying "An unsupported operation was attempted"? I had a similar problem and solved it by using AfxOleInit instead of CoInitialize(NULL).
|
|
|
|
|
thanks Herbert now its working fine
|
|
|
|
|
I have apartment threaded built VB activex control hosted on ATL dialog - they reside in thread T1.
Another CComObject component in thread T2 of the same process - tries to access methods of this ActiveX control.
There is an exception.
I tried using Lock(), Unlock() provided by ATLModule, and also explicitly creating CComCriticalSection. But in vain.
Can anyone help?
|
|
|
|
|
Someone wrote:
Another CComObject component in thread T2 of the same process - tries to access methods of this ActiveX control.
Please have a look at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/com/htm/cmf_a2c_88tp.asp[^]
Suppose you have the interface pointer pCtrl in thread T1. Then you cannot use that pointer straight away in thread T2. You would have to do something like this:
IStream* pStream;
CoMarshalInterThreadInterfaceInStream(IID_ITheInterfaceID, pCtrl, &pStream); If the call is successful, pStream will be a stream containing a reference to your object pCtrl and apartment marshalling information.
In thread T2, you pick up the pStream object, and unmarshal the interface pointer from the stream like this:
ITheInterface* pCtrl2;
CoGetInterfaceAndReleaseStream(pStream, IID_ITheInterfaceID, (void**)pCtrl2); The interface pointer pCtrl2 will now be accessible in thread T2. Generally speaking, the interface pointer deserialized from a stream is accessible in the thread where it was deserialized.
--
Arigato gozaimashita!
|
|
|
|
|
I tried this, but due to some runtime exception, changed to Global Interface Table. Now the problem is:
I create instance of IGlobalInterfaceTable and marshal my interface into it using RegisterInterfaceInGlobal(..). It returns me HRESULT of Successful.
Now if I Unmarshall this interface in the same thread somewhere down the line, I can successfully retriev it & call methods on this interface.
Problem is that in another thread, when I create instance of Global interface table, and access the interface using global cookie, I get HRESULT of 0x8000FFFF which means catastrophic failure.
The second thread calls CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); and CoUninitialize(). Also it waits for a event handle. Apart from the wait statement, the thread returns immediately. (it does not have message pump).
|
|
|
|
|
Dear Memebers,
Wishes to all !
This is akszn.
Here i am looking for some tips to create my own utility to autofill the contents in a web page fields.
Please suggest do anybody have developed it yet. If somebody have any Idea about it. please let me know.
To know more about google toolbar please visit : http://www.google.com
I want to know can we create that toolbar like google and how ?
Please spare your time to reply this post, its urgent
With Regards
|
|
|
|
|
I have a standard componenet developed in VC.Net which will fire an event. The .Net component will send two parameters of type object with that event.
I used VC++6.0 to develop my vc++ client,
In the corresponding .idl file the declaration of the event handler is like:
methods:
[id(0x00000001), helpstring("method Moved")]
void Moved(
[in] long XPosition,
[in] long YPosition);
I have done the following in my VC++ application.
1. I have created a class derived from IDispEventImpl,as follows:
class CSinkObj : public IDispEventImpl<idc_srcobj, csinkobj="">
{
public:
HWND m_hWndList;
CSinkObj(HWND hWnd = NULL) : m_hWndList(hWnd)
{
}
BEGIN_SINK_MAP(CSinkObj)
SINK_ENTRY(IDC_SRCOBJ, 1, Moved)
END_SINK_MAP()
void __stdcall Moved(long XPosition, long YPosition)
{
AfxMessageBox("Event notification handled in MFC client");
}
};
2. In the CPP file,
I get the address using cocreateinstance and I used the AtlGetObjectSourceInterface and DispEventAdvise for my object ,as follows:
m_pSinkObj = new CSinkObj(hWndCtrl);
HRESULT hr = m_pStageSrcObj.CoCreateInstance(CLSID_Stage,NULL,
CLSCTX_INPROC_SERVER);
_ASSERTE(SUCCEEDED(hr));
hr = AtlGetObjectSourceInterface(m_pStageSrcObj, &m_pSinkObj->m_libid,
&m_pSinkObj->m_iid, &m_pSinkObj->m_wMajorVerNum, &m_pSinkObj->m_wMinorVerNum);
_ASSERTE(SUCCEEDED(hr));
all above can be compiled and linked successfully,and i set a breakpoint at AtlGetObjectSourceInterface and step over,the problem appeared like : m_pSinkObj->m_libid is not NULL,but m_pSinkObj->m_iid is NULL,so the HRESULT value returned failed! so I am not able to capture the event from the component.
Can any one of you please tell me the solution for my problem... or is there any other way to capture the event from a VC.Net component in VC++6.0
thanks !
andy_cn
|
|
|
|
|
HI,
I m new to ATL DLL
I want to make a Dll from which i want to get the functionality of CSocket class through ASP.NEt.
I run the ATL COM wizrad use ATL DLL , soporting MFC , proxt stub , MTS all ..
I added a MFC Class CSock Inherited from CSocket class.
When i compile it . it gives error .
CSocket undefined ???????????
How i can handle it.
and i want to use this DLL for ASP.NEt page to give the functionalty to a ASP.Net page connect to a client application through IP and Port.
m i doing a right solution. means ATL DLL , and use this DLL behind a ASP.NET page.
and tell me y CSocket is Undefined
thanx
Regards.
|
|
|
|
|
I want to call AtlGetObjectSourceInterface to get the interface ID of the source interface IStage,but after the function is implemented,there appears a problem like this:m_pSinkObj->m_libid is not NULL,but m_pSinkObj->m_iid is NULL,so the HRESULT value returned failed! as follows:
m_pSinkObj = new CSinkObj(hWndCtrl);
HRESULT hr = m_pStageSrcObj.CoCreateInstance(CLSID_Stage,NULL,
CLSCTX_INPROC_SERVER);
_ASSERTE(SUCCEEDED(hr));
hr = AtlGetObjectSourceInterface(m_pStageSrcObj, &m_pSinkObj->m_libid,
&m_pSinkObj->m_iid, &m_pSinkObj->m_wMajorVerNum, &m_pSinkObj->m_wMinorVerNum);
_ASSERTE(SUCCEEDED(hr));
thanks!
andy_cn
|
|
|
|
|
Hi to all
I implemented address book support in my application with IAdressBook interface. Everything is fine - application is able to open, store,resolve, contacts from address book. But if I run my application for the very first time on freshly installed MS Windows the problem occurs.
It looks that if you have never run MS Outlook express or Windows Addres Book aplication on your computer - personall address book is not created yet and some of COM function fails. I see also no way to initialize addrres book by calling some COM functions.
Here is a sample code:
hr = m_lpAdrBook->GetPAB( &lpcbEID, &lpEID);
// Open the root PAB container
// This is where all the WAB contents reside
hr = m_lpAdrBook->OpenEntry(lpcbEID,
(LPENTRYID)lpEID,
NULL,
0,
&ulObjType,
(LPUNKNOWN *)&lpContainer);
// Get a contents table of all the contents in the
// WABs root container
hr = lpContainer->GetContentsTable( 0, &lpAB); //this function fails on systems that hever had Outlook run before!.
I would be grateful for any tips how to initialize the address book in a first time.
Thanks and best regards!
Irek
Check out my software at: http://www.ireksoftware.com
|
|
|
|
|
Hi all,
Can anyone please help me to reterive the OCX properties from handle of third party application?
Thanks,
Mohan
|
|
|
|
|
Hi,
I'm not sure if this is possible, or whether it's been answered before but I've reached meltdown trying to guess the key phrase to get information on this.
What I have is:
- an existing COM DLL + idl etc which is installed in location A
What I'd like to do is:
write a new version of the DLL supporting the same interfaces as A so it is a complete replacement for A. However, I actually want to use the original DLL to do all the work.
All the new DLL is for is to journal calls in and events out of the original and forward responses back to the client application. It may eventually multiplex information elsewhere, but that's the future.
Any help would be greatly appreciated. I've been staring at MSDN too long to actually read the COM API clearly
Thanks.
Kev
|
|
|
|
|
You can import the idl file in your new idl file to get the interface information from the old file. Please see the MIDL statement import .
Note that the compiled DLL will not depend on the old DLL. You can opt to install only the new DLL on the target system.
Another way to do it is to #import (VC++ feature) the DLL and its associated type library into your C++ code.
A third way to do it is to grab the header file generated by the compilation of the IDL file beloning to the old DLL, and #include it in your new sources.
Personally, I import import in the IDL file. Please note that by doing so, the corresponding header file of the imported IDL file, must also be accessible to the C++ compiler. At work I have an include files in one directory and IDL files in another (you can have them in one directory if you're not so anal about order it as I am ). I have added those two directories to the include search path in the IDE. That way MIDL finds the idl-file, and the C++ compiler finds the corresponding header file.
--
Arigato gozaimashita!
|
|
|
|
|
Hi,
thanks for replying - all useful information.
However, I don't think I made my question clear enough.
What I am trying to achieve is to be able to install my binary-compatible version of an exisiting DLL onto a pre-existing system containing the original DLL. My new DLL would register itself and be the DLL loaded by clients of the original DLL.
My DLL, because it knows that there is an existing DLL in a known location would be able to the original to provide the clients with identical functionality.
If I was using plain DLL's I'd simply be able to install the new version so that it was found earlier in the path and load in the original DLL using LoadLibrary(). Since I know exactly what the interfaces are, I could do this with the COM DLL. However, I'm looking for an "official" COM way of short-circuiting the registry lookup.
Kev
|
|
|
|
|
Aha! My foggy brain finally seems to be kicking into gear again. I believe the answer is to:
1) Call CoLoadLibrary() to load the specific DLL into memory
2) Call GetProcAddress() to get the original's DllGetClassObject() function.
3) Call DllGetClassObject() to get the original DLL's class-factory, then off-we-go!
Pretty obvious really. Oh well
I'll try this out later on today when shipping-hell lets me.
Kev
|
|
|
|
|
I need to take an opinion on whether our approach is right (described below):
Problem
We have a ATL windows service which also exposes one COM class - say MainServer. MainServer interacts with other internal COM objects and a VB ActiveX control. Client application can instantiate MainServer component and fire some methods on it. The VB ActiveX control needs a form container - so we are using ATL dialog (invisible, modeless) to host it. And fire methods on the dialog.
Output
Service when tested through control panel GUI, it works perfectly and we can fire methods on ActiveX control through its container in ServiceWinMain(), Run() and other methods.
But when tested with Client application which instantiates MainServer and fires methods, we have an unspecified exception.
My questions are:
1. Is it possible to host ATL dialog like I mentioned in a Windows service?
2. What is the best way to make this application thread safe?
3. Is this approach right?
|
|
|
|
|
HI
Wt is the difercne between
Differnce between ATL DLL, ATL Service and ATL EXE
and where thay r used
i want to use them in ASP.NET page .
that every client can use it .
I want to do in it is , to connect to a sepecific client IP and Socket and to get and send data.
or may i use a WebService is ASP.NET
which one is better
thanx
Regards.
|
|
|
|
|
zahid_ash wrote:
Differnce between ATL DLL, ATL Service and ATL EXE
A DLL server is in-proc. That means that the code inside the DLL will run within the same process space as the client. This means faster execution, at the cost of not too good reliability. If the server crashes, the entire process will crash with it.
zahid_ash wrote:
ATL EXE
An EXE server out-proc. That means it will run in its own process, separate from the client. Execution will require marshalling and is thus slower than a DLL server. However, if the server crashes, the client may still survive (given that it inspects and act appropriately to the HRESULTs returned by the COM methods)
zahid_ash wrote:
ATL Service
It works sort of like an ATL EXE, but is started by the system at boot time, and not at first client activation.
--
Arigato gozaimashita!
|
|
|
|
|
i've developed a windows service on VC 7. using ATL.
I'm using .net istaller to install that.
.net istaller uses command "service full path" -service to install the service.
It is observed that ,when i do installation using this installer, and tries to acces an interface of service
it gives automation error,"object doesn't support automation or queryinterface failed"
interestingly, if i unregisters the same service form same location and register it using same command, it doesn't give any problem.
what would be the problem.
thanks,
Prasad
|
|
|
|
|
Hi, I'm implementing an interface method of a COM object that runs in a local EXE server. One of the arguments is a SAFEARRAY (packed in VARIANT).I found if I destroyed the SAFEARRAY after using it, the server EXE would crash mysterically after running for a while. But if I left the SAFEARRAY alone, everything would be OK. So should I destroy the SAFEARRAY or not? Will the underlying RPC do the cleanup work for me?
There is also the twin question: after a client fills a SAFEARRAY argument and then calls the method, does it need to destroy the SAFEARRAY?
Thanks a lot.
|
|
|
|
|