|
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.
|
|
|
|
|
Sorry, but I'm not sure that I understand your idea clearly. Can you tell me some more about your idea.
Thanks
Hung Son
A Vietnamese student
i-g.hypermart.net
dlhson2001@yahoo.com
|
|
|
|
|
Sorry. How much do you know already about CAs, and what are to needing to do with them?
I'm not late, I'm just not as early as I could have been.
|
|
|
|
|
I use msflexgrid in a excel like program to display the app data, but when the data is huge, i mean about 400 items. the additem method will take about 30s to complete. what's wrong? I use vc60 and there is no other way then add each item a time. what can i do? thanks for help
|
|
|
|
|
Why doesnt ClassWizard allow u to override the defaults for non-client area messages?
|
|
|
|
|
Thanks in advanced!;P
|
|
|
|
|
Hello guys,
I'm quite new on COM and maybe what I'm asking it's stupid : in VC++ is there an automatic way to add another interface to an existing class which already has one or I have to do it by hand? If so, in which file I have to add it (idl, header file of the class)?
Thank you very much,
Thomas
|
|
|
|
|
Anonymous wrote:
add another interface to an existing class
Why do you want to add another interface,there are diferrent reason to add it.what do you want to do?
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
I want to add three more methods to the class and while the first interface was "published" already I need another interface (hope I'm right with this ; if not please give me an advice).
|
|
|
|
|
I've been working with binary behaviors for the last two weeks, but the resource in the net is very poor. Anyone of you already work with binary behaviors?
|
|
|
|
|
Hello everyone,
I've been playing around with Excel Automation for a while now, and I'm having a little problem.
I'm using some classes that VC++ automagically generated from the Excel type library. When I try and close the instance of excel I've created, it seems to work, and no errors or exceptions occur. But after my app terminates there is still an excel.exe shown in NT's Task Manager.
Here is the code I'm using to close Excel (It's probably got loads of unneccesary stuff in, I've been playing with it trying to fix the problem):
m_ExcelWorkbook.DetachDispatch();
m_ExcelWorkbooks.DetachDispatch();
m_ExcelWorksheet.DetachDispatch();
m_ExcelApp.SetVisible( false );
m_ExcelApp.Quit();
m_ExcelApp.DetachDispatch();
m_ExcelApp.ReleaseDispatch();
Hope someone can give me some pointers or a link to RTFM.
TIA,
Pete
|
|
|
|
|
Hello,
If I register my DCOM exe server as local server, it works fine.
If I register it as NT Service, the registration seems good but every call to CoCreateIntance failed with the error ERROR_SERVICE_DOES_NOT_EXIST.
If I try to configure with DCOMCNFG.EXE, it prompts the service is installed but it show the same error when I want to apply the modification.
When I go in the Service window, my service is present and I can run it/stop it via the Service Manager. In the EventViewer, I can see the info/warning/error message the server drops.
The DCOM server is developped under VC++ 6.0 with ATL.
Can you give me a hint on how to solve that problem?
I have read the Richard Grimes' book but found nothing. I read it again and again wo any success.
Thanks,
Bruno
|
|
|
|
|
|
I got it.
The name of the LocalService appid entry does not match the service name.
I have chnage the IDS_SERVICENAME and ATL use a hardcoded name one time and I miss to change it.
|
|
|
|