Click here to Skip to main content
15,914,943 members
Home / Discussions / COM
   

COM

 
GeneralProblem with C# COM server Pin
Tunca Bergmen24-Apr-02 23:38
Tunca Bergmen24-Apr-02 23:38 
AnswerRe: Problem with C# COM server Pin
netcreator16-Apr-09 17:54
netcreator16-Apr-09 17:54 
GeneralPlease help me! Pin
StefanM24-Apr-02 11:01
StefanM24-Apr-02 11:01 
QuestionHow to pass a string into COM Pin
24-Apr-02 5:34
suss24-Apr-02 5:34 
AnswerRe: How to pass a string into COM Pin
Paul M Watt24-Apr-02 5:42
mentorPaul M Watt24-Apr-02 5:42 
GeneralRe: How to pass a string into COM Pin
Sayan Mukherjee24-Apr-02 21:30
Sayan Mukherjee24-Apr-02 21:30 
GeneralRe: How to pass a string into COM Pin
25-Apr-02 1:29
suss25-Apr-02 1:29 
GeneralRe: How to pass a string into COM Pin
Matt Philmon1-May-02 2:11
Matt Philmon1-May-02 2:11 
There's a few things you need to take into account.

Your COM object's interface that you're trying to reach... did you implement it using IUnknown or IDispatch? IUnknown will let you more or less pass any kind of data you want including good 'ol CHAR and CHAR* type stuff. IDispatch, which is required if your component is or ever will be used in Visual Basic or any scripting language (JavaScript or VB Script), is much more limited. From my experience and I don't doubt some will disagree, IDispatch is "safer" in most cases regardless of whether your object is needed in VB or not (particularly if you have to support Windows 95/98). IDispatch, however, greatly narrows down your options to a degree on types. Sure, there's ways around this restriction, but basically with IDispatch you have some basic integer types... after that you really have to use BSTR's and VARIANT's. These are a real pain in the... keister, particularly in C++ but you'll have better results.

The solution using SysAllocString mentioned above would be the correct usage if you're using IDispatch and passing a BSTR. I'm gathering from the type you mentioned that you chose IUnknown.

In this case, it's really quite simple,
CString strData("Hello World");

// Load your smart pointer to your object
IMyInterfacePtr pInterface;
HRESULT hr = pInterface.CreateInstance(__uuidof(MyCoClass));
if (SUCCEEDED(hr))
{
hr = pInterface->YourFunctionCall(strData.GetBuffer(strData.GetLength()));
if (SUCCEEDED(hr))
{

}
else
{

}
strData.ReleaseBuffer();
}
AnswerRe: How to pass a string into COM Pin
soup29-Apr-02 2:21
soup29-Apr-02 2:21 
GeneralA strange issue about custom interface Pin
maya24-Apr-02 4:08
maya24-Apr-02 4:08 
GeneralRe: A strange issue about custom interface Pin
Paul M Watt24-Apr-02 8:24
mentorPaul M Watt24-Apr-02 8:24 
GeneralTimer in DCOM server Pin
Hans Ruck23-Apr-02 23:11
Hans Ruck23-Apr-02 23:11 
GeneralRe: Timer in DCOM server Pin
Sayan Mukherjee24-Apr-02 21:38
Sayan Mukherjee24-Apr-02 21:38 
QuestionHow to uninstall a component(.dll) by C++ Pin
23-Apr-02 16:47
suss23-Apr-02 16:47 
AnswerRe: How to uninstall a component(.dll) by C++ Pin
bryce23-Apr-02 16:52
bryce23-Apr-02 16:52 
AnswerRe: How to uninstall a component(.dll) by C++ Pin
Vi223-Apr-02 21:01
Vi223-Apr-02 21:01 
AnswerRe: How to uninstall a component(.dll) by C++ Pin
Amit Dey27-Apr-02 16:49
Amit Dey27-Apr-02 16:49 
QuestionHow to uninstall a component(.dll) in a web page Pin
23-Apr-02 16:29
suss23-Apr-02 16:29 
AnswerRe: How to uninstall a component(.dll) in a web page Pin
Michael Dunn23-Apr-02 16:58
sitebuilderMichael Dunn23-Apr-02 16:58 
AnswerRe: How to uninstall a component(.dll) in a web page Pin
Amit Dey27-Apr-02 16:52
Amit Dey27-Apr-02 16:52 
QuestionHow to add a popup menu into Explorer Bar ActiveX Control? Pin
23-Apr-02 7:54
suss23-Apr-02 7:54 
AnswerRe: How to add a popup menu into Explorer Bar ActiveX Control? Pin
Amit Dey27-Apr-02 19:21
Amit Dey27-Apr-02 19:21 
GeneralATL-based subclassed windowed control flickers on resize Pin
Mr Matt Ellis, Esq23-Apr-02 5:39
Mr Matt Ellis, Esq23-Apr-02 5:39 
QuestionHow to use COM Objects in VC++ - Please Help Pin
23-Apr-02 1:33
suss23-Apr-02 1:33 
AnswerRe: How to use COM Objects in VC++ - Please Help Pin
Paul M Watt24-Apr-02 8:27
mentorPaul M Watt24-Apr-02 8:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.