COM??????????C++
???????????? ???????[ 2014/7/4 14:07:18 ] ????????COM C++ net
?????????????????????????COM??????????????????????????????????????COM?·???????????????????????
#pragma once
class IExtensibleObject
{
public:
virtual void* Dynamic_Cast(const char* str)=0;
virtual void AddRef()=0;
virtual void Release()=0;
};
class IFastString:public IExtensibleObject
{
public:
virtual int Length(void)=0;
virtual int Find(const char* str)=0;
};
class FastString:public IFastString
{
public:
FastString(const char* str=NULL);
virtual void* Dynamic_Cast(const char* str);
virtual void AddRef() ;
virtual void Release();
virtual int Length();
virtual int Find(const char* str);
~FastString();
private:
char* m_str;
int len;
int m_cPtrs;//???ü???
};
//????????
extern "C" __declspec(dllimport) IFastString* CreateFastString(const char* psz);
|
?????????COM?????????????????????????????????
????1??????????????????????????????????????????????????????????????/?????????????????
????2??????????ó???????????????FastString????????FastString?????????????????????????FastString????????IFastString???????????????DLL??FastString?????С??????????????????е?????????????DLL?д??????
????3?????????FastString????????????????????delete??CreateFastString????????????????COM??????????FastString?????????????????????в???????????????????????????????????????????????????????????????????????ü???????????FastString??
????4????????????Dynamic_Cast??
????RTTI???????????????????????????????????????RTTI?????????е???????????“??????????????????????????????”???????????????????в???????????????????????????麯????????????????????麯?????鷽?????е?λ????????????е??????????????е??????棬????2???????????????鷽?????鷽?????е?λ???????????????????????????????virtual??????public???????????virtual???????鷽?????鷽?????е?λ?ú??鷽??????????????£?????????????????????鷽???С?
????????????????????ü????????????????????????????????????????????е?????????
????5??????????????????棬????????????????
???????????????????м?????????????鷽?????е????????仯???°汾??DLL??????????????????????????????????????????????????DLL??????????????????£?????????????????????????
?????????????????????DLL????????????£?
????COM?????????????????????DLL????new????????????????ü???????????????????????????COM????COM???????????????仯???????????????????????????????????????鷽?????е?λ?ò???????????????????????????????????????
?????????????????????virtual?????????????????????????????????????????????FastString?????????????FastString???????????????????????????????len??κ????Length????????????????3????汾????????????????DLL???????????????ж???OK?????????ò???????κ?????????????FastString????????????????????????DEMO????????????£?????????????
???????????????????????COM??????????????C++??
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11