CoInitialize의 기능

C++에서 COM 객체를 사용하기 위해서는 객체를 사용하려는

각 Thread에서 CoInitialize나 CoInitializeEx를 호출해 줘야 합니다.

또한 CoInitialize를 호출하면 COM 객체의 사용이 끝났을 때 반드시 CoUninitialize를 호출해 줘야 합니다.

CoInitialize를 n 번 호출할 경우 CoUninitialize도 n 번 호출이 되어야 한다는 의미 입니다.

CoInitialize가 S_FALSE를 리턴할 경우 S_FALSE를 리턴한 경우를 포함해서 CoUnintialize를 호출해야 합니다.

그런데 문제는 CoInitializeEx의 경우 다음과 같은 경우에 문제가 발생할 수 있습니다.

CoInitializeEx(COINIT_APARTMENTTHREADED)
CoInitializeEx(COINIT_MULTITHREADED)
CoUninitialize()
CoUninitialize()


위와 같이 호출한 경우 두번째 CoInitializeEx(COINIT_MULTITHREADED)를 호출하면

함수는 reference count를 증가시키지 않고 RPC_E_CHANGED_MODE 를 리턴합니다.

이렇게 되면 CoUninitialize의 호출이 더 많이 일어나게 되어 아직 COM 객체를 사용중인데도 불구하고 관련 연결이나 메모리들이 해제되어버리는 사태가 발생합니다.

이 문제를 해결하려면 RPC_E_CHANGED_MODE를 에러로 간주하고 reference count를 유지시키는 방향으로 코드를 작성하는 것이 좋습니다.

혹은 문제가 발생하지 않도록 reference count를 관리할 또다른 방안이 필요합니다

