Click here to Skip to main content
15,877,574 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CWnd pointer Pin
josip cagalj21-Sep-07 2:13
josip cagalj21-Sep-07 2:13 
GeneralRe: CWnd pointer Pin
bob1697221-Sep-07 2:16
bob1697221-Sep-07 2:16 
GeneralRe: CWnd pointer Pin
Mark Salsbery21-Sep-07 8:22
Mark Salsbery21-Sep-07 8:22 
GeneralRe: CWnd pointer Pin
josip cagalj23-Sep-07 22:55
josip cagalj23-Sep-07 22:55 
QuestionException Pin
shir_k21-Sep-07 1:43
shir_k21-Sep-07 1:43 
AnswerRe: Exception Pin
Roger Stoltz21-Sep-07 3:47
Roger Stoltz21-Sep-07 3:47 
GeneralRe: Exception Pin
shir_k23-Sep-07 20:04
shir_k23-Sep-07 20:04 
AnswerRe: Exception Pin
Roger Stoltz23-Sep-07 21:56
Roger Stoltz23-Sep-07 21:56 
shir_k wrote:
CString SerialData
CComVariant vIn;
vIn.Clear();
vIn = CMSCommPtr ->GetInput();
SerialData = vIn.bstrVal;

U see any problem in the above code.


All COM interfaces returns a HRESULT, which is a 32-bit integer value that is an error code that equals zero if everything was OK. The ability to return any other type is disguised when using dispatch interfaces. In your case the VARIANT that is supposed to be returned is a temporary object in the wrapper for the MSComm server. The wrapper was created by the wizard when you added the ActiveX component to your project. A pointer to this temporary VARIANT is provided in the parameter list when the interface method is called. For some reason the MSComm server doesn't like how that temporary object is set up, or you may be calling it from the wrong context.
This can happen if you're calling the server from a different thread than the one that created the server without marshalling the interface.

I suggest that you continue with one of the following depending on whether you're using multiple threads or not:

1. If you're using multiple threads you have to know how to cross apartment boundaries the correct way. Read Lim Bio Liong's excellent articles to get the basics down. You'll find them here[^], starting with part 1.

2. If you're only using one single thread, I suggest you use the other implementation of the Input() method that takes a VARIANT in the parameter list according to my first post in this forum thread. This way you have the control over the VARIANT.


"It's supposed to be hard, otherwise anybody could do it!" - selfquote
"High speed never compensates for wrong direction!" - unknown

GeneralRe: Exception Pin
shir_k24-Sep-07 0:35
shir_k24-Sep-07 0:35 
AnswerRe: Exception Pin
Iain Clarke, Warrior Programmer21-Sep-07 4:54
Iain Clarke, Warrior Programmer21-Sep-07 4:54 
GeneralRe: Exception Pin
Mark Salsbery21-Sep-07 8:24
Mark Salsbery21-Sep-07 8:24 
GeneralRe: Exception Pin
shir_k23-Sep-07 19:17
shir_k23-Sep-07 19:17 
Question[Message Deleted] Pin
padpras21-Sep-07 1:17
padpras21-Sep-07 1:17 
AnswerRe: problem with customizing scrollbar Pin
Waldermort21-Sep-07 4:39
Waldermort21-Sep-07 4:39 
AnswerRe: problem with customizing scrollbar Pin
Iain Clarke, Warrior Programmer21-Sep-07 4:56
Iain Clarke, Warrior Programmer21-Sep-07 4:56 
AnswerRe: problem with customizing scrollbar Pin
Iain Clarke, Warrior Programmer21-Sep-07 4:57
Iain Clarke, Warrior Programmer21-Sep-07 4:57 
AnswerPlease don't delete your question. Pin
Iain Clarke, Warrior Programmer23-Sep-07 22:10
Iain Clarke, Warrior Programmer23-Sep-07 22:10 
Questionproblem in thread calling Pin
AnayKulkarni21-Sep-07 0:23
AnayKulkarni21-Sep-07 0:23 
AnswerRe: problem in thread calling Pin
KarstenK21-Sep-07 0:34
mveKarstenK21-Sep-07 0:34 
AnswerRe: problem in thread calling Pin
nbugalia21-Sep-07 0:35
nbugalia21-Sep-07 0:35 
QuestionSolution ot the following error Pin
Maynka20-Sep-07 23:51
Maynka20-Sep-07 23:51 
AnswerRe: Solution ot the following error Pin
ShilpiP21-Sep-07 0:47
ShilpiP21-Sep-07 0:47 
GeneralRe: Solution ot the following error Pin
Maynka21-Sep-07 1:07
Maynka21-Sep-07 1:07 
GeneralRe: Solution ot the following error Pin
ShilpiP21-Sep-07 1:32
ShilpiP21-Sep-07 1:32 
GeneralRe: Solution ot the following error Pin
ShilpiP21-Sep-07 1:43
ShilpiP21-Sep-07 1:43 

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.