|
I am trying the first _Connection method you suggest, so what should i pass from the vb side?
If i implemented your suggestion, would the vb side be something like this?
dim fred as new adodb.connection
fred.open blah blah blah
somestring = getfield(fred, anotherstring)
Cheers,
Dave
|
|
|
|
|
Dave,
Yes, that should do the trick. If it fails then you have a few options including...
1) Making it IUnknown in C++ then in VB do this
dim fred as new adodb.connection
dim oFred as Object
fred.open blah blah blah
set oFred = fred
somestring = getfield(oFred, anotherstring)
(Set in VB is much akin to QueryInterface in C++)
2) Make it a Variant in C++ containing either IUnknown or IDispatch then do the same as above but Dim oFred as a Variant instead.
I haven't done exactly this before (I've done it with my own custom objects) but the principal should be the same.
Also, make sure that you do a _Connection.AddRef() at the beginning and .Release() at the end of your processing in C++ as you will be a COM Client in this case. Not doing this may yield all sorts of nastiness if VB decides it can let go of the Connection in the mean time.
Good luck,
Sam
|
|
|
|
|
This may not be a true COM question, but I am trying every source I can find to try to solve this one:
I am completely frustrated!
I have read from several sources, that you can use the GetIRichEditOle() function to get to the ITextDocument interface for a CRichEditCtrl.
I am using VC 6, and the RichEdit version looks like it is 3.0.
I am using the following code:
ITextDocument *pTextDoc = NULL;
IRichEditOle * ire = m_RichEdit.GetIRichEditOle();
if ((ire == NULL) || (ire->QueryInterface(IID_ITextDocument, (void**) &pTextDoc) != S_OK) || (pTextDoc == NULL)){
DWORD dwErr = GetLastError();
if (ire != NULL)
ire->Release();
TRACE("Failed ITextDoc\n");
}
The pTextDoc is always NULL. The GetLastError() returns 0.
I have also tried the method specified in MSDN, but it fails also. The method they use is very similar to the above code, so that's no surprise.
I am getting desperate! I need to get the ITextDocument interface to do some things like set the line spacing.
Please, if anyone knows how to do this, let me know.
Thank you very much,
David
|
|
|
|
|
I want to create search engine which will be used for searching xls,ppt,txt,htm,pdf,doc files base on search keyword.
For this specification i would like to create component as inprocess server and it should operate on companies intranet. So anybody guide me how to create the component weather by using IFilter index server of microsoft. If you have any guidance about IFilter or any other will be very useful for me.
|
|
|
|
|
I want to build three objects, one is common and want to be used by other two objects. How can i access from one object to another object
|
|
|
|
|
Reusing COM objects
.
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
Can you tell me something in detail. I want to access from one object to other objects.
What mechanism it is and What API i need?
|
|
|
|
|
I suggest you Containment that is easier.Do you know how to use your COM object in client application?Thats exactly the same.Use CreateInstance() in your second component to iniatilize the first component.If you have any problem to use it just ask.
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
Mazdak, Thank you very much. I'll try on it.
|
|
|
|
|
Hi,
I'm having a problem in COM EXE.
I create a new worker thread that loops and listens to messages. during shut down I release pointers defined in its scope, and call CoUninitialize.
but it seems to get stuck there. (The function who stops the thread waits until the worker thread is signaled, that happens only after couninitialize, which is the last line in the worker thread)
is there any deadlock associated with it? or I have not released everything? I checked and it seems i have released all.
can you supply me with directions for thought what is wrong there?
Thanks.
Sefi p.
|
|
|
|
|
Hi all,
in the code below, hToken is an impersonation token which I
duplicate into a primary token in order to use with
CreateProcessAsUser. I ask the new token to have the
DELEGATION level of impersonation but I get error 1346 :
ERROR_BAD_IMPERSONATION_LEVEL. NTLM is running on W2K as
the SSP provider, but it seem that delegation is not supported. Is it possible to have the impersonation level with CLOAKING enabled with NTLM ? does this provide a
one hop machine-cross delegation level (which is sufficient for my server) ? All this is done with a calling from an ASP page, how can i set the impersonation level for the client ?. All this confuse me, thank to bring some light ...;)
if ( !DuplicateTokenEx(
hToken, // handle to token to duplicate
TOKEN_ALL_ACCESS | TOKEN_QUERY |
TOKEN_ASSIGN_PRIMARY | TOKEN_DUPLICATE,
NULL,
SecurityDelegation,
TokenPrimary,
&hDup ) ) {
err = GetLastError();}
|
|
|
|
|
Sorry for the duplicate post but the first one stripped off the template args. Look near the bottom of the code snippet. I'm not sure what the code is doing, can someone explain.
template<typename _IIID> class _com_ptr_t {
public:
typedef _IIID ThisIIID;
typedef typename _IIID::Interface Interface;
static const IID& GetIID() throw()
{
return ThisIIID::GetIID();
}
template<typename _OtherIID> _com_ptr_t(const _com_ptr_t<_OtherIID>& p) throw(_com_error)
: m_pInterface(NULL)
{
HRESULT hr = _QueryInterface(p);
if (FAILED(hr) && (hr != E_NOINTERFACE)) {
_com_issue_error(hr);
}
}
template<typename _InterfaceType> _com_ptr_t(_InterfaceType* p) throw(_com_error)
: m_pInterface(NULL)
{
HRESULT hr = _QueryInterface(p);
if (FAILED(hr) && (hr != E_NOINTERFACE)) {
_com_issue_error(hr);
}
}
template<> _com_ptr_t(LPSTR str) throw(_com_error)
{
new(this) _com_ptr_t(static_cast<LPCSTR> (str), NULL);
}
...
}
|
|
|
|
|
Gerald Schwab wrote:
template<> _com_ptr_t(LPSTR str) throw(_com_error)
{
new(this) _com_ptr_t(static_cast<LPCSTR>(str), NULL);
}
That is calling one constructor from another. Since the constructor that takes an LPCSTR is marked explicit , a different constructor was needed that takes an LPSTR. (explicit means that the constructor parameter must exactly match LPCSTR, no implicit conversions (such as adding a const qualification to convert an LPSTR to an LPCSTR) are allowed.)
This totally negates the purpose of having the explicit constructor, but oh well.
The new(this) calls an operator new defined in new.h, which is #include'd at the top of comip.h.
--Mike--
"Jobs that don't allow you to visit the Lounge 25 times a day at the minimum are not worth having anyway."
-- Nish, 3/28/2002
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan and Jamie Salé.
|
|
|
|
|
Thanks for the reply Michael. I understand the "explicit" part, but I'm still a little fuzzy on the "new" part. I stepped through the code with the debugger and it looks like this constuctor is instantiating itself using the explicit constructor. Here's what I don't quit get: when "new(this)" is called, "this" already has an address. So is this constructor calling the explicit constructor and replacing itself with the constructed value of the explicit contructor? Or is it casting from this constructor to the explicit constructor? I understand the result, I just don't quite grasp how the code gets there.
|
|
|
|
|
The purpose of new() is usually to allocate memory and return a pointer to it, however you can overload new() to do anything. That's what that constructor does, it calls an overloaded new() that just returns the parameter passed to it. Since there is already memory allocated for this , new() returns that address, then C++ calls the constructor.
It is bloody confusing, though.
--Mike--
"Jobs that don't allow you to visit the Lounge 25 times a day at the minimum are not worth having anyway."
-- Nish, 3/28/2002
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan and Jamie Salé.
|
|
|
|
|
Mike,
I see you continue to include a link to your "really out-of-date homepage" when are you going to update it?
Nick Parker
|
|
|
|
|
|
Look near the bottom of the code snippet. I'm not sure what the code is doing, can someone explain.
template<typename _IIID> class _com_ptr_t {
public:
typedef _IIID ThisIIID;
typedef typename _IIID::Interface Interface;
static const IID& GetIID() throw()
{
return ThisIIID::GetIID();
}
template<typename _OtherIID> _com_ptr_t(const _com_ptr_t<_OtherIID>& p) throw(_com_error)
: m_pInterface(NULL)
{
HRESULT hr = _QueryInterface(p);
if (FAILED(hr) && (hr != E_NOINTERFACE)) {
_com_issue_error(hr);
}
}
template<typename _InterfaceType> _com_ptr_t(_InterfaceType* p) throw(_com_error)
: m_pInterface(NULL)
{
HRESULT hr = _QueryInterface(p);
if (FAILED(hr) && (hr != E_NOINTERFACE)) {
_com_issue_error(hr);
}
}
template<> _com_ptr_t(LPSTR str) throw(_com_error)
{
new(this) _com_ptr_t(static_cast<LPCSTR> (str), NULL); <<<<<<-- WHAT IS THIS LINE DOING?
}
...
}
|
|
|
|
|
open a new com. port but disable the interface.
---->NULL
czer
|
|
|
|
|
I was wondering if it is possible to use STL vectors with CComBSTR?
example:
vector<ccombstr *=""> vComBSTR;
Now how does one allocate new CComBSTR objects into the vector? I'm quessing like so,
vComBSTR.push_back(new CComBSTR("Hello"));
Or do I need to use the SysAllocString instead?
What is a programmer to do.
Thanks in advance.
Ken
|
|
|
|
|
Madmaximus wrote:
I was wondering if it is possible to use STL vectors with CComBSTR?
std::vector<CAdapt<CComBSTR> >
CAdapt is an ATL class that lets you use CComBSTR and CComPTR/CComQIPtr in STL collections. See CAdapt in MSDN for more.
--Mike--
"Jobs that don't allow you to visit the Lounge 25 times a day at the minimum are not worth having anyway."
-- Nish, 3/28/2002
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan and Jamie Salé.
|
|
|
|
|
Thanks for the fast reply.
How does one declare a CComBSTR pointer in a vactor?
Example:
std::vector<cadapt<ccombstr *=""> >
Does one just uses the new operator? Or do I need to use the SysAllocString function.
Examples:
std::vector<cadapt<ccombstr *=""> > vComBSTR;
vComBSTR.push_back( new CComBSTR("Hello"));
OR
vComBSTR.push_back( SysAllocString("Hello"));
Thanks in advance.
Ken
|
|
|
|
|
I'm trying to build a library similar to the common dialog controls library. It works, mostly. I have a class CHostWindow:
class ATL_NO_VTABLE CHostWindow :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CHostWindow, &CLSID_HostWindow>,
public IDispatchImpl<IHostWindow, &IID_IHostWindow, &LIBID_BTS_DLGHELPERLib>,
public CWindowImpl<CHostWindow>
In my Win32 application, I invoke HostWindow, pass to it an interface to the control I want to host, and the window works as you'd expect.
if (SUCCEEDED(Result = iHost.CreateInstance(CLSID_HostWindow)))
{
iHost->Host((PDWORD)&CLSID_DlgFieldProperties, (IUnknown**)&iFieldProps);
iHost->Show(SW_SHOW);
}
This is fine when the control contains basic window elements like pushbuttons and edit boxes but when the composite control contains another control (like the list control in the Resource Editor), the app crashes with an access violation, and according to the stack trace the program is recursively running through the composite control's property list until it runs out of stack space.
I've spent too much time trying to figure this out and now need help! I'm using CAxWindow (memory leak and all) to do the hosting. Can someone explain to me what I might be missing, or point me to some relevant, working, code?
Thanks
Matt
|
|
|
|
|
I'm a student and I'm doing my project:
Build a Certification Authority
Can you give me some informations, links, tutorials, email, which related to this problem ?
Thanks!
Hung Son
A Vietnamese student
i-g.hypermart.net
dlhson2001@yahoo.com
|
|
|
|
|
Windows.NET server has a CA module. I assume there is a similar thing in Win2K server. Try the Microsoft website. Remember that your Root certificate will not be recognised on other peoples PCs if you havent registered it with microsoft or the other CA list providers.
I'm not late, I'm just not as early as I could have been.
|
|
|
|