|
I have a local COM server that must not die when there are no more reference
to it and I don't want it to be a service. To do this I made sure that the
reference counter never reaches 0. To accomplish this I tried several
things:
1. Use CoAddRefServerProcess() at startup.
2. USe CoLockObjectExternal at startup.
3. Modify CModuleExe::Unlock so the lock count only reaches 0 if allowed.
When I use any of these 3 methods (which probalby all do the same: make sure
the ref. counter does not reach 0) my component stays alive, but it will
free a lot of memory. I saw my component of 1.7 MB go to a mere 60 KB .
I figured I would see a slight decrease of memory use as it does not need the proxy/stubs anymore. But this seems a bit radicale.
Does anyone know what happened?
Is there a beter way of making sure a component stays alive when tere are no more
references to it?
Regards,
Brian.
|
|
|
|
|
How do we extract the custom errors which are embedded in the HRESULT variable?
|
|
|
|
|
|
Could you explain more!?.I did not find any help in how to use these macro in MSDN?Could you help me out?
thx deepu
|
|
|
|
|
That is how resizing a ATL control inside the ATL server DLL? The detail is: I
set a ATL control property with Width and Height and want resize the control
according to the two parameters. Please tell me how can I get it?
cz
|
|
|
|
|
Hi
have you tried SetWindowPos() ?
Hush..Hush.. thought I heard you calling my name now...
|
|
|
|
|
Yes, I have do it by SetWindowPos. Just after I call this function, the ATL extenter
has been resized(become smaller). But I click in the original rect of the ATL extenter,
the ATL become the original size as same as before calling SetWindowPos.
In fact I want to call SetWindowRgn to make a irregular ATL control, but I cannot
because the same reason as above. Click the ATL, it become back to previous shape.
cz
|
|
|
|
|
After FormatMessage( ) how do I convert lpMsgBuf to a BSTR? Thanks.
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
// Convert lpMsgBuf to BSTR
|
|
|
|
|
Use the ATL string conversion macro T2BSTR.
#include <atlconv.h>
{
USES_CONVERSION;
BSTR bstr = T2BSTR(lpMsgBuf);
...
} The memory allocated for the BSTR is freed whenever the block is exited.
--Mike--
http://home.inreach.com/mdunn/
The Signature, back by popular demand: Buffy. Pajamas.
|
|
|
|
|
If you are using MFC you can use:
CString::AllocSysString() but remember that you are allocating a new OLE style string which may need to be cleaned up with ::SysFreeString().
Alternatively you could use ATLs CComBSTR object which will clean itself up like a CString.
Cheers.
John Curtis.
Software guy.
Fatlab Software.
|
|
|
|
|
you can use ::SysAllocStringByteLen()
char* pLcID;
:SysAllocStringByteLen(pLcID,sizeof(pLcID));
|
|
|
|
|
I am using dual interface to expose the functions of the COM interface.One of the function takes the handle of window as the parameter.
I need to use the Invoke()method to call the function and pass the parameter.Could you please help me with some kind of sample code ?
Thanks
Jafer
Jafer
|
|
|
|
|
I'm new to COM and ATL and I'm trying to produce a simple component that will serve collections of other COM objects.
I've created my COM object, LoginUser and tested it with VB - all OK.
I've created my COM collection for LoginUser objects and tested it with VB - all OK. (I am using David Petersons collection wizard).
What I am unable to do is add LoginUser object to the collection in VC++. I get the collection back with the correct number of items but all of the items appear to be uninitialised. Can anyone tell me how to do this. I've appended a snipet of my code in case anyone can tell me where I've gone astray and how to fix it.
STDMETHODIMP WASP::GetUsers( IWASPrecordset **pUser )
{
HRESULT hr;
IWASPrecordset *pR = NULL;
// Start COM subsystem
CoInitialize( NULL );
// Create a recordset object,
hr = CoCreateInstance ( CLSID_WASPrecordset,
NULL,
CLSCTX_INPROC_SERVER,
__uuidof(IWASPrecordset),
(void**) &pR );
// Did we succeed
if( SUCCEEDED(hr) )
{
for( i = 0; i < 10; ++i )
{
ILoginUserInt *pU = NULL;
// Create a LoginUser object,
hr = CoCreateInstance ( CLSID_LoginUserInt,
NULL,
CLSCTX_INPROC_SERVER,
__uuidof(ILoginUserInt),
(void**) &pU );
// Did we succeed - put user details into login user object
if( SUCCEEDED(hr) )
{
_bstr_t bst( "James" );
// Put user name into user object
pU->put_User( bst );
// Now put object into collection
pR->Add( pU );
// Release my copy of this object
pU->Release();
pU = NULL;
}
}
// Now set the return value to be the new object
pR->QueryInterface(__uuidof(IWASPrecordset),(void **) pUser);
// Release my copy of the object
pR->Release();
pR = NULL;
}
// Stop COM subsystem
::CoUninitialize();
return hr;
}
Thanks
Nic.
|
|
|
|
|
I have some COM components. I want to write an application in VC++6 using them.
What should i do? Do I have to change any settings for vc?
|
|
|
|
|
Not specifically. Just import your server's typelib and call methods/ connect to events etc..
Hush..Hush.. thought I heard you calling my name now...
|
|
|
|
|
Hi Is there anybody, who knows how I can create an ActiveXControl in another ActiveXControl.
It could work with 'CreateControl' , but I don't know how!!!!
Please help me as fast as you can!!
thank u
|
|
|
|
|
I use ActiveX componet microsoft winsock ver 6 in Visual C++
Mycode is
Server:
VARIANT NewMemberPackage;
NewMemberPackage.vt = VT_BSTR;
NewMemberPackage.bstrVal = MyPacked.AllocSysString();
m_winsockmember.SendData(NewMemberPackage);
----------------------------------------------------------------
Client:
VARIANT mPackage;
VARIANT menumType;
VARIANT mmaxLength;
mPackage.vt = VT_BYREF|VT_BSTR;
menumType.vt = VT_UI1;
menumType.bVal = VT_BSTR;
mmaxLength.vt = VT_I4;
mmaxLength.iVal = 512;
m_WinsockConnect.GetData(&mPackage, menumType, mmaxLength);
---------------------------------------------------------------------
In client is wrong but I can't found information about this Component in my country. How I Programming VC++ Code In Client. Helpme Please
Sura
|
|
|
|
|
I have a COM component (ATL) that returns a collection object. When the component is registered through regular regsrv32 all is well. When I register it under COM+ as a library application it fails from a VB client with the error "Property let procedure not defined and property get procedure did not return an object". This error occurs when trying to execute a for each loop. I can access the collection via the Item method. All the collection objects are exhibiting the error. When called from an Automation client it will succeed when registered under COM+. Any idea what is going on?
TIA!
Nate
nwilhelmi@kore.com
(The registration process wouldn't work)
|
|
|
|
|
I have a free threaded out-of-process COM server that after the clients release the interface the COM server's CComModule::Unlock() returns a value > 0. After the client first releases, the return value of Unlock() is 1, after the client loads and releases the second time the value is 2, and this continues to increase by one as I startup and shutdown the client.
The client is using a smart pointer to the COM server interface. I also detached, the interface from the smart pointer in the destructor of my application and displayed the return value of Release() which is always 0. So it seems the client is releasing everything properly, it's just that the server isn't maintaining ref. count correctly for some reason. This causes the COM server to never shutdown. Any ideas why it keeps on increasing?
I turned on ATL debugging and came out with the following output in the trace window. I also display the return of Unlock() for the lines that begin with "Unlock count: X".
1> CComClassFactory - IUnknown
CComClassFactory - IUnknown
Loaded 'C:\WINDOWS\SYSTEM\RPCRT4.DLL', no matching symbolic information found.
2> CComClassFactory - IUnknown
1< CComClassFactory - IUnknown
1> CComClassFactory - IClassFactory
CComClassFactory - IClassFactory
1> CNREmail - IUnknown
CNREmail - IUnknown
2> CNREmail - IUnknown
CNREmail - IMarshal - failed
CNREmail - {0000001B-0000-0000-C000-000000000046} - failed
3> CNREmail - IUnknown
CNREmail - IUnknown
4> CNREmail - IUnknown
CNREmail - IStdMarshalInfo - failed
CNREmail - IExternalConnection - failed
3< CNREmail - IUnknown
Unlock count: 3
1> CNREmail - INREmail
CNREmail - INREmail
Loaded '[My app's Proxy server].dll', no matching symbolic information found.
1> CNREmail - INREmail
CNREmail - INREmail
2< CNREmail - IUnknown
Unlock count: 4
1< CNREmail - IUnknown
Unlock count: 3
0< CComClassFactory - IClassFactory
Loaded 'C:\WINDOWS\SYSTEM\MSVCRT.DLL', no matching symbolic information found.
Loaded 'C:\Program Files\Common Files\SYSTEM\ADO\msado15.dll', no matching symbolic information found.
Loaded 'C:\Program Files\Common Files\SYSTEM\ole db\oledb32.dll', no matching symbolic information found.
Loaded 'C:\Program Files\Common Files\SYSTEM\ole db\oledb32a.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\msjint40.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\msjter40.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\mswstr10.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\msjet40.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\msjetoledb40.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\SYSTEM\MTXDM.DLL', no matching symbolic information found.
1> CNREmail - INREmail
CNREmail - INREmail
CNREmail - IMarshal - failed
CNREmail - {0000001B-0000-0000-C000-000000000046} - failed
2> CNREmail - IUnknown
CNREmail - IUnknown
1< CNREmail - IUnknown
Unlock count: 4
0< CNREmail - INREmail
Unlock count: 3
2> CNREmail - INREmail
The thread 0xFFF6F197 has exited with code 0 (0x0).
1< CNREmail - INREmail
Unlock count: 3
0< CNREmail - INREmail
Unlock count: 2
0< CNREmail - IUnknown
Unlock count: 1
Thanks in advance for any help!
- Pros
|
|
|
|
|
Also, when I startup and shutdown the client, the reference count that is returned via the ATL header debug interface traces always returns 1 after the client shutsdown and doesn't increase like the unlock count returned from CComModule::Unlock() which increases by 1 each time.
|
|
|
|
|
I figured it out. I had some worker threads in my COM server in which I was marshalling an interface pointer to itself, and had forgotten to call Release().
|
|
|
|
|
Hi guys,
Does anyone know what wrong I am doing?
CComPtr<ix> pIn;
CoCreateInstance(...)
... using pIn is fine ...
After that ...
_variant_t vIn(static_cast<iuknown*>(pIn));
... First chance exception???
I have already asked on codeguru... hasn't answer... Is here anyone who know?
Thanks for help.
|
|
|
|
|
I want to use IActiveDesktop in a program o create a random wallpaper changer. I get a pointer to IActiveDesktop (using CoCreateInstance), but when I try to use any Methods, I get the error message "Use of undefined type 'IActiveDesktop'". It then directs me to the declaration of IActiveDesktop in comdef.h. Can anyone help me use this.
Thanks
P.S. -> I don't want to use any MFC in the program. I'm using Win2K and VC++ 6.0.
Greg J. Hedlund
SuperStar
|
|
|
|
|
|
i use [in]short nSisze,[in,size_is(nSize)]byte* pBuffer,
or [in]short nSisze,[in,size_is(nSize)]byte pBuffer[],
but on the server i only get the first byte allocated in the client.
why???
Thanks in advance
|
|
|
|