|
You can use CComBSTR class to make this conversion.
CComBSTR bstrString( tcharString );
or
bstrString = tcharOtherString;
With best wishes,
Vita
|
|
|
|
|
|
The string conversion macros require that you put the USES_CONVERSION; macro at the beginning of the function/block.
--Mike--
Just released - RightClick-Encrypt v1.3 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Your getting this error because your not using the USES_CONVERSION macro in your functions that use the T2OLE macro. For example:
void myfunc(LPTSTR szIN, BSTR* bszOut){
USES_CONVERSION;
bszOut = T2OLE(szIN);
}
Hope that helps.
|
|
|
|
|
Yep, it workes this way. Thanks.
|
|
|
|
|
Hi!
I am new to COM / ATL and just trying to learn that...
I want to have a ATL COM Component with a dialog box with all its message handeling in it and want to show up that dialog in some other Client app using some interface etc.
Pls tell me how to do that. I will be thankful if you can give me detailed tutorial kind ....specifying all steps ..as I am new to it.
One more another question....
Actually my need is that my client ( a win32 SDK project without MFC) has a method which adds property Sheets and all it needs is a Dialog Resource ID and Callback function of that dialog to add propertysheet to existing propertysheet. Now I want a com dll having that property sheet. I would like to know how to do that ...Pls help . What I should do to make COM Dll and how to get Dialog ID and callback function in Client...
I would love to have some code/ project examples
thanks
Naveen
|
|
|
|
|
I need to implement IDispatch::GetIDSOfNames without creating type library, i.e. I need to return certain ID for certain name. How??
|
|
|
|
|
You must implement your version of GetIDsOfNames and correlate it with Invoke. Also you must implement the GetTypeInfoCount and GetTypeInfo to return E_NOTIMPL. And last, you should describe your interface as empty interface, derived from IDispatch.
With best wishes,
Vita
|
|
|
|
|
Yes, thanks, but can I ask some more about memory management. How to allocate memory in IDispatch::GetIDSOfNames implementation? (hich function is needed?)
|
|
|
|
|
I do not see any problem with memory. GetIDSOfNames does not return any memory pointer. If you want to allocate the internal buffers's memory then you can use any strategy you want.
With best wishes,
Vita
|
|
|
|
|
Sorry, I thought I must allocate memory for rgDispId. Now all correct!
P.S. Russian programmers answered me for the my last 4 questions. Hm...
|
|
|
|
|
Welcome on www.RSDN.ru, if you can read the Russian text.
With best wishes,
Vita
|
|
|
|
|
Yeah... My nick is ADK there...
|
|
|
|
|
Hello.
Sorry my poor english.
My question is how to Call ComAddin Function from VBA Macro if ComAddin is maked by using MFC C++;
I know how to call ComAddin function from VBA if ComAddin is maked by using VB.
|
|
|
|
|
is it good practice, or even possible, to have one class factory produce instances of many different COM classes?
i'm trying to make a scripting engine using IActiveScript and such, but i have multiple COM classes implementing IActiveScript, IActiveScriptSite, etc... but I don't want to have a class factory for each one
any thoughts?
- Roman -
|
|
|
|
|
By definition, as the class factory the class object of some class must produce the many instances of that and only that class.
COM standard CoCreateInstance and CoGetClassObject fucntions realize this strategy with IClassFactory interface. But the class object can have another interface by which you can create any other objects as well.
With best wishes,
Vita
|
|
|
|
|
So I need many factories? i didn't understand the second part of your message, thanks anyway
- Roman -
|
|
|
|
|
A creation of a COM object begins from the creation of the its class object via CoGetClassObject(CLSID,context,NULL,IID_Ix,(void**)&pCoObj) where CocreateInstance uses IID_Ix is equal IID_IClassFactory. So created object is called a class factory object. Then CoCreateInstance uses pCoObj->IClassFactory::CreateInstance(pUnkOuter, IID_Iy, (void**)ppObj) to create a COM object with interface Iy.
Nobody prevents you to use other interface which let you create some COM objects, which may belong to different classes, by calling of some Ix function with some parameter - pCoObj->Ix::FuncCreate(BSTR type, IActiveScript* *ppScript).
Or create alone object M which will be a manager of your objects by previous scheme of a class object.
With best wishes,
Vita
|
|
|
|
|
Hi,
I am having some content in textfile.iam reading the content from file by using API called Read file.I convert this string to bstr using (_bstr_t)string and then i called the method LoadXML(string,bool).But when iam parsing this iam not getting output.
why it is so.
Thanks in advance.
|
|
|
|
|
Hi,
I'm a newbie here and I was hoping if anyone knew ANYTHING about the ICustomDownload interface. It's a COM interface for allowing control of downloads from Internet Explorer. I think it was introduced for IE v5.5 or something.
I read something about it in MSDN, but I can't seem to find it anymore - plus it didn't show enough info.
You've probably seen programs like GetRight, GoZilla and DAP which I think implement this interface.
Cheers
Dazza
|
|
|
|
|
I am currently working on a project to migrate some delphi based com objects to .NET, for reasons that are beyond the scope of this post I am going to be doing this method by method - so I am looking at using managed components from unmanaged code.
As a test project, I create a simple delphi based com object with two methods :
RandMethodA : Returns a random number from 0-100
RandMethodB : Returns a random number from 101-200
The idea is the redirect calls into RandMethodA to a piece of .NET managed code that does exactly the same thing.
Right thats the theory over with, this is the problem I am encountering :
I have created the .NET code and using the "tlbexp" & regasm" tools I have created a TLB file for it, I then added this TLB file to the delphi COM code - when I compile with the new TLB I get alot of compile errors in a file called mscorlib_TLB.pas which seems to be something that is autogenerated when I import the .NET TLB into the project.
eg: (some not all)
[Error] mscorlib_TLB.pas(4984): Illegal type in OLE automation section: 'Byte'
[Error] mscorlib_TLB.pas(4991): Illegal type in OLE automation section: 'Single'
[Error] mscorlib_TLB.pas(4992): Illegal type in OLE automation section: 'Double'
[Error] mscorlib_TLB.pas(10396): Illegal type in OLE automation section: 'Byte'
[Error] mscorlib_TLB.pas(10403): Illegal type in OLE automation section: 'Single'
[Error] mscorlib_TLB.pas(10404): Illegal type in OLE automation section: 'Double'
[Fatal Error] ManagedRandServer_TLB.pas(45): Could not compile used unit 'mscorlib_TLB.pas'
I sincerly hope this makes sense to somebody
Thanks in advance
RANT : Why does my boss give me these "projects" aaarrrggghhh
|
|
|
|
|
If I have call a COM object in an in-process server, which modifies a pointer, passed to it, in a worker thread as followers.
CoInitialize( NULL );
IProfile Profile;
Profile.CreateDispatch(_T("AutomationDispatch.Profile"));
int Size = Profile.GetDataSize();
double * pData = new double[ Size ];
Profile.GetData( pData );
Every works OK.
But if I call CoInitialize( NULL ) in the main thread before creating the worker thread. Then I get the following run-time error
Heap block at 00148698 modified at 001486A8 past requested size of 8.
When I debug the code, the pointer memory address passed to the COM object is changed in the COM object implementation.
If I pass the address of the pointer to COM object. Then there are no heap errors. I assume this because the address is passed by value.
|
|
|
|
|
Since you are planning to pass your COM object to different thread, call CoInitializeEx(NULL, COINIT_MULTITHREADED); . Your worker thread need to call CoInitialize(NULL) too.
|
|
|
|
|
:(I have one COM with function Connect(string,integer) which connects to a Socket Server,and property, Status which returns integer.The COM is working fine with VB.But not working with ASP.but it is returning status from the COM.I tried with one more property which returns string.That is also returning perfactly.
My Conclusion is there might be some type conversion problem.Can anyone suggest anything please.And one more problem is the dll remains in use ,if i close the page also.
Big D
|
|
|
|
|
Hi,
I am facing a problem.
Following is the description:
I have a COM server(EXE).
It has a method, "ServerMethodAAA". The "ServerMethodAAA" method, calls a Dll function, "DllFuncDlg()". "DllFuncDlg()" function invokes a dialog box.
I have a client app for my COM Server, which loads COM Server in hidden mode.
Problem:
When client calls method, "ServerMethodAAA", the dialog is displayed in hidden mode. That is, behind client application. I want that dialog should appear in fore ground window.
Please suggest me.
Regards.
|
|
|
|