A fast hardware problem on com 's

Category: VC/MFC -> ATL/ActiveX/COM Author: wangsiweiwsw Date: 2001-07-09 12:36:10
 
wangsiweiwsw
2001-07-09 12:36:10
This question is a bit long , plus a limited ability to express himself , so the text is a bit long :

I wrote a com component reads the data, and then call the component reads the data in the MFC, of course, I manually register in advance through the assembly , and after programs are written, compiled and no errors , well, when executed , it says " runtime error " has been tested and is prompted not registered , but I obviously have already registered , and later , I listen to senior sister apprentice said to ( ) function in the app added class InitInstance AfxOleInit (); this line of code , the result is really good ( but when I run on the computer before me without AfxOleInit (); code to run is right ) , I run , there are proper operating results , but did not run long the program would crash , and I debugging, suggesting lines of code cross-border access , but I look for a long time and found that there is no cross-border access , and that this when the program on my computer before running ( note that before the computer does not add AfxOleInit () code to run properly , there is no prompt cross-border access in any line of code inside ) , there is no wrong, why I changed computers, to add a line AfxOleInit () code appeared bounds visited it?
I think for a long time , I think the problem lies in the AfxOleInit () on this line of code , two computer except this line of code , the other are the same, is not it add this line of code before the computer there will also add cross-border access, and then I found a computer before , plus AfxOleInit (); this code , when there really is running out of bounds access error , put me happy almost jumped .

now know where the problem ( I infer that AfxOleInit (); problems in this line of code , you do not know God's view is great ~ ~ ~ ) , and then how to change it , and remove it it, obviously registered component assembly was prompted not registered before, do not go, it will run a crash , there is no way to explain !

how to do ?
jamesqiangwang
2001-07-09 12:47:49
Suite problem ?
CoInitialize or CoInitializeEx
zhenglu12
2001-07-09 12:55:18
I did not have to use AfxOLeInit
AfxOLeInit is CoInitialize (  NULL  ) package
php_xsyc
2001-07-09 13:10:23
AfxOleInit is used to initialize the
use com
must call this function when you do your own testing should be com when you write a good environment has been initialized
you here is definitely a problem
own code little by little, check it
wzqlj
2001-07-09 13:28:25
you have to judge AfxOleInit return values? Do not easily suspect API MFC provided , AfxOleInit addition to initialize the thread suites, also registered a message filter. MFC supports only single-threaded apartment, perhaps before executing AfxOleInit have also performed a loaded DLL initialization , so even if you do not perform AfxOleInit can not go wrong. Behavior in this situation may be different on different machines , such as the machine properly, the machine error , not that this is AfxOleInit wrong , it is customary to determine what you want to return a value , in order to determine whether the current operating state exists suite type conflict .

there , " my code no problem." This sentence is very people nausea and caution.
hgj002
2001-07-09 13:46:59
you can remotely debug your components even start if all else fails , it is no initialization suite , out of bounds , you have to look at what specific piece of code to debug problems
zhangyu19890625
2001-07-09 14:02:14
think it caught out of bounds exception, and then to carefully analyze
qq1041840445
2001-07-09 14:17:11
which   problems on computers , on debugging on which computer , nobody tells you each computer environment may not be the same ?
song5229881
2001-07-09 14:32:29
Well , I look at the top !
sadan6636
2001-07-09 14:45:14
First determine which line of code collapse, unthinking who can help you
maomss
2001-07-09 14:51:22


Hello , Thank you for your answer.

your answer is correct , you can use :: CoInitialize (  NULL  ) to replace AfxOleInit, so it does not appear I said above error , thank you !
guangtongzhuangshi
2001-07-09 15:09:26


Thank you for your help.

because the code is more, look at the code is a very annoying thing, I pasted up , then estimated that many people will crash out , so I did not paste , and in fact, I'm almost sure is not my code itself issue . And later proved my guess is correct , the question is AfxOleInit appear on this line of code .
Buthcer
2001-07-09 15:27:32


Hello , Thank you for your answer.

But you say com must add AfxOLeInit use this function I do not agree with , a , I have personally verified , sometimes when you do not need to add MFC , but the same code copy to when another machine may have to appear on the situation to increase .
2, use :: CoInitialize (  NULL  ) seems to be replacing AfxOleInit to initialize com, also personally verified .

no problem with my code , I would AfxOleInit replaced :: CoInitialize (  NULL  ) after the problems are solved . I now want to know why is it so ? ? ?
LJL112
2001-07-09 15:33:36


ah , thank you for your answer and reminders.

I judge had AfxOleInit its return value , the return value is non- zero, I think the initialization is successful, the concept of the suite , I do not know, maybe I need to replenish suite -related knowledge .
yonghua110
2001-07-09 15:53:11


com I understand is limited to a very basic application , not solid basic skills , forgive me , huh. Amount to you to learn.