Click to See Complete Forum and Search --> : Shell Interface prob - ITaskbarList


is.chris
May 15th, 2006, 11:31 PM
Hi,

I have just tried implementing the ITaskbarList interface


bool Window::ShowInTaskBar( __Bool_ b_Show ){

//************************************************************************************************

//this->i_TaskBar is an ITaskbarList*
bool b_Return = false;

if( ( !this->i_TaskBar ) && ( CoCreateInstance( CLSID_TaskbarList, NUM_0, CLSCTX_LOCAL_SERVER, IID_ITaskbarList, ( LPVOID* ) this->i_TaskBar ) == S_OK ) ){

this->i_TaskBar->HrInit();
}else{

PTR0( this->i_TaskBar );
}

if( this->i_TaskBar ){

if( b_Show ){

this->i_TaskBar->AddTab( this->Handle() );
}else{

this->i_TaskBar->DeleteTab( this->Handle() );

}
}
return b_Return;
}


CoCreateInstance appears to be failing, although i do not think I am doing things right... I have not found a topic showing shell usage only MSDN topics on what is in the shell.

anybody used this interface before that can point me in the right direction?

I don't think I am passing the right data type to the last param of CoCreateInstance
Cheers

kirants
May 16th, 2006, 12:17 AM
Typically, you would do this:

CoCreateInstance( CLSID_TaskbarList, NUM_0, CLSCTX_LOCAL_SERVER, IID_ITaskbarList, ( LPVOID* ) &this->i_TaskBar );

Note the & for the last param.

Also, make sure you call CoInitialize(/Ex) before you call CoCreateInstance.
Also, make sure you always check for SUCCEEDED() or FAILED() on the return value of any COM call.

is.chris
May 16th, 2006, 12:33 AM
This is what I have now, but CoCreateInstance still fails, running WinXP Sp2.



bool Window::ShowInTaskBar( bool b_Show ){

//**********************************************************************************************************************

//Variable list
bool b_Return = false;
HRESULT h_Return = CoInitializeEx( NUM_0, COINIT_APARTMENTTHREADED );


if( ( h_Return == S_OK ) || ( h_Return == S_FALSE ) ){

if( ( !this->i_TaskBar ) && ( CoCreateInstance( CLSID_TaskbarList, NUM_0, CLSCTX_LOCAL_SERVER, IID_ITaskbarList, ( LPVOID* ) &this->i_TaskBar ) == S_OK ) ){

this->i_TaskBar->HrInit();

}else{

PTR0( this->i_TaskBar );
}


if( this->i_TaskBar ){

if( b_Show ){

this->i_TaskBar->AddTab( this->Handle() );
}else{

this->i_TaskBar->DeleteTab( this->Handle() );

}
}
}
return b_Return;
}

kirants
May 17th, 2006, 12:17 AM
When something fails, it always helps to note what the HRESULT code is. You can use a tool called Error lookup ( shipped with Visual Studio -> accessible from the IDE from tools menu ) and punch in the error number there and see what the description is

How to use error lookup (http://www.codeguru.com/forum/showpost.php?p=1262709&postcount=14)

is.chris
May 17th, 2006, 02:30 AM
Yeah it returns, REGDB_E_CLASSNOTREG, but the interface is in the registry and registered, same as CoGetClassObject.

I am pretty sure ITaskbarList is the interface winamp uses to control its taskbar and it works fine.

Am starting to think WinXp has some extra requirements or something