|
Hi,
There's an example in the book Wrox Proffessional DCOM Application Development. The object sent inherits from IPersistStreamInitImpl<cmyclass>, defines all it's private BSTRs as CComBSTR rather than BSTR.
private:
CComBSTR m_bstrCustomerID;
CComBSTR m_bstrArtist;
...
Then in a property map:
BEGIN_PROPERTY_MAP<cmyclass>
PROP_ENTRY("CustomerID", 1, CLSID_NULL)
PROP_ENTRY("Artist", 2, CLSID_NULL)
....
END_PROPERTY_MAP()</cmyclass>
Then declares put_ and get_ methods for the above:
STDMETHOD(put_CustomerID( BSTR newVal);
STDMETHOD(get_CustomerID( BSTR* pVal);
STDMETHOD(put_Artist( BSTR newVal);
STDMETHOD(get_Artist( BSTR* pVal);
In the IPersistStream method it has:
public:
STDMETHOD(GetSizeMax)(ULARGE_INTEGER* pcbSize)
{
pcbSize->QuadPart = sizeof(DWORD)
pcbSize->QuadPart +=
SizeOfBSTR(m_bstrCustomerID) +
SizeOfBSTR(m_bstrArtist) +
...
return S_OK;
}
Thre's more of course but this seems to be the basics. If this helps let me know if I've missed anything.
|
|
|
|
|
|
Great. Just for your information, if you inherit from IPersistStreamInitImpl and use the ATL property map, which contains, say a BSTR then call:
hr = pIPersistStreamInit->Save (pIStream, FALSE);
This ends up calling:
CComBSTR bstrWrite;
bstrWrite.Attach(*(BSTR*)pData);
hr = bstrWrite.WriteToStream(pStm);
which calls:
ULONG cb;
ULONG cbStrLen = CComBSTR::GetStreamSize(m_str) - sizeof(ULONG);
HRESULT hr = pStream->Write((void*) &cbStrLen, sizeof(cbStrLen), &cb);
if (FAILED(hr))
return hr;
return cbStrLen ? pStream->Write((void*) m_str, cbStrLen, &cb) : S_OK;
so ATL already provides the code which does what your solution suggests.
|
|
|
|
|
Ok mate. I'll be back to this in a few days. Now I'm busy with another project, but I'll try what you say, it looks cleaner and not as tricky as the given solution, though have to check it out.
|
|
|
|
|
I've got MSHTML calling my IAuthenticate interface to get the username/password when it's downloading stuff that needs authentication, but how do I know if it worked?
I have a username/password that will be correct *most* of the time but if it's not, I want to disable calls to my IAuthenticate so that the browser will revert to its normal behaviour i.e. show a dialog asking for authentication details. It'd be nice if I could also instruct the MSHTML instance to retry without using the credentials I supplied.
But to do any of this, I need to know if the username/password I gave worked. Just checking for a HTTP 401/3 might not work since I sometimes seem to get a "This page cannot be displayed" error.
I enjoy occasionally wandering around randomly, and often find that when I do so, I get to where I wanted to be [^].
Awasu 2.4 [^]: A free RSS/Atom feed reader with support for Code Project.
|
|
|
|
|
how to handle flow control without using MSCOMM control?
there is no such flow control property...
|
|
|
|
|
Am I right in thinking you are using VB6.0?
|
|
|
|
|
hello all,
i want to customize the context menu which appears when one clicks
on to a mail-id(in front of From: or To .
there are 2 ways of doing this either via xml or via dll's.
i have chosen to write a dll for it as it offers much more flexibility,but the real problem is using what i should write a dll .NET(vb,c# etc) or using unmanaged code(vc++). & what are the problems that could arise by using unmanaged code.
you can reply me at: n.chudekar.31@gmail.com
thanks n regards,
nikhil.
|
|
|
|
|
I have a method that accepts a VARIANT by value using [in] attribute in my IDL file.
Do I need to do a VariantClear () within my implementation method. Please
help. Thanks in advance.
B2C
|
|
|
|
|
Perhaps, it really depends on what's in your VARIANT. If it contains, say, an Int or a BSTR there's really no need. Once you have a VARIANT that contains a pointer to something else it can get a bit more complicated.
|
|
|
|
|
is it possible to write a program which can register activex in windows vista automatically?(in fact i want find a way to register activex in vista when i wasn't administrator)
|
|
|
|
|
I've never tried it but read a recomendation[^] to use HKCU\Software\Classes instead of HKCR or 'side-by-side' COM to do away with registration.
|
|
|
|
|
|
Hi
i read your link, but i don't know how can i do that? (to use HKCU\Software\Classes instead of HKCR)?
would you tell me more about this? thank you
Zo.Naderi-Iran
|
|
|
|
|
As I said I've never tired it and just read a recomendation. I did a search for 'HKCU Software Classes' etc on Code-Project and there seems more there than I could pass on here.
|
|
|
|
|
oh, thank you
Zo.Naderi-Iran
|
|
|
|
|
I want to write to a bmp file and read from it from a COM dll, kindly give me a quick solution.
|
|
|
|
|
There is nothing COM related here.
You can still use CreateFile , ReadFile , WriteFile for one.
You could also use fopen or fstream etc.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
i need its source file
Sujit Sahu (Cruel Handsome)
|
|
|
|
|
Hello, i have got a big problem:
I have put the AvtiveX control "Microsoft RDP Client Control 2" into a MFC dialog. Now i want to do the settings like server, username and password. In VB.NET its easy. But how can I set up the password ? It seems to be a bit difficult to set up the settings behind "AdvancedSettings2" in C++.
After the command "get" there is an LPDISPATCH result, but I dont know how to handle with it to set up the password. Please help ...
.NET:
Form_RDP.RDP_Client.Server = "demo.demo.de"
Dim username, passwort As String
username = "demo"
passwort = "demo"
' Herstellen der Remotedsktopverbindung
Form_RDP.RDP_Client.UserName = username
Form_RDP.RDP_Client.DesktopWidth = 1024
Form_RDP.RDP_Client.DesktopHeight = 786
Form_RDP.RDP_Client.AdvancedSettings2.ClearTextPassword = passwort ' !!!!!!
C++:
m_mstscax1.put_Server("demo.demo.de");
m_mstscax1.put_UserName("demo");
m_mstscax1.put_DesktopWidth(1024);
m_mstscax1.put_DesktopHeight(786);
LPDISPATCH result;
result = m_mstscax1.get_AdvancedSettings2();
|
|
|
|
|
The method "get_AdvancedSettings2" implies you get back a IMsRdpClientAdvancedSettings2 interface. Actually you get a pointer to an IDispatch interface (LPDISPATCH) result. In the C++ you can, I think then call QueryInterface on the IDispatch within 'result' to get a IMsRdpClientAdvancedSettings2 interface which presumably will provide the methods you need to call.
|
|
|
|
|
Hi, could you explain how to handle this IDispatch-thing with QueryInterface?
Would be nice to understand this stuff a little more
|
|
|
|
|
m_rdp.put_ColorDepth(8);
m_rdp.put_Server(_T("150.245.178.27"));
m_rdp.put_UserName(_T("yushb0602"));
m_rdp.put_Domain(_T(""));
m_rdp.put_DesktopHeight(1000);
m_rdp.put_DesktopWidth(1000);
IMsRdpClientAdvancedSettings adv(m_rdp.get_AdvancedSettings());
adv.SetClearTextPassword(_T("yushb0602"));
m_rdp.Connect();
|
|
|
|
|
Hi all,
I have .net dll generated with vb.net code, can I run this dll as com component??
Thanks for help
|
|
|
|
|
You must make in COM visible.
Look at the [ComVisible] attribute.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|