“CoInitialize의 기능”의 160개의 댓글

  1. This is a good tip particularly to those fresh to the blogosphere.
    Short but very accurate info… Many thanks for
    sharing this one. A must read article!

  2. Having read this I thought it was very informative. I appreciate
    you taking the time and effort to put this short article together.
    I once again find myself personally spending way too much time
    both reading and leaving comments. But so what,
    it was still worthwhile!

  3. Cbd oil that works 2020
    Today, I went to the beachfront with my children. I found a sea shell and gave it to my 4 year
    old daughter and said “You can hear the ocean if you put this to your ear.” She
    placed the shell to her ear and screamed. There was a hermit crab inside and it pinched her ear.
    She never wants to go back! LoL I know this is entirely off topic but
    I had to tell someone! best rated cbd oil http://j.mp/3drY6lE cbd oil that works 2020
    http://j.mp/3drY6lE

  4. I just want to mention I’m newbie to weblog and definitely loved this blog site. Very likely I’m likely to bookmark your site . You absolutely come with impressive posts. Thank you for sharing your website.

  5. I just couldn’t depart your site prior to suggesting that I extremely enjoyed the standard information an individual provide for your visitors? Is gonna be back frequently in order to inspect new posts

  6. When I initially commented I clicked the -Alert me when brand-new comments are included- checkbox and currently each time a remark is included I obtain four emails with the same remark. Exists any way you can remove me from that solution? Thanks!

  7. Do you have a spam issue on this website; I also am a blogger, and I was curious about your situation; we have created some nice methods and we are looking to swap strategies with others,
    please shoot me an e-mail if interested.

  8. There are some fascinating points in time in this post however I don?t understand if I see every one of them facility to heart. There is some legitimacy yet I will hold opinion till I consider it further. Good write-up, many thanks as well as we want much more! Included in FeedBurner too

  9. This website is really a walk-through for every one of the info you wanted about this and also didn?t recognize who to ask. Glance right here, and also you?ll definitely uncover it.

  10. An interesting conversation is worth comment. I think that you ought to create a lot more on this subject, it could not be a frowned on subject however usually people are not enough to speak on such subjects. To the next. Cheers

  11. I uncovered your blog website on google and inspect a few of your very early blog posts. Remain to keep up the excellent operate. I simply added up your RSS feed to my MSN News Viewers. Looking for onward to learning more from you later!?

  12. I discovered your blog site on google as well as check a few of your very early posts. Continue to maintain the very good run. I simply extra up your RSS feed to my MSN Information Reader. Looking for ahead to reading more from you in the future!?

  13. I am typically to blog writing and also i truly appreciate your material. The article has actually peaks my interest. I am going to bookmark your site and keep looking for brand-new details.

  14. When I initially commented I clicked the -Inform me when brand-new comments are added- checkbox as well as currently each time a comment is added I get four emails with the exact same remark. Exists any way you can remove me from that service? Many thanks!

  15. A fascinating conversation deserves comment. I believe that you should create extra on this topic, it could not be a frowned on topic but typically people are not enough to talk on such topics. To the next. Cheers

  16. Oh my benefits! an amazing short article man. Thank you Nonetheless I am experiencing concern with ur rss. Don?t understand why Not able to subscribe to it. Exists any individual getting the same rss problem? Any person that knows kindly react. Thnkx

  17. After research a few of the article on your internet site currently, and also I absolutely like your means of blog writing. I bookmarked it to my bookmark site listing and also will certainly be examining back quickly. Pls have a look at my web site too as well as let me know what you believe.

  18. When I originally commented I clicked the -Notify me when new comments are included- checkbox and now each time a remark is added I obtain 4 e-mails with the exact same comment. Is there any way you can remove me from that solution? Many thanks!

  19. I simply want to say I am all new to blogging and site-building and definitely loved your web page. More than likely I’m planning to bookmark your site . You really have superb well written articles. Thanks for sharing your blog site.

  20. 핑백: Power to Choose

  21. 핑백: choi game ban ca mien phi

  22. I simply want to say I am newbie to weblog and certainly savored your page. More than likely I’m want to bookmark your site . You certainly have great articles and reviews. With thanks for sharing your webpage.

  23. Thanks so much for giving everyone remarkably special chance to check tips from this website. It is often so fantastic plus stuffed with fun for me and my office peers to visit your site particularly three times weekly to see the newest issues you will have. Of course, I am usually contented concerning the special tips and hints you serve. Certain 2 areas in this article are without a doubt the most efficient we’ve had.

  24. I was just looking for this information for a while. After 6 hours of continuous Googleing, at last I got it in your web site. I wonder what is the lack of Google strategy that do not rank this type of informative web sites in top of the list. Generally the top sites are full of garbage.

  25. I liked as much as you will obtain carried out proper here. The cartoon is attractive, your authored material stylish. however, you command get bought an nervousness over that you wish be delivering the following. unwell unquestionably come more before again as precisely the same nearly a lot ceaselessly inside case you protect this hike.

  26. I simply want to mention I am just very new to blogging and site-building and absolutely liked this web page. Most likely I’m planning to bookmark your blog . You actually have really good article content. Kudos for sharing your blog site.

  27. Howdy would you mind sharing which blog platform you’re using? I’m looking to start my own blog in the near future but I’m having a difficult time selecting between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your layout seems different then most blogs and I’m looking for something completely unique. P.S My apologies for getting off-topic but I had to ask!

  28. Hey there! I know this is kinda off topic however I’d figured I’d ask. Would you be interested in exchanging links or maybe guest writing a blog article or vice-versa? My website covers a lot of the same subjects as yours and I think we could greatly benefit from each other. If you’re interested feel free to shoot me an email. I look forward to hearing from you! Great blog by the way!

  29. Next time I read a blog, Hopefully it does not fail me just as much as this one. After all, Yes, it was my choice to read through, nonetheless I truly believed you’d have something interesting to say. All I hear is a bunch of complaining about something you can fix if you were not too busy looking for attention.

  30. Oh my goodness! Incredible article dude! Many thanks, However I am going through problems with your RSS. I donít know the reason why I can’t subscribe to it. Is there anybody else getting identical RSS problems? Anyone who knows the solution will you kindly respond? Thanks!!

  31. Just want to say your article is as astounding. The clarity to your publish is simply cool and i can think you’re knowledgeable on this subject. Well with your permission let me to grab your RSS feed to stay updated with coming near near post. Thank you a million and please continue the rewarding work.

  32. Fantastic goods from you, man. I have take into account your stuff prior to and you’re simply extremely great. I actually like what you’ve acquired here, certainly like what you are saying and the way in which during which you assert it. You make it entertaining and you still take care of to stay it wise. I can not wait to learn much more from you. This is actually a great website.

  33. I’m impressed, I have to say. Really hardly ever do I encounter a blog that’s both educative and entertaining, and let me inform you, you might have hit the nail on the head. Your thought is excellent; the difficulty is something that not sufficient individuals are speaking intelligently about. I am very comfortable that I stumbled across this in my search for something relating to this.

  34. Another thing I have really noticed is the fact that for many people, bad credit is the consequence of circumstances beyond their control. By way of example they may happen to be saddled having an illness so they really have large bills for collections. It might be due to a job loss or the inability to do the job. Sometimes divorce process can truly send the budget in an opposite direction. Thank you for sharing your thinking on this blog.

  35. After checking out a handful of the blog articles on your web page, I honestly appreciate your way of writing a blog. I book marked it to my bookmark website list and will be checking back in the near future. Please visit my website too and tell me what you think.

  36. Having read this I thought it was very informative. I appreciate you finding the time and effort to put sbobet online this informative article together. I once again find myself personally spending a significant amount of time both reading and leaving comments

  37. Hi! I could have sworn I’ve visited this blog before but after browsing through some of the posts I realized it’s new to me. Regardless, I’m definitely delighted I found it and I’ll be bookmarking it and checking back regularly.

  38. Together with everything which seems to be building inside this specific subject matter, your points of view happen to be fairly exciting. Nevertheless, I am sorry, because I can not give credence to your entire theory, all be it exciting none the less. It looks to everybody that your comments are actually not totally justified and in fact you are generally yourself not even completely convinced of the point. In any event I did enjoy looking at it.

  39. Howdy, I do believe your website may be having web browser compatibility issues. Whenever I take a look at your web site in Safari, it looks fine however, if opening in IE, it has some overlapping issues. I simply wanted to provide you with a quick heads up! Other than that, fantastic site.

  40. I’m amazed, I must say. Seldom do I encounter a blog that’s equally educative and entertaining, and let me tell you, you’ve hit the nail on the head. The problem is an issue that too few folks are speaking intelligently about. I am very happy that I came across this in my search for something concerning this.

  41. Right here is the perfect website for anybody who hopes to understand this topic. You realize a whole lot its almost tough to argue with you (not that I really would want to…HaHa). You definitely put a brand new spin on a subject which has been written about for years. Wonderful stuff, just wonderful.

  42. An outstanding share! I’ve just forwarded this onto a co-worker who had been doing a little research on this. And he actually ordered me dinner simply because I stumbled upon it for him… lol. So let me reword this…. Thanks for the meal!! But yeah, thanx for spending the time to talk about this issue here on your site.

  43. I think other site proprietors should take this web site as an model, very clean and excellent user genial style and design, as well as the content. You are an expert in this topic!

  44. I like what you guys are up too. Such intelligent work and reporting! Carry on the excellent works guys I have incorporated you guys to my blogroll. I think it will improve the value of my web site 🙂

  45. Can I simply say what relief to get somebody that in fact knows what theyre dealing with on-line. You actually know how to bring a concern to light to make it essential. Workout . should ought to see this and can see this side of your story. I cant think youre less well-known simply because you definitely hold the gift.

  46. I blog often and I genuinely appreciate your information. This article has truly peaked my interest. I am going to book mark your website and keep checking for new details about once per week. I subscribed to your Feed as well.

  47. May I just say what a comfort to uncover an individual who actually understands what they’re talking about over the internet. You definitely realize how to bring a problem to light and make it important. More people need to look at this and understand this side of your story. I was surprised you aren’t more popular given that you most certainly have the gift.

  48. After I initially commented I appear to have clicked the -Notify me when new comments are added- checkbox and from now on whenever a comment is added I get four emails with the same comment. There has to be a means you are able to remove me from that service? Thanks a lot.

  49. Hi, i feel that i saw you visited my blog so i came to “return the desire”.I’m attempting to find issues to enhance my site!I guess its adequate to use a few of your ideas!!

  50. Oh my goodness! Amazing article dude! Thank you so much, However I am going through problems with your RSS. I don’t understand why I cannot join it. Is there anyone else getting similar RSS issues? Anyone that knows the answer can you kindly respond? Thanx!

  51. I was just searching for this info for some time. After six hours of continuous Googleing, finally I got it in your website. I wonder what is the lack of Google strategy that do not rank this kind of informative web sites in top of the list. Generally the top websites are full of garbage.

  52. Hello! I could have sworn I’ve visited this site before but after browsing through some of the posts I realized it’s new to me. Regardless, I’m definitely pleased I discovered it and I’ll be book-marking it and checking back regularly!

  53. I should say also believe that mesothelioma cancer is a uncommon form of cancer malignancy that is usually found in people previously familiar with asbestos. Cancerous tissue form inside the mesothelium, which is a shielding lining which covers the majority of the body’s areas. These cells normally form from the lining on the lungs, tummy, or the sac that encircles one’s heart. Thanks for giving your ideas.

  54. Hi there! I simply would like to offer you a big thumbs up for your great information you have got right here on this post. I will be returning to your website for more soon.

  55. Right here is the perfect web site for anybody who would like to understand this topic. You know so much its almost hard to argue with you (not that I actually will need to…HaHa). You definitely put a fresh spin on a topic that’s been discussed for many years. Excellent stuff, just wonderful.

  56. This is the perfect site for everyone who hopes to find out about this topic. You understand a whole lot its almost hard to argue with you (not that I really will need to…HaHa). You definitely put a brand new spin on a subject which has been discussed for decades. Wonderful stuff, just great.

  57. hi!,I like your writing very much! share we communicate more about your post on AOL? I need a specialist on this area to solve my problem. May be that’s you! Looking forward to see you.

  58. Howdy! This post couldn’t be written any better! Reading through this article reminds me of my previous roommate! He continually kept talking about this. I will forward this post to him. Pretty sure he will have a great read. Many thanks for sharing!

  59. Hello! Someone in my Myspace group shared this site with us so I came to take a look. I’m definitely enjoying the information. I’m bookmarking and will be tweeting this to my followers! Wonderful blog and wonderful style and design.

  60. An outstanding share! I’ve just forwarded this onto a coworker who was doing a little research on this. And he in fact ordered me lunch because I found it for him… lol. So allow me to reword this…. Thanks for the meal!! But yeah, thanx for spending some time to talk about this subject here on your web page.

  61. I have been exploring for a little bit for any high quality articles or blog posts on this kind of area . Exploring in Yahoo I at last stumbled upon this website. Reading this information So i am happy to convey that I have a very good uncanny feeling I discovered just what I needed. I most certainly will make sure to do not forget this website and give it a look regularly.

  62. Hello, I believe your site could be having web browser compatibility problems. Whenever I look at your website in Safari, it looks fine however when opening in I.E., it’s got some overlapping issues. I simply wanted to give you a quick heads up! Apart from that, excellent site!

  63. It’s appropriate time to make some plans for the future and it’s time to be happy. I’ve read this post and if I could I desire to suggest you few interesting things or tips. Perhaps you could write next articles referring to this article. I want to read more things about it!

  64. certainly like your web site but you need to test the spelling on quite a few of your posts. Many of them are rife with spelling problems and I find it very troublesome to tell the reality nevertheless I will certainly come back again.

  65. I must say, as a lot as I enjoyed reading what you had to say, I couldnt help but lose interest after a while. Its as if you had a wonderful grasp on the subject matter, but you forgot to include your readers. Perhaps you should think about this from far more than one angle. Or maybe you shouldnt generalise so considerably. Its better if you think about what others may have to say instead of just going for a gut reaction to the subject. Think about adjusting your own believed process and giving others who may read this the benefit of the doubt.Jobs offered

  66. Together with every thing which appears to be building throughout this area, your viewpoints are relatively stimulating. However, I appologize, but I do not subscribe to your whole idea, all be it stimulating none the less. It appears to everyone that your comments are generally not completely rationalized and in simple fact you are generally your self not wholly confident of your argument. In any event I did appreciate reading it.

  67. This design is steller! You certainly know how to keep a reader amused. Between your wit and your videos, I was almost moved to start my own blog (well, almost…HaHa!) Excellent job. I really enjoyed what you had to say, and more than that, how you presented it. Too cool!

  68. It’s a shame you don’t have a donate button! I’d certainly donate to this outstanding blog! I suppose for now i’ll settle for bookmarking and adding your RSS feed to my Google account. I look forward to fresh updates and will talk about this blog with my Facebook group. Chat soon!

  69. Most of whatever you articulate is supprisingly legitimate and it makes me ponder the reason why I had not looked at this in this light before. This article truly did turn the light on for me personally as far as this specific topic goes. Nonetheless at this time there is actually one particular issue I am not really too cozy with so whilst I make an effort to reconcile that with the actual core idea of your position, let me see exactly what all the rest of your subscribers have to point out.Well done.

  70. Thanks on your marvelous posting! I truly enjoyed reading it, you’re a great author.I will be sure to bookmark your blog and will eventually come back in the foreseeable future. I want to encourage that you continue your great job, have a nice day!

댓글 남기기