[Explorer API] How can I get active datasource and active document ?

Hi,

Inspired by this thread

https://communities.bentley.com/products/programming/microstation_programming/f/microstation-programming---forum/108454/v8i-mdl-how-to-call-projectwise-api-from-native-code-mdl/329450#329450

I'm trying to call the ProjectWise API from MDL/cpp. I would like to get the active datasource, project and document from PW Explorer and I've tried to do it this way:

if (aaApi_Initialize(AAMODULE_EXPLORER))
	{
		aaApi_InitializeModules(AAMODULE_ALL);

		HDSOURCE dataSource = aaApi_GetActiveDatasource();
		if (dataSource == NULL)
			lifalib_dmsg("NULL");
		else
			lifalib_dmsg("ActiveDatasource OK");

		lifalib_dmsg("Count = %d", aaApi_GetProjectCount());

The dataSource is NULL and the number of projects is -1...

There is no problem in find a datasource by name:

HDSOURCE *pdataSource;
		ULong count;
		if (aaApi_GetDatasourceHandlesByName(L"Test", &pdataSource, &count))
			lifalib_dmsg("OK");
		else
			lifalib_dmsg("NOT OK");

What am I missing or doing wrong ?

Regards,

Evan H. Hansen