Click here to Skip to main content
15,042,397 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CArray can't add Pin
jw8130-Jan-05 6:50
Memberjw8130-Jan-05 6:50 
GeneralRe: CArray can't add Pin
Bob Ciora30-Jan-05 6:54
MemberBob Ciora30-Jan-05 6:54 
GeneralRe: CArray can't add Pin
jw8130-Jan-05 6:57
Memberjw8130-Jan-05 6:57 
GeneralRe: CArray can't add Pin
Bob Ciora30-Jan-05 7:02
MemberBob Ciora30-Jan-05 7:02 
GeneralRe: CArray can't add Pin
jw8130-Jan-05 19:03
Memberjw8130-Jan-05 19:03 
Questionwhy a COM can not be deleted? Pin
includeh1030-Jan-05 5:15
Memberincludeh1030-Jan-05 5:15 
AnswerRe: why a COM can not be deleted? Pin
Bob Ciora30-Jan-05 6:52
MemberBob Ciora30-Jan-05 6:52 
GeneralRe: why a COM can not be deleted? Pin
includeh1030-Jan-05 10:28
Memberincludeh1030-Jan-05 10:28 
Hi Bob,
thanks.

I am testing a sample downloaded.
the sample uses a ref count (ULONG m_uRefCount) initialized as 1 in construct;

in AddRef(), the count inc 1;
in Release(), the count dec 1;
in QueryInterface(), it may inc 1;

is the idea right?

details are in followings:
----------------------------------------
//construct
CContextMenu::CContextMenu()
{
m_uRefCount=1;
}

STDMETHODIMP_(ULONG)CContextMenu::AddRef()
{
return ++m_uRefCount;
}

STDMETHODIMP_(ULONG)CContextMenu::Release()
{
if(--m_uRefCount==0)
{
delete this;
return 0;
}
return m_uRefCount;
}

STDMETHODIMP CContextMenu::QueryInterface(REFIID iid,LPVOID FAR*ppv)
{
m_uRefCount++;
if(IsEqualIID(riid,IID_IUnknown))
{
*ppv=this;
return NOERROR;
}
else if(IsEqualIID(riid,IID_IShellExtInit))
{
*ppv=(LPSHELLEXTINIT)this;
return NOERROR;
}
else if(IsEqualIID(riid,IID_IContextMenu))
{
*ppv=(IContextMenu*)this;
return NOERROR;
}
else
{
m_uRefCount--;
*ppv=0;
return ResultFromScode(E_NOINTERFACE);
}
}

m_uRefCount is NOT used by other placess.
what is wrong?















GeneralRe: why a COM can not be deleted? Pin
geo_m30-Jan-05 19:39
Membergeo_m30-Jan-05 19:39 
GeneralTrouble with for(;;) Pin
ghostpirate730-Jan-05 3:20
Memberghostpirate730-Jan-05 3:20 
GeneralRe: Trouble with for(;;) Pin
Bob Ciora30-Jan-05 6:00
MemberBob Ciora30-Jan-05 6:00 
GeneralRe: Trouble with for(;;) Pin
Bob Ciora30-Jan-05 6:32
MemberBob Ciora30-Jan-05 6:32 
QuestionCan not debug COM from ASP.NET ... Pin
vgrigor130-Jan-05 2:27
Membervgrigor130-Jan-05 2:27 
QuestionWhy toolbar disabled? Pin
skybirdcao30-Jan-05 1:17
Memberskybirdcao30-Jan-05 1:17 
Questiona big challenge: how to control toolbar's button size? Pin
skybirdcao30-Jan-05 0:51
Memberskybirdcao30-Jan-05 0:51 
Questionhow to get pixel? Pin
cobre12330-Jan-05 0:46
susscobre12330-Jan-05 0:46 
QuestionHow to add a password to a .exe file? Pin
sharkmouse29-Jan-05 23:39
Membersharkmouse29-Jan-05 23:39 
AnswerRe: How to add a password to a .exe file? Pin
skybirdcao30-Jan-05 1:51
Memberskybirdcao30-Jan-05 1:51 
GeneralRe: How to add a password to a .exe file? Pin
User 665830-Jan-05 2:16
MemberUser 665830-Jan-05 2:16 
GeneralRe: How to add a password to a .exe file? Pin
sharkmouse30-Jan-05 18:23
Membersharkmouse30-Jan-05 18:23 
GeneralRe: How to add a password to a .exe file? Pin
Le Quang Long27-Apr-12 23:37
MemberLe Quang Long27-Apr-12 23:37 
GeneralVisual Studio start page configuration. Pin
rbid29-Jan-05 22:19
Memberrbid29-Jan-05 22:19 
GeneralRe: Visual Studio start page configuration. Pin
PJ Arends29-Jan-05 22:56
professionalPJ Arends29-Jan-05 22:56 
GeneralRe: Visual Studio start page configuration. Pin
rbid29-Jan-05 23:59
Memberrbid29-Jan-05 23:59 
GeneralRe: Visual Studio start page configuration. Pin
rbid30-Jan-05 0:17
Memberrbid30-Jan-05 0:17 

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.