From: sisimma on
Hi,

I've ported UPnP sample code into Windows Mobile 6.0 SDK from "PUBLIC\SERVERS\
SDK\SAMPLES\UPNP\DEVICE" in Windows Embedded CE 6.0.

UPnP COM dll has been registered successfully and then run regdevice.exe.

I'm asking why my code below doesn't return OK in upnpdevice.dll.

hr = pReg->RegisterRunningDevice(desDoc,punk,initBSTR,resourcePathBSTR,
lifeTime,&DeviceID);

Could not register the device with the Device Host - 80070006

is there anyone who can answer my question?

FYI, refer attatched the sample project using VS2005
http://advenet.com/sisimma/blog/attachment/1079.ashx

thanks.

--
Message posted via http://www.pocketpcjunkies.com

From: sisimma via PocketPCJunkies.com on
sisimma wrote:
>Hi,
>
>I've ported UPnP sample code into Windows Mobile 6.0 SDK from "PUBLIC\SERVERS\
>SDK\SAMPLES\UPNP\DEVICE" in Windows Embedded CE 6.0.
>
>UPnP COM dll has been registered successfully and then run regdevice.exe.
>
>I'm asking why my code below doesn't return OK in upnpdevice.dll.
>
> hr = pReg->RegisterRunningDevice(desDoc,punk,initBSTR,resourcePathBSTR,
>lifeTime,&DeviceID);
>
>Could not register the device with the Device Host - 80070006
>
>is there anyone who can answer my question?
>
>FYI, refer attatched the sample project using VS2005
>http://advenet.com/sisimma/blog/attachment/1079.ashx
>
>thanks.

Today I've found no registry in Window Mobile professional device 6.0 for
Interfaces for upnphost interface even though upnphost.dll has been
registered successfully.

My understanding is that interfaces GUIDs below should have been set in
registy by installing Optional Server Components such as upnphost.ARM.cab and
upnpctrl.ARM.cab

// Reserved GUIDS for our use
//
// 204810b3-73b2-11d4-bf42-00b0d0118b56 LIBID_UPnPHostLib
// 204810b4-73b2-11d4-bf42-00b0d0118b56 IID_IUPnPEventSink
// 204810b5-73b2-11d4-bf42-00b0d0118b56 IID_IUPnPEventSource
// 204810b6-73b2-11d4-bf42-00b0d0118b56 IID_IUPnPRegistrar
// 204810b7-73b2-11d4-bf42-00b0d0118b56 IID_IUPnPReregistrar
// 204810b8-73b2-11d4-bf42-00b0d0118b56 IID_IUPnPDeviceProvider
// 204810b9-73b2-11d4-bf42-00b0d0118b56 CLSID_UPnPRegistrar
// 204810ba-73b2-11d4-bf42-00b0d0118b56 IID_IUPnPDeviceControl

could anyone help me with professional comments how to use upnphost.dll?
thank you in advance.

--
Message posted via PocketPCJunkies.com
http://www.pocketpcjunkies.com/Uwe/Forums.aspx/pocketpc-prog/200801/1

