|
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
|
|
|
|
|
This is just a guess since I'm a COM newbie, but if you created your ATL object with a "dual" interface then the above IDL won't work. You'll need to either use a VARIANT safearray to pass the data in, or create your object with a "custom" interface when you're on the ATL object wizard dialog.
Hope that helps,
Pros
|
|
|
|
|
Oh,thanks a lot .and also thanks for your reply in the previous message
I posted as cg.
I've tried again . I use
[in]short nSize,[in,size_is(nSize)]byte buffer[].
I found that it works both in the "dual" interface and custom interface .
But I don't know now why it failed before .a little confused
cg
|
|
|
|
|
Hello COM gurus
I'm trying to create a UI-less MFC ActiveX control that can be accessed from VBScript in an HTML page. I'm not using ATL because I want to minimize the possibility that the user's machine needs a restart. I've looked at MSDN's safectl tutorial which implements IObjectSafety to allow for scripting in hopes of getting some idea of what's going on. However, when I try to invoke a user-defined automation method in this control from VBScript, I get a "Catastrophic Error" (8000FFFF). This can't be good.
Can anyone suggest what I should look at/implement to expose methods to VBScript? Thanks for any suggestions.
|
|
|
|
|
Nevermind, I found the problem...See http://support.microsoft.com/support/kb/articles/Q146/1/20.ASP
|
|
|
|
|
I am trying to create a very simple com server, everything goes well until the last phase of the build process,
during the registration phase visual C++ freezes, I tried reinstalling VC++ but that did not help. Any ideas?
|
|
|
|
|
Are you on Win 9x? And running Norton AntiVirus? There's a known bug with NAV 2000 and 2001 on 9x which makes VC hang if you're running the Auto-Protect (background scanner) and do a build that makes VC launch another program in a custom build step (such as regsvr32 in an ATL project). Just disable AP (right-click the tray icon, pick Disable Auto-Protect) before doing your build.
Annoying, I know.
--Mike--
http://home.inreach.com/mdunn/
The Signature, back by popular demand: Buffy. Pajamas.
|
|
|
|
|
i am daily facing this problem even thou any auto protect program is not running. After restart if kill both winoldap and Visual Studiofrom next on wards it freeze please help me.
|
|
|
|
|
Warning: COM newbie...
If I do all the code inline, no problems. Inside the function, everything works fine also. The moment it returns, pMyObj gets set to NULL (Like it's going out of scope?) What have I missed here, and how can I fix it such that I pass in a CComPtr and have it setup inside the function, but still valid outside the function (i.e. not reset to NULL)?
NB: Angle brackets converted to square brackets coz they were being treated as HTML.
BOOL DoStuff( CComPtr[IMyObj] pMyObj ); // Declaration
BOOL DoStuff( CComPtr[IMyObj] pMyObj ) // Definition
{
hr = pMyObj.CoCreateInstance( CLSID_MyObj );
if( FAILED( hr ) return FALSE;
return TRUE
}
void MyDlg::MyFunc( void )
{
CComPtr[IMyObj] pMyOutsideObj; // Usage
if( !DoStuff( pMyOutsideObj ) )
return;
}
|
|
|
|
|
The changes that DoStuff() makes to its parameter aren't reflected outside the function. This is how C function parameters work. You can fix your code by changing the parameter to a reference:
BOOL DoStuff ( CComPtr<IMyObj>& pMyObj );
--Mike--
http://home.inreach.com/mdunn/
The Signature, back by popular demand: Buffy. Pajamas.
|
|
|
|