From: sisimma via PocketPCJunkies.com on
int _cdecl wmain()
{
// This executable makes the call to the Device Host to register a device

HRESULT hr = S_OK;
IUnknown *punk = NULL;
IDispatch *pIDisp = NULL;
IUPnPRegistrar *pReg = NULL;
IUPnPReregistrar *pRereg = NULL;
LPWSTR resourcePath = NULL;
DWORD dwSize = 0;
WCHAR fileDescriptionDoc[] = L"\\Program files\\regdevice\\device.xml";
WCHAR initString[] = L"UpnpDevice SDK Sample";
WCHAR filepath[] = L"\\Program Files\\regdevice";
LONG lifeTime = DEFAULT_DEVICE_LIFETIME;
BSTR DeviceID = NULL;
BSTR desDoc = NULL;
BSTR initBSTR = NULL;
BSTR resourcePathBSTR = NULL;
BSTR ProgID=L"UPNPSampleDevice.CUPNPDevice.1";
BSTR containerID=NULL;
// CHAR option;
INT getMsgRet = 0;

BOOL retVal = TRUE;

printf("\nSetup:");
printf("\nBefore running this program please make sure that the two XML
files");
printf("\nare in the same directory as the EXE.\n");
printf("\nAlso make sure that the command 'regsvrce UPNPDevice.dll'");
printf("\nhas been run to register device-specific COM object.\n");

hr = CoInitializeEx (NULL, COINIT_MULTITHREADED);
if (FAILED(hr))
{
printf("\nCould not initialize COM library");
return 0;
}

/* hr = CoInitializeSecurity(
NULL,
-1,
NULL,
NULL,
RPC_C_AUTHN_LEVEL_DEFAULT,
RPC_C_IMP_LEVEL_IMPERSONATE,
NULL,
EOAC_SECURE_REFS,
NULL
);
*/
if (FAILED(hr))
{
printf("\nCould not initialize COM security");
goto error;
}

// Now try to instantiate the Device Control Object
hr = CoCreateInstance(
// CLSID_UPNPSampleDimmerDevice,
CLSID_UPNPSampleDevice,
NULL,
CLSCTX_INPROC_SERVER,
__uuidof(IUPnPDeviceControl),
(LPVOID *) &punk
);

if (FAILED(hr))
{
printf("\nCould not Instantiate the Device Control Object. - %x",hr);
printf("\nCheck that the dll UPNPDevice.dll has been registered");
goto error;
}

// Continue with the registration and register the running device with the
Device Host
// get the resource path or the current directory where the XML files are
located

// Call GetCurrentDirectory() specifying nBufferLength = 0 to get the size
of the
// required buffer to hold path, then call this function again to fill in
the buffer
//dwSize = GetCurrentDirectoryW(0, NULL);
//resourcePath = (WCHAR *) CoTaskMemAlloc((dwSize + 1) * sizeof (WCHAR));
// add for for trailing "\"
resourcePath = (WCHAR *) CoTaskMemAlloc(100); // add for for trailing "\"
resourcePath = filepath;
if (resourcePath == NULL)
{
printf("\nMemory Allocation Failure.. exiting");
goto error;
}
/*
if (GetCurrentDirectoryW(dwSize, resourcePath) == 0)
{
printf("\nCould not get the current directory Path where the XML files
are located");
goto error;
}
*/
wcscat(resourcePath,L"\\");

//now we try to read in the description doc for the DimmerDevice
retVal = DescriptionDocToBSTR(fileDescriptionDoc, &desDoc);

if (retVal==FALSE)
{
printf("\nCould not load the description document for the device");
goto error;
}

initBSTR = SysAllocString(initString);
if (initBSTR==NULL)
{
printf("\nMemory Allocation Failure.. exiting");
goto error;
}

resourcePathBSTR = SysAllocString(resourcePath);
if (resourcePathBSTR == NULL)
{
printf("\nMemory Allocation Failure.. exiting");
goto error;
}

//now register the device with the Device Host service
hr = CoCreateInstance(
__uuidof(UPnPRegistrar),//CLSID_UPnPRegistrar
NULL,
CLSCTX_INPROC_SERVER,
// CLSCTX_LOCAL_SERVER,
__uuidof(IUPnPRegistrar),//IID_IUPnPRegistrar
(LPVOID *) &pReg
);
if (FAILED(hr))
{
printf("\nCould not get a pointer to the IUPnPRegistrar Interface
failed - %x",hr);
printf("\nCheck that the UPNP Device Host Component is installed on
this machine");
goto error;
}

//now get a pointer to the IID_IUPnPReregistrar
hr = CoCreateInstance(
__uuidof(UPnPRegistrar),//CLSID_UPnPRegistrar
NULL,
CLSCTX_INPROC_SERVER,
// CLSCTX_LOCAL_SERVER,
__uuidof(IUPnPReregistrar),//IID_IUPnPReregistrar
(LPVOID *) &pRereg
);

if (FAILED(hr))
{
printf("\nCould not get the pointer to the IUPnPReregistrar Interface -
%x",hr);
printf("\nCheck that the UPNP Device Host Component is installed on
this machine");
goto error;
}

hr = pReg->RegisterRunningDevice(desDoc,punk,initBSTR,resourcePathBSTR,
lifeTime,&DeviceID);

=============================================================
I've got E_HANDLE returned from pReg->RegisterRunningDevice
I think input values for the function are correct.
please help me out with experience of upnp device on windows mobile....
thanks.

--
Message posted via PocketPCJunkies.com
http://www.pocketpcjunkies.com/Uwe/Forums.aspx/pocketpc-prog/200801